frontend: pick corpus

dev
voje 5 years ago
parent e363cc3fd6
commit d84ad9e163

@ -386,7 +386,8 @@ def prepare_db():
# update entries (add headwords and fuctors for indexing)
for corpus in ["ssj", "kres"]:
for e in valdb[corpus].find({}):
#! hw_tids are not array ids
if e["srl_links"] is None:
continue
hw_tids = list(set([x["from"] for x in e["srl_links"]]))
hw_tokens = [helper_tid_to_token(tid, e["tokens"]) for tid in hw_tids]
headwords = [(t["lemma"] if t["msd"][0] == "G" else t["lemma"] + "_") for t in hw_tokens]
@ -403,11 +404,15 @@ def prepare_db():
res_hws = {}
res_fns = {}
for e in valdb[corpus].find({}):
if "headwords" not in e:
continue
for hw in e["headwords"]:
if hw in res_hws:
res_hws[hw] += 1
else:
res_hws[hw] = 1
if "functors" not in e:
continue
for fn in e["functors"]:
if fn in res_fns:
res_fns[fn] += 1

@ -9,8 +9,9 @@
<Nav></Nav>
<div class="my-home container-fluid">
<div class="row">
<div id="serach" class="col-sm-2 border-right fill">
<LWords v-if="this.$root.store.selIndex === 'words'"></LWords>
<div id="serach" class="col-sm-2 border-right fill" :key=this.$root.store.indexReloader>
<LWords
v-if="this.$root.store.selIndex.val === 'words'"></LWords>
<LFunctors v-else></LFunctors>
</div>
<div class="col-sm-10">

@ -32,7 +32,7 @@
<tr>
<label class="radio-inline"><input value="one" v-model="$root.store.radio" v-on:change="reload()" checked="" type="radio" name="optradio">posamezne povedi</label>&nbsp;&nbsp;
<label class="radio-inline"><input value="two" v-model="$root.store.radio" v-on:change="reload()" type="radio" name="optradio">skupne udeleženske vloge</label>&nbsp;&nbsp;
<label v-if="this.$root.store.selIndex === 'words'" class="radio-inline"><input value="three" v-model="$root.store.radio" v-on:change="reload()" type="radio" name="optradio">po meri</label>
<label v-if="this.$root.store.selIndex.val === 'words'" class="radio-inline"><input value="three" v-model="$root.store.radio" v-on:change="reload()" type="radio" name="optradio">po meri</label>
</tr>
</table>
</div>
@ -209,7 +209,7 @@ export default {
reload: function () {
this.state = "loading"
this.sentences = {}
if (this.$root.store.selIndex === "functors") this.getFFrames(this.hw)
if (this.$root.store.selIndex.val === "functors") this.getFFrames(this.hw)
else {
this.getFrames(this.hw)
if (this.$root.store.radio === "three") {

@ -6,7 +6,7 @@
<b-collapse is-nav id="nav_collapse">
<b-navbar-nav>
<b-nav-item-dropdown text="korpus" right>
<b-nav-item-dropdown :text=corpText right>
<b-dropdown-item v-for="option in optCorpora"
:value="option"
:key="option"
@ -18,11 +18,11 @@
</b-navbar-nav>
<b-navbar-nav>
<b-nav-item-dropdown text="prikaz" right>
<b-nav-item-dropdown :text=indexText right>
<b-dropdown-item v-for="option in optIndexes"
:value="option.val"
:key="option.val"
v-on:click="updateIndex(option.val)"
v-on:click="updateIndex(option)"
>
{{ option.key }}
</b-dropdown-item>
@ -59,24 +59,35 @@ export default {
name: "Nav",
props: ["appState"],
data() {return {
optCorpora: ["kres", "ssj"],
optIndexes: [
{key: "besede", val: "words"},
{key: "udeleženske vloge", val: "functors"},
],
optCorpora: ["kres", "ssj"],
indexText: "pregled: " + this.$root.store.selIndex.key,
corpText: "korpus: " + this.$root.store.selCorpus,
}},
methods: {
updateAll() {
this.$root.store.indexReloader += 1
this.$root.store.radio = "one"
this.$router.push({
name: "Home"
})
},
setCorpText(val) {
this.corpText = "kropus: " + val
},
updateCorpus(val) {
this.setCorpText(val)
this.$root.store.selCorpus = val
this.updateAll()
},
setIndexText(val) {
this.indexText = "index: " + val
},
updateIndex(val) {
this.setIndexText(val.key)
this.$root.store.selIndex = val
this.updateAll()
},

@ -38,8 +38,9 @@ const store = {
// api_addr: "http://193.2.76.103:5004", // production
token: null,
username: null,
selIndex: "words",
selIndex: {key: "besede", val: "words"},
selCorpus: "kres",
indexReloader: 0,
radio: "one",
has_se: [], // used for appending (se) to certain verbs
}

Loading…
Cancel
Save