forked from kristjan/cjvt-valency
todo: functors
This commit is contained in:
parent
40f6aea2e7
commit
8a3d6f0a5a
|
@ -95,8 +95,9 @@ def api_register():
|
|||
email == ""
|
||||
):
|
||||
return "ERR"
|
||||
email_hash = hashlib.sha256(email.encode("utf-8")).hexdigest()
|
||||
existing = list(valdb[USERS_COLL].find({
|
||||
"$or": [{"username": username}, {"email": email}]
|
||||
"$or": [{"username": username}, {"email": email_hash}]
|
||||
}))
|
||||
if len(existing) > 0:
|
||||
return "ERR: Username or email already exists."
|
||||
|
@ -104,8 +105,7 @@ def api_register():
|
|||
"username": username,
|
||||
"hpass": hashlib.sha256(
|
||||
password.encode("utf-8")).hexdigest(),
|
||||
"email": hashlib.sha256(
|
||||
email.encode("utf-8")).hexdigest()
|
||||
"email": email_hash
|
||||
}
|
||||
valdb[USERS_COLL].insert(entry)
|
||||
return "OK"
|
||||
|
@ -264,20 +264,19 @@ def api_get_frames():
|
|||
if hw is None:
|
||||
return json.dumps({"error": "Required argument: hw (headword)."})
|
||||
|
||||
rf_name = request.args.get("rf", "reduce_0") # 2nd is default
|
||||
rf_name = request.args.get("rf", "reduce_0")
|
||||
RF = reduce_functions[rf_name]["f"]
|
||||
|
||||
corpus = request.args.get("cor")
|
||||
if corpus not in CORPORA:
|
||||
return json.dumps({"error": "cor={kres,ssj}"})
|
||||
|
||||
# entry = vallex.entries[hw] # TODO hw -> [Frame,]
|
||||
cur = valdb[corpus].find({"headwords": hw})
|
||||
frames = []
|
||||
for ent in cur:
|
||||
# TODO: maybe filter by hw?
|
||||
frames += frames_from_db_entry(ent) # pre-process this step for prod TODO
|
||||
|
||||
# filter by relevant hw
|
||||
frames = [x for x in frames if x.hw == hw]
|
||||
|
||||
ret_frames = RF(frames, valdb[SENSEMAP_COLL])
|
||||
|
@ -290,10 +289,21 @@ def api_get_functor_frames():
|
|||
functor = request.args.get("functor")
|
||||
if functor is None:
|
||||
return json.dumps({"error": "Missing argument: functor."})
|
||||
rf_name = request.args.get("rf", "reduce_0") # 2nd is default
|
||||
|
||||
rf_name = request.args.get("rf", "reduce_0")
|
||||
RF = reduce_functions[rf_name]["f"]
|
||||
raw_frames = vallex.functors_index[functor] # TODO
|
||||
ret_frames = RF(raw_frames, vallex)
|
||||
|
||||
corpus = request.args.get("cor")
|
||||
if corpus not in CORPORA:
|
||||
return json.dumps({"error": "cor={kres,ssj}"})
|
||||
|
||||
cur = valdb[corpus].find({"functors": functor})
|
||||
frames = []
|
||||
for ent in cur:
|
||||
frames += frames_from_db_entry(ent) # pre-process this step for prod TODO
|
||||
|
||||
# raw_frames = vallex.functors_index[functor] # TODO
|
||||
ret_frames = RF(frames, valdb[SENSEMAP_COLL])
|
||||
return prepare_frames(ret_frames)
|
||||
|
||||
# FRAMES ----------------------------^
|
||||
|
|
Loading…
Reference in New Issue
Block a user