update(Blogger): generate index file for front-end blog search

This commit is contained in:
DanyLE 2023-05-22 14:04:05 +02:00
parent f9f27321ab
commit d011b004ec
4 changed files with 35 additions and 1 deletions

View File

@ -42,6 +42,23 @@ if data then
end end
cluster.tfidf(documents) cluster.tfidf(documents)
-- indexing all terms to cache file
local cache_file = dbpath..".index.json"
local f = io.open(cache_file, "w")
if f then
local indexes = {}
for id, doc in pairs(documents) do
for term,v in pairs(doc) do
if not indexes[term] then
indexes[term] = {}
end
indexes[term][tostring(id)] = doc[term].tfidf
end
end
f:write(JSON.encode(indexes))
f:close()
end
--
--local v = cluster.search("arm", documents) --local v = cluster.search("arm", documents)
--echo(JSON.encode(v)) --echo(JSON.encode(v))
local vectors, maxv, size = cluster.get_vectors(documents) local vectors, maxv, size = cluster.get_vectors(documents)

View File

@ -42,6 +42,23 @@ if data then
end end
cluster.tfidf(documents) cluster.tfidf(documents)
-- indexing all terms to cache file
local cache_file = dbpath..".index.json"
local f = io.open(cache_file, "w")
if f then
local indexes = {}
for id, doc in pairs(documents) do
for term,v in pairs(doc) do
if not indexes[term] then
indexes[term] = {}
end
indexes[term][tostring(id)] = doc[term].tfidf
end
end
f:write(JSON.encode(indexes))
f:close()
end
--
--local v = cluster.search("arm", documents) --local v = cluster.search("arm", documents)
--echo(JSON.encode(v)) --echo(JSON.encode(v))
local vectors, maxv, size = cluster.get_vectors(documents) local vectors, maxv, size = cluster.get_vectors(documents)

Binary file not shown.

View File

@ -95,7 +95,7 @@
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/Blogger/README.md", "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/Blogger/README.md",
"category": "Internet", "category": "Internet",
"author": "Xuan Sang LE", "author": "Xuan Sang LE",
"version": "0.2.10-a", "version": "0.2.11-a",
"dependencies": ["SimpleMDE@2.18.0-r","Katex@0.11.1-r","SQLiteDB@0.1.0-a"],"mimes":["none"], "dependencies": ["SimpleMDE@2.18.0-r","Katex@0.11.1-r","SQLiteDB@0.1.0-a"],"mimes":["none"],
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/Blogger/build/release/Blogger.zip" "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/Blogger/build/release/Blogger.zip"
}, },