=
Add compression and decompression functions for fact check data; update dependencies and remove obsolete files
fd342b4
using Oxygen | |
using HTTP | |
import OstreaCultura as OC | |
# Load the fasttext embeddings and the fasttext model | |
tmp_destination = tempname() | |
# Decompress the fact check data | |
OC.decompress_csv("data/fc_latest_maxi_compr", tmp_destination) | |
##### | |
const (fc_embed, fc) = OC.load_fasttext_embeddings(tmp_destination) | |
const (nar_embed, nar) = OC.load_fasttext_embeddings("data/expansive_claims_library_expanded_embed_maxi.csv") | |
@get "/greet" function(req::HTTP.Request) | |
return "hello world!" | |
end | |
## Send a query to the test-index index in the test-namespace namespace | |
#@get "/query" function(req::HTTP.Request, querytext::String, indexname::String, namespace::String, top_k::Int64=5, include_values::Bool=false) | |
# OC.query(querytext, indexname, namespace; top_k=top_k, include_values=include_values) | |
## Send a query to look for matches within an organic dataset | |
#@get "/queryclaims" function(req::HTTP.Request, claim::String, counterclaim::String, indexname::String, namespace::String, top_k::Int64=5000, include_values::Bool=false) | |
# OC.query_claims(claim, counterclaim, indexname, namespace; top_k=top_k, include_values=include_values) | |
## Classify a claim within the misinformation library | |
#@get "/classify" function(req::HTTP.Request, claim::String, counterclaim::String, indexname::String, namespace::String, top_k::Int64=10, include_values::Bool=false) | |
# OC.classify_claim(claim, counterclaim, indexname, namespace; top_k=top_k, include_values=include_values) | |
# Model is really 'namespace' in the OC library | |
#@get "/search" function(req::HTTP.Request, claim::String, model::String="narratives", top_k::Int64=5) | |
# # remove % signs from claim, replace with percent | |
# claim = replace(claim, "%" => "percent") | |
# OC.search(claim, "oc-hybrid-library-index", model; top_k=top_k, include_values=false) | |
@get "/fastfactsearch" function(req::HTTP.Request, claim::String, model::String="factchecks", top_k::Int64=5) | |
# remove % signs from claim, replace with percent | |
claim = replace(claim, "%" => "percent") | |
if model == "narratives" | |
json(OC.fast_topk(nar_embed, nar, claim, top_k)) | |
elseif model == "factchecks" | |
json(OC.fast_topk(fc_embed, fc, claim, top_k)) | |
else | |
"Model not found" | |
end | |
end | |
#@get "/searchplot" function(req::HTTP.Request, claim::String, model::String, top_k::Int64=5, include_values::Bool=false) | |
# OC.searchplot(claim, "oc-hybrid-library-index", model; top_k=top_k, include_values=include_values) | |
# start the web server | |
serve(host="0.0.0.0", port=8000) |