7 Commits

5 changed files with 39 additions and 15 deletions

2
.gitignore vendored
View File

@@ -10,5 +10,5 @@ build/*
# using kdev4, works fairly nicely!
.kdev4
**/*.kdev4
remote

View File

@@ -1,5 +1,3 @@
.PHONY: all release build transcrypt copy $(RES_LESS_FILE) $(RES_PY_FILE) $(RES_HTML_FILE) $(RES_XML_FILE)
SRC_FOLDER=$(CURDIR)/../src
RES_FOLDER=$(CURDIR)/../res
@@ -20,6 +18,7 @@ RES_PY_FILE=$(SRC_FOLDER)/$(PY_FILE)
RES_HTML_FILE=$(RES_FOLDER)/$(HTML_FILE)
RES_XML_FILE=$(RES_FOLDER)/$(XML_FILE)
.PHONY: all release build transcrypt copy $(RES_LESS_FILE) $(RES_PY_FILE) $(RES_HTML_FILE) $(RES_XML_FILE) $(CONV_FILE)
.DEFAULT_GOAL := all
all: BR_FLAGS := $(BR_FLAGS) --debug

View File

@@ -3,15 +3,19 @@
# fail if any command fails
set -e
OUT_FILE=conversions.csv
if [[ -z "${API_KEY}" ]]; then
echo "API_KEY not defined, should be api key to CJVT's gitea"
exit 1
fi
OUT_FILE=conversions.csv
TEMP_FILE=$(mktemp)
if [ -f $OUT_FILE ]; then
echo "file for conversion of SKE collocations: '$OUT_FILE' already exists, skipping."
exit 0
fi
rm -r $OUT_FILE
TEMP_FILE=$(mktemp)
curl -s "https://gitea.cjvt.si/api/v1/repos/generic/data_admin/contents/resources/structure_conversions.csv?token=$API_KEY" -o $TEMP_FILE
echo "wc: $(wc $TEMP_FILE)"

View File

@@ -34,12 +34,23 @@ def build_structure_conversions():
structure_conversions.append((__new__(RegExp(vfrom, 'u')), vto_name, vto_id))
def convert_structure(structure):
def convert_structure(structure, type):
if structure_conversions is None:
build_structure_conversions()
for vfrom, vto_name, vto_id in structure_conversions:
match = structure.match(vfrom)
# fix for ids 65, 66, 67 which instead matched with 64
if match and vto_id == '64' and '-s' in type:
vto_name = 's0-vp-s0'
vto_id = '65'
elif match and vto_id == '64' and '-g' in type:
vto_name = 'gg-vp-gg'
vto_id = '66'
elif match and vto_id == '64' and '-r' in type:
vto_name = 'r-vp-r'
vto_id = '67'
if match:
# we need to remove replace alias here as we want to use javascript's one
__pragma__('noalias', 'replace')
@@ -49,4 +60,4 @@ def convert_structure(structure):
return result, vto_id
window.console.log("Unknown structure: ", structure)
return None
return 'N/A', '/'

View File

@@ -26,6 +26,7 @@ class SkeExample:
self.mid = ""
self.s_id = ""
self.gf2_good = None
self.gf2_check = False
@staticmethod
def fromLine(line):
@@ -58,7 +59,7 @@ class SkeCollocation:
def __init__(self, data):
self.word = data.word
self.frequency = data.count
self.structure_name, self.structure_id = convert_structure(data.gramrel)
self.structure_name, self.structure_id = convert_structure(data.gramrel, data.lempos)
self.other = {"score": data.score, "cm": data.cm}
@@ -140,7 +141,7 @@ class SkeModal(ClickMessage):
elif type(data) is list:
window.console.log(data)
# check if gf2 examples are loaded or not
if data[0].gf2_good is None:
if not data[0].gf2_check and type(data[0]) is SkeExample:
# we get the data, we have to match it with available data on our gf2 examples API
match_gf2_examples(data, page_num, search_term, ske_index)
@@ -161,12 +162,18 @@ class SkeModalGf2Update(SkeModal):
example.gf_good = False
data_dict[example.s_id] = example
bad_response = dict(response_data["bad"])
for gf_sid, gf_data in bad_response.items():
data_dict[gf_sid].gf2_good = None
data_dict[gf_sid].gf2_check = True
good_response = dict(response_data["good"])
for gf_sid, gf_data in good_response.items():
data_dict[gf_sid].left = gf_data.left
data_dict[gf_sid].mid = gf_data.mid
data_dict[gf_sid].right = gf_data.right
data_dict[gf_sid].gf2_good = True
data_dict[gf_sid].gf2_check = True
# changed data_dict, now we can redraw!
# just let it do its thing in update_model
@@ -217,10 +224,12 @@ class SkeInsert(DataChgClickMessage):
console.log("You really should not be here, my lady")
continue
model.reset()
def _as_corpus_example(self, example):
new_example = Example()
new_example.inner = CorpusExample()
new_example.inner.other_attributes["exampleId"] = example.s_id
new_example.inner.other_attributes["example_id"] = example.s_id
new_example.inner.cluster = ExampleClusters.first_empty_cluster()
lex_left = ComponentLexeme()
@@ -229,7 +238,7 @@ class SkeInsert(DataChgClickMessage):
lex_mid = ComponentLexeme()
lex_mid.text = example["mid"]
lex_mid.role = "headword"
lex_mid.role = "collocation"
lex_right = ComponentLexeme()
lex_right.text = example["right"]
@@ -243,6 +252,7 @@ class SkeInsert(DataChgClickMessage):
new_collocation.inner = MultiwordExample()
new_collocation.inner.other_attributes["structure_id"] = example.structure_id
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"
@@ -253,7 +263,7 @@ class SkeInsert(DataChgClickMessage):
lex_mid = ComponentLexeme()
lex_mid.text = example.word
lex_mid.role = "headword"
lex_mid.role = "collocation"
lex_right = ComponentLexeme()
lex_right.text = ""