mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-12-25 19:58:21 +01:00
update(Blogger): generate index file for front-end blog search
This commit is contained in:
parent
f9f27321ab
commit
d011b004ec
@ -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)
|
||||||
|
@ -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.
@ -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"
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user