view and save of ske examples/collocations
This commit is contained in:
parent
8bb506700d
commit
6912222a53
|
@ -315,6 +315,21 @@
|
||||||
.ske-line {
|
.ske-line {
|
||||||
display: block;
|
display: block;
|
||||||
margin-top: 0.2em;
|
margin-top: 0.2em;
|
||||||
|
|
||||||
|
.checkable {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grey1 {
|
||||||
|
margin-left: 0.3em;
|
||||||
|
background-color: @silver;
|
||||||
|
color: @black;
|
||||||
|
}
|
||||||
|
.grey2 {
|
||||||
|
margin-left: 0.3em;
|
||||||
|
background-color: @black;
|
||||||
|
color: @silver;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ from lib.snabbdom import h
|
||||||
|
|
||||||
from model.example.example import Example
|
from model.example.example import Example
|
||||||
from model.example.corpus_example import CorpusExample
|
from model.example.corpus_example import CorpusExample
|
||||||
|
from model.example.multiword_example import MultiwordExample
|
||||||
from model.example.component_lexeme import ComponentLexeme
|
from model.example.component_lexeme import ComponentLexeme
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,10 +33,23 @@ class SkeExample:
|
||||||
|
|
||||||
class SkeCollocation:
|
class SkeCollocation:
|
||||||
def __init__(self, data):
|
def __init__(self, data):
|
||||||
self.text = data.cm
|
self.word = data.word
|
||||||
|
self.frequency = data.count
|
||||||
|
self.structure_name = data.gramrel
|
||||||
|
|
||||||
|
self.other = {"score": data.score, "cm": data.cm}
|
||||||
|
|
||||||
def view(self):
|
def view(self):
|
||||||
return h("span", {}, self.text)
|
return [
|
||||||
|
h("span.grey1", {}, self.word),
|
||||||
|
h("span", {}, ","),
|
||||||
|
h("span.grey2", {}, self.frequency),
|
||||||
|
h("span", {}, ","),
|
||||||
|
h("span.grey1", {}, self.other["score"]),
|
||||||
|
h("span", {}, ","),
|
||||||
|
h("span.grey2", {}, self.other["cm"]),
|
||||||
|
h("span", {}, ","),
|
||||||
|
h("span.grey1", {}, self.structure_name)]
|
||||||
|
|
||||||
|
|
||||||
def get_parser(ske_index_type):
|
def get_parser(ske_index_type):
|
||||||
|
@ -102,9 +116,6 @@ class SkeInsert(DataChgClickMessage):
|
||||||
if len(data) == 0:
|
if len(data) == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
if not isinstance(data[0], SkeExample):
|
|
||||||
return
|
|
||||||
|
|
||||||
sense_num = document.getElementById("ske-sense-select").selectedIndex
|
sense_num = document.getElementById("ske-sense-select").selectedIndex
|
||||||
sense = model.entry.senses[sense_num]
|
sense = model.entry.senses[sense_num]
|
||||||
|
|
||||||
|
@ -115,23 +126,55 @@ class SkeInsert(DataChgClickMessage):
|
||||||
if not element.checked:
|
if not element.checked:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
elif isinstance(ex, SkeExample):
|
||||||
|
sense.examples.append(self._as_corpus_example(ex))
|
||||||
|
|
||||||
|
elif isinstance(ex, SkeCollocation):
|
||||||
|
sense.examples.append(self._as_multiword_example(ex))
|
||||||
|
|
||||||
|
else:
|
||||||
|
console.log("You really should not be here, my lady")
|
||||||
|
continue
|
||||||
|
|
||||||
|
def _as_corpus_example(self, example):
|
||||||
new_example = Example()
|
new_example = Example()
|
||||||
new_example.inner = CorpusExample()
|
new_example.inner = CorpusExample()
|
||||||
|
|
||||||
lex_left = ComponentLexeme()
|
lex_left = ComponentLexeme()
|
||||||
lex_left.text = ex["left"]
|
lex_left.text = example["left"]
|
||||||
lex_left.role = "other"
|
lex_left.role = None
|
||||||
|
|
||||||
lex_mid = ComponentLexeme()
|
lex_mid = ComponentLexeme()
|
||||||
lex_mid.text = ex["mid"]
|
lex_mid.text = example["mid"]
|
||||||
lex_mid.role = "headword"
|
lex_mid.role = "headword"
|
||||||
|
|
||||||
lex_right = ComponentLexeme()
|
lex_right = ComponentLexeme()
|
||||||
lex_right.text = ex["right"]
|
lex_right.text = example["right"]
|
||||||
lex_right.role = "other"
|
lex_right.role = None
|
||||||
|
|
||||||
new_example.components.extend([lex_left, lex_mid, lex_right])
|
new_example.components.extend([lex_left, lex_mid, lex_right])
|
||||||
|
return new_example
|
||||||
|
|
||||||
# now add it to senses
|
def _as_multiword_example(self, example):
|
||||||
sense.examples.append(new_example)
|
new_collocation = Example()
|
||||||
|
new_collocation.inner = MultiwordExample()
|
||||||
|
|
||||||
|
new_collocation.inner.other_attributes["structureName"] = example.structure_name
|
||||||
|
new_collocation.inner.other_attributes["logDice"] = example.other["score"]
|
||||||
|
new_collocation.inner.other_attributes["frequency"] = example.frequency
|
||||||
|
new_collocation.inner.type = "collocation"
|
||||||
|
|
||||||
|
lex_left = ComponentLexeme()
|
||||||
|
lex_left.text = ""
|
||||||
|
lex_left.role = None
|
||||||
|
|
||||||
|
lex_mid = ComponentLexeme()
|
||||||
|
lex_mid.text = example.word
|
||||||
|
lex_mid.role = "headword"
|
||||||
|
|
||||||
|
lex_right = ComponentLexeme()
|
||||||
|
lex_right.text = ""
|
||||||
|
lex_right.role = None
|
||||||
|
|
||||||
|
new_collocation.components.extend([lex_left, lex_mid, lex_right])
|
||||||
|
return new_collocation
|
||||||
|
|
Loading…
Reference in New Issue
Block a user