def term_ranking(t): order = get_matrix('order', t.dictionary.version) terms = [ term(int(i)) for i in sorted(order[t.index, :].indices, key=lambda o: order[t.index, o]) ] return [t for t in terms if len(t) == 1], [t for t in terms if len(t) != 1]
def translate_update(root, f): update = {'terms': {str(s.script): str(f(s.script)) for s in term(root).relations.contains} } version = create_dictionary_version(latest_dictionary_version(), update=update) upload_to_s3(version) print(version)
def get_competence_en_curr_data_diff(): update = {} remove = [] for t in term("M:.-O:.-'M:.-wa.e.-'t.-x.-s.y.-',").relations.contains: if len(t) == 1 or len(t) == 2 or len(t) == 18: update[str(t.script)] = str(translate_competence_en_curr_data(t.script)) else: remove.append(str(t.script)) return update, remove
def term_ranking(t): order = get_matrix('order', t.dictionary.version) terms = [term(int(i)) for i in sorted(order[t.index, :].indices, key=lambda o: order[t.index, o])] return [t for t in terms if len(t) == 1], [t for t in terms if len(t) != 1]
# **_up # }, # 'remove': { # *_rem # } # } # print('\n'.join("{} => {}".format(a, b) for a, b in _up.items())) # version = create_dictionary_version(latest_dictionary_version(), update=update, remove=_rem) # upload_to_s3(version) # print(version) root = "O:.M:.-M:.-'" translator = translate_ecosystem_intl_col_tern "dictionary_2018-06-08_17:07:06" print(str(translator(script(root)))) d = Dictionary("dictionary_2018-06-08_17:07:06") # translate_update("s.u.-'O:M:.-'O:.-',+s.u.-'M:O:.-O:.-'M:.-',", translate_formes_visuelles) diff = { **{ str(s.script): str(translate_competence_en_curr_data(s.script)) for s in term("M:.-O:.-'M:.-wa.e.-'t.-x.-s.y.-',", d).relations.contains }, # **{str(s.script): str(translate_ecosystem_intl_col_tern(s.script)) for s in term("O:.M:.-M:.-'", d).relations.contains}, } import json print(json.dumps(diff, indent=True)) version = create_dictionary_version(None, diff=diff) # upload_to_s3(version) print(version)
# _up, _rem = get_competence_en_curr_data_diff() # update = {'terms': { # **{str(s.script): str(translate_mouvements_et_milieux(s.script)) for s in term("i.f.B:.-+u.f.M:.-O:.-'").relations.contains}, # **_up # }, # 'remove': { # *_rem # } # } # print('\n'.join("{} => {}".format(a, b) for a, b in _up.items())) # version = create_dictionary_version(latest_dictionary_version(), update=update, remove=_rem) # upload_to_s3(version) # print(version) root = "O:.M:.-M:.-'" translator = translate_ecosystem_intl_col_tern "dictionary_2018-06-08_17:07:06" print(str(translator(script(root)))) d = Dictionary("dictionary_2018-06-08_17:07:06") # translate_update("s.u.-'O:M:.-'O:.-',+s.u.-'M:O:.-O:.-'M:.-',", translate_formes_visuelles) diff = { **{str(s.script): str(translate_competence_en_curr_data(s.script)) for s in term("M:.-O:.-'M:.-wa.e.-'t.-x.-s.y.-',", d).relations.contains}, # **{str(s.script): str(translate_ecosystem_intl_col_tern(s.script)) for s in term("O:.M:.-M:.-'", d).relations.contains}, } import json print(json.dumps(diff, indent=True)) version = create_dictionary_version(None, diff=diff) # upload_to_s3(version) print(version)
# "f.o.-f.o.-'E:.-U:.n.-l.-',E:.-U:.M:T:.-l.-'E:.-A:.M:T:.-l.-',_": "Parties du corps: le tronc", # "f.o.-f.o.-'E:.-U:.t.-l.-',E:.-U:.M:T:.-l.-'E:.-A:.M:T:.-l.-',_": "Parties du corps: la tête", # "f.o.-f.o.-',n.i.-f.i.-',M:O:.-O:.-',_": "Parties du corps: membres", # "f.o.-f.o.-'E:.-U:.S:+B:T:.-l.-',E:.-U:.M:T:.-l.-'E:.-A:.M:T:.-l.-',_": "Parties du corps: la tête et le tronc" # }, # 'en': { # "f.o.-f.o.-',n.i.-f.i.-',M:O:.-O:.-',_+f.o.-f.o.-'E:.-U:.S:+B:T:.-l.-',E:.-U:.M:T:.-l.-'E:.-A:.M:T:.-l.-',_": "body parts", # "f.o.-f.o.-'E:.-U:.n.-l.-',E:.-U:.M:T:.-l.-'E:.-A:.M:T:.-l.-',_": "Body parts: trunk", # "f.o.-f.o.-'E:.-U:.t.-l.-',E:.-U:.M:T:.-l.-'E:.-A:.M:T:.-l.-',_": "Body parts: head", # "f.o.-f.o.-',n.i.-f.i.-',M:O:.-O:.-',_": "body parts: limbs", # "f.o.-f.o.-'E:.-U:.S:+B:T:.-l.-',E:.-U:.M:T:.-l.-'E:.-A:.M:T:.-l.-',_": "Body parts: head and trunk" # # } # } # } # to_remove = ["f.o.-f.o.-'E:.-U:.n.-l.-',E:.-U:.M:T:.-l.-'E:.-A:.M:T:.-l.-',_", # "f.o.-f.o.-'E:.-U:.t.-l.-',E:.-U:.M:T:.-l.-'E:.-A:.M:T:.-l.-',_", # "f.o.-f.o.-',n.i.-f.i.-',M:O:.-O:.-',_" # ] to_remove, to_add = factorize_root( term( "b.i.-n.i.-'l.i.-n.i.-'+m.+l.i.-f.i.-'+wu.f.A:.-+a.S:.-+i.U:.-+e.O:.-+S:+T:T:.i.-'n.o.-n.o.-'+f.o.-f.o.-'+n.-B:.A:.-+S:+B:.U:.-'," )) version = create_dictionary_version(latest_dictionary_version(), add=to_add, remove=to_remove) upload_to_s3(version) print(version)