forked from kristjan/cjvt-valency
fixed a few bugs; todo: senses
This commit is contained in:
parent
87b1d010e2
commit
e4730c40e1
6
Makefile
6
Makefile
|
@ -75,8 +75,10 @@ frontend-prod:
|
|||
|
||||
|
||||
## Backend
|
||||
backend-env: python-env-install
|
||||
|
||||
backend-dev-init: python-env-install
|
||||
cd ./src/backend_flask; python3 app.py \
|
||||
--config-file ./conf_files/dev_conf_init.yaml \
|
||||
--dbuser $(DB_USR_USER) --dbpass $(DB_USR_PASS) --dbaddr $(DBADDR)
|
||||
|
||||
backend-dev: python-env-install
|
||||
cd ./src/backend_flask; python3 app.py \
|
||||
|
|
|
@ -48,7 +48,11 @@ Relies heavily on the database. Set that up first.
|
|||
```bash
|
||||
$ make python-env
|
||||
|
||||
# $ make backend-dev # development
|
||||
# development:
|
||||
$ make backend-dev-init # run the first time, to prepare the db, then kill
|
||||
$ make backend-dev # debug with this one
|
||||
|
||||
# production
|
||||
$ make backend-prod
|
||||
```
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ SENSEMAP_COLL = "sensemap"
|
|||
|
||||
# pre-generated data (gui leftside word index)
|
||||
CORPORA = ["ssj", "kres"]
|
||||
app_index = {c: {} for c in CORPORA}
|
||||
app_index = None
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
valdb = None
|
||||
|
@ -239,7 +239,6 @@ def prepare_frames(ret_frames):
|
|||
# append sentences
|
||||
for frame in ret_frames:
|
||||
unique_sids = {".".join(x.split(".")[:-1]): x for x in frame.tids}
|
||||
log.debug(str(unique_sids))
|
||||
# frame.sentences = []
|
||||
frame.aggr_sent = {}
|
||||
# sid, tid==hw
|
||||
|
@ -268,8 +267,13 @@ def api_get_frames():
|
|||
rf_name = request.args.get("rf", "reduce_0") # 2nd is default
|
||||
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.kres.find({"headwords": hw})
|
||||
cur = valdb[corpus].find({"headwords": hw})
|
||||
print("N_results: " + str(cur.count()))
|
||||
frames = []
|
||||
for ent in cur:
|
||||
# TODO: maybe filter by hw?
|
||||
|
@ -277,11 +281,7 @@ def api_get_frames():
|
|||
|
||||
# return json.dumps([x.to_json() for x in frames])
|
||||
|
||||
print("A")
|
||||
print(frames[0].to_json())
|
||||
ret_frames = RF(frames, None)
|
||||
print("B")
|
||||
print(ret_frames[0].to_json())
|
||||
return prepare_frames(ret_frames)
|
||||
|
||||
|
||||
|
@ -438,6 +438,7 @@ def prepare_db():
|
|||
valdb[corpus].ensure_index([("functors", pymongo.ASCENDING)])
|
||||
|
||||
# create app_index (used in frontend, left side word index)
|
||||
tmp_app_index = {c: {} for c in CORPORA}
|
||||
for corpus in CORPORA:
|
||||
res_hws = {}
|
||||
res_fns = {}
|
||||
|
@ -467,11 +468,13 @@ def prepare_db():
|
|||
|
||||
for k, e in alphabetical.items():
|
||||
alphabetical[k] = sorted(e, key=lambda x: x[0])
|
||||
app_index[corpus]["words"] = alphabetical
|
||||
tmp_app_index[corpus]["words"] = alphabetical
|
||||
|
||||
functors = [(k, e) for (k, e) in res_fns.items()]
|
||||
functors = sorted(functors, key=lambda x: x[0])
|
||||
app_index[corpus]["functors"] = functors
|
||||
tmp_app_index[corpus]["functors"] = functors
|
||||
|
||||
valdb.appindex.update({"dockey": "appindex"}, {"dockey": "appindex", "data": tmp_app_index}, upsert=True)
|
||||
|
||||
# APP PREFLIGHT ---------------------^
|
||||
|
||||
|
@ -506,9 +509,12 @@ if __name__ == "__main__":
|
|||
)
|
||||
valdb = client.valdb
|
||||
|
||||
if config["prepare_db"]:
|
||||
if bool(config["prepare_db"]):
|
||||
prepare_db()
|
||||
|
||||
# app index from db
|
||||
app_index = (valdb.appindex.find_one({"dockey": "appindex"}))["data"]
|
||||
|
||||
# log.info("[*] Starting app.py with config:\n%s".format(config))
|
||||
log.info("[*] Starting app.py with config:\n{}".format(config))
|
||||
|
||||
|
|
|
@ -3,5 +3,5 @@ debug: True
|
|||
port: 5004
|
||||
host: localhost
|
||||
logfile: "/var/log/valency_backend.log"
|
||||
prepare_db: True
|
||||
prepare_db: False
|
||||
---
|
||||
|
|
7
src/backend_flask/conf_files/dev_conf_init.yaml
Normal file
7
src/backend_flask/conf_files/dev_conf_init.yaml
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
debug: True
|
||||
port: 5004
|
||||
host: localhost
|
||||
logfile: "/var/log/valency_backend.log"
|
||||
prepare_db: True
|
||||
---
|
2
src/frontend_vue/package-lock.json
generated
2
src/frontend_vue/package-lock.json
generated
|
@ -116,7 +116,7 @@
|
|||
"argparse": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
||||
"integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=",
|
||||
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
|
|
|
@ -121,7 +121,8 @@ export default {
|
|||
this.$http.get(
|
||||
this.$root.store.api_addr +
|
||||
"/api/functor-frames" +
|
||||
"?functor=" + functor + "&rf=" + reduce_fun
|
||||
"?functor=" + functor + "&rf=" + reduce_fun +
|
||||
"&cor=" + component.$root.store.selCorpus
|
||||
)
|
||||
.then(function (response) {
|
||||
component.$root.store.api_error = null
|
||||
|
@ -150,7 +151,8 @@ export default {
|
|||
var component = this
|
||||
this.$http.get(
|
||||
this.$root.store.api_addr + "/api/frames" +
|
||||
"?hw=" + hw + "&rf=" + reduce_fun
|
||||
"?hw=" + hw + "&rf=" + reduce_fun +
|
||||
"&cor=" + component.$root.store.selCorpus
|
||||
)
|
||||
.then(function (response) {
|
||||
component.$root.store.api_error = null
|
||||
|
@ -176,9 +178,11 @@ export default {
|
|||
var words = []
|
||||
var hw_idx = -1
|
||||
var tmp_hw = this.hw
|
||||
/* Removes underscore for adjectives
|
||||
if (tmp_hw[tmp_hw.length - 1] === "_") {
|
||||
tmp_hw = tmp_hw.substr(0, tmp_hw.length - 1)
|
||||
}
|
||||
*/
|
||||
for (var i in sentence) {
|
||||
words.push(sentence[i][1].word)
|
||||
if (sentence[i][1].lemma === tmp_hw && hw_idx == -1) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user