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) # update entries (add headwords and fuctors for indexing)
for corpus in ["ssj", "kres"]: for corpus in ["ssj", "kres"]:
for e in valdb[corpus].find({}): 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_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] 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] 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_hws = {}
res_fns = {} res_fns = {}
for e in valdb[corpus].find({}): for e in valdb[corpus].find({}):
if "headwords" not in e:
continue
for hw in e["headwords"]: for hw in e["headwords"]:
if hw in res_hws: if hw in res_hws:
res_hws[hw] += 1 res_hws[hw] += 1
else: else:
res_hws[hw] = 1 res_hws[hw] = 1
if "functors" not in e:
continue
for fn in e["functors"]: for fn in e["functors"]:
if fn in res_fns: if fn in res_fns:
res_fns[fn] += 1 res_fns[fn] += 1

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

@ -32,7 +32,7 @@
<tr> <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="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 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> </tr>
</table> </table>
</div> </div>
@ -209,7 +209,7 @@ export default {
reload: function () { reload: function () {
this.state = "loading" this.state = "loading"
this.sentences = {} this.sentences = {}
if (this.$root.store.selIndex === "functors") this.getFFrames(this.hw) if (this.$root.store.selIndex.val === "functors") this.getFFrames(this.hw)
else { else {
this.getFrames(this.hw) this.getFrames(this.hw)
if (this.$root.store.radio === "three") { if (this.$root.store.radio === "three") {

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

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

Loading…
Cancel
Save