Feature#1405 collocation structure
This commit is contained in:
parent
b010414bfe
commit
aca8093ab3
|
@ -31,7 +31,7 @@ all: build
|
||||||
build: copy $(CSS_FILE) bundle.js local.js
|
build: copy $(CSS_FILE) bundle.js local.js
|
||||||
|
|
||||||
transcrypt: $(RES_PY_FILE) $(TS_BUILD)
|
transcrypt: $(RES_PY_FILE) $(TS_BUILD)
|
||||||
transcrypt $(TS_FLAGS) $<
|
python3 -m transcrypt $(TS_FLAGS) $<
|
||||||
|
|
||||||
bundle.js: transcrypt $(CONV_FILE)
|
bundle.js: transcrypt $(CONV_FILE)
|
||||||
cd ..; browserify $(BR_FLAGS) build/$(TS_BUILD)/main.js -o build/bundle.js
|
cd ..; browserify $(BR_FLAGS) build/$(TS_BUILD)/main.js -o build/bundle.js
|
||||||
|
|
|
@ -34,19 +34,30 @@ def build_structure_conversions():
|
||||||
structure_conversions.append((__new__(RegExp(vfrom, 'u')), vto_name, vto_id))
|
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:
|
if structure_conversions is None:
|
||||||
build_structure_conversions()
|
build_structure_conversions()
|
||||||
|
|
||||||
for vfrom, vto_name, vto_id in structure_conversions:
|
for vfrom, vto_name, vto_id in structure_conversions:
|
||||||
match = structure.match(vfrom)
|
match = structure.match(vfrom)
|
||||||
|
# fix for ids 65, 66 which matched instead with 64
|
||||||
|
if match and vto_id == '64' and '-g' in type:
|
||||||
|
vto_name = 'gg-vp-gg'
|
||||||
|
vto_id = '66'
|
||||||
|
elif match and vto_id == '64' and '-s' in type:
|
||||||
|
vto_name = 's0-vp-s0'
|
||||||
|
vto_id = '65'
|
||||||
|
|
||||||
if match:
|
if match:
|
||||||
# we need to remove replace alias here as we want to use javascript's one
|
# we need to remove replace alias here as we want to use javascript's one
|
||||||
__pragma__('noalias', 'replace')
|
__pragma__('noalias', 'replace')
|
||||||
result = structure.replace(vfrom, vto_name).strip()
|
result = structure.replace(vfrom, vto_name).strip()
|
||||||
__pragma__('alias', 'replace', "py_replace")
|
__pragma__('alias', 'replace', "py_replace")
|
||||||
|
|
||||||
|
if vto_id == '64':
|
||||||
|
console.log(structure)
|
||||||
|
|
||||||
return result, vto_id
|
return result, vto_id
|
||||||
|
|
||||||
window.console.log("Unknown structure: ", structure)
|
window.console.log("Unknown structure: ", structure)
|
||||||
return None
|
return 'N/A', '/'
|
||||||
|
|
|
@ -58,7 +58,7 @@ class SkeCollocation:
|
||||||
def __init__(self, data):
|
def __init__(self, data):
|
||||||
self.word = data.word
|
self.word = data.word
|
||||||
self.frequency = data.count
|
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.filterwords)
|
||||||
|
|
||||||
self.other = {"score": data.score, "cm": data.cm}
|
self.other = {"score": data.score, "cm": data.cm}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user