def _split_subst(s): subst, attr, mode = s assert isinstance(mode, NullScript) subst0, subst1, mode = subst assert isinstance(mode, NullScript) return m(m(subst0), m(subst1), attr)
def add_row_evolution_culturel(): """ M:O:.-'F:.-'k.o.-t.o.-', => M:O:.-+S:.-'F:.-'k.o.-t.o.-', :return: """ src = script("M:O:.-'F:.-'k.o.-t.o.-',") s, a, _m = src tgt = m(s + script("S:.-'"), a, _m) to_update = {} to_remove = [] to_update[src] = tgt # for ss_s in s.singular_sequences: # to_update[m(ss_s, a, _m)] = m(ss_s, a, _m) for ss_a in a.singular_sequences: to_update[m(s, ss_a, _m)] = m(script("S:.-'"), ss_a, _m) # to_update[m(s, ss_a, _m)] = m(s + script("S:.-'"), ss_a, _m) # to_add.append() # # to_remove.append() # # res.append(tgt) # for r in tgt.singular_sequences: return to_update, to_remove
def translate_body_parts(s): def _level_3(s): s2, a2, m2 = s s1, a1, m1 = a2 return m(s2, m(s1, m(a1.children[0], m1.children[0])), m2) s4, a4, _ = s s3, a3, _ = a4 return m(s4, m(_level_3(s3), _level_3(a3)))
def translate_temps(s): """ t.o. - n.o. - 'M:O:.-', """ root = script("t.o.-n.o.-M: O:.-'") if not s.singular_sequences_set.issubset(root.singular_sequences): return s _s, _a, _m = s return m(m(_s, _a), m(_m))
def migrate_sOOF(scri): "s.O:O:.-F:.-' => s.o.-O:O:.-'F:.-'," if not set(scri.singular_sequences).issubset( script("s.O:O:.-F:.-'").singular_sequences_set): return scri s, a, _ = scri.children ss, sa, _ = s.children return m(m(m(ss, script('o.')), m(sa)), m(a))
def migrate_EOOMt0(scri): "E:.-'O:O:.-M:.t.o.-', => E:.-'O:O:.-M:.-'t.o.-'," if not set(scri.singular_sequences).issubset( script("E:.-'O:O:.-M:.t.o.-',").singular_sequences_set): return scri s, a, _ = scri.children _as, aa, _ = a.children aas, aaa, aam = aa.children return m(s, m(_as, m(aas)), m(m(aaa, aam)))
def _transfer_substance(s): """ E:O:.-M:O:.-t.o.-' => E:.-O:.M:O:.-t.o.-‘ """ subst, attr, mode = s attr0, attr1, attr2 = attr assert isinstance(attr1, NullScript) and isinstance(attr2, NullScript) subst, subst1, subst2 = subst assert isinstance(subst1, NullScript) and isinstance(subst2, NullScript) subst0, subst1, subst2 = subst assert isinstance(subst2, NullScript) return m(m(m(subst0)), m(m(subst1), attr0), mode)
def _add_mode_t(s): """ O:O:.O:O:.- => O:O:.O:O:.t.- """ subst, attr, mode = s assert isinstance(mode, NullScript) return m(subst, attr, script('t.'))
def translate_competence_en_curr_data(s): """M:.-O:.-'M:.-wa.e.-'t.-x.-s.y.-', => t.-x.-s.y.-' wa.e.-', M:M:.-',O:.-',_""" subst, attr, mode = s attr_s, attr_a, attr_m = attr assert isinstance(attr_m, NullScript) subst_s, subst_a, subst_m = subst assert isinstance(subst_m, NullScript) first_M = subst_s.children[0].children[0] return m(m(mode, m(attr_a)), m(m(m(m(first_M, attr_s.children[0].children[0])))), m(m(subst_a)))
def translate_ocean(s): if s in script("M:.-'M:.-'n.-T:.A:.-',"): return _rotate_sc(s) elif s in script("s.-S:.U:.-'l.-S:.O:.-'n.-T:.A:.-',"): subst, attr, mode = s return m(subst, mode, attr) elif isinstance(s, AdditiveScript): return AdditiveScript(children=[translate_ocean(c) for c in s])
def migrate_EOETI(scri): "E:.O:.E:T:.+I:.- => O:.E:T:.+I:.-" if not set(scri.singular_sequences).issubset( script("E:.O:.E:T:.+I:.-").singular_sequences_set): return scri s, a, _m = scri.children return m(script('S:.'), a, _m)
def migrate_tidi(s): """ t.i.-d.i.-t.+M:O:.-' t.i.-d.i.-'t.+M:O:.-', :param s: :return: """ root = script("t.i.-d.i.-t.+M:O:.-'") if not s.singular_sequences_set.issubset(root.singular_sequences_set): return s _s, a, _m = s return m(m(_s, a), m(_m))
def test_multiplication(self): sub = sc('wa.') att = sc('u.') mode = sc('O:.') r = m(substance=sub, attribute=att, mode=mode) self.assertEqual(r.layer, 2) self.assertIsInstance(r, MultiplicativeScript) self.assertListEqual(r.children, [sub, att, mode])
def _insert_f_additive(s): """i.B:.-+u.M:.-O:.-' => i.f.B:.-+u.f.M:.-O:.-'""" subst, attr, mode = s assert isinstance(mode, NullScript) if isinstance(subst, AdditiveScript): subst = AdditiveScript([_insert_attr_f(_s) for _s in subst]) else: subst = _insert_attr_f(subst) return m(subst ,attr)
def translate_mouvements_et_milieux(s): """i.f.B:.-+u.f.M:.-O:.-' -> i.B:.-+u.M:.-O:.-'""" subst, attr, mode = s assert isinstance(mode, NullScript) if isinstance(subst, AdditiveScript): subst = AdditiveScript([_remove_attr_f(_s) for _s in subst]) else: subst = _remove_attr_f(subst) return m(subst, attr)
def _insert_f_additive(s): """i.B:.-+u.M:.-O:.-' => i.f.B:.-+u.f.M:.-O:.-'""" subst, attr, mode = s assert isinstance(mode, NullScript) if isinstance(subst, AdditiveScript): subst = AdditiveScript([_insert_attr_f(_s) for _s in subst]) else: subst = _insert_attr_f(subst) return m(subst, attr)
def _promote_and_split(s): """ E:F:.O:M:.t.- => E:.-F:.O:M:.-t.-‘ E:F:.M:M:.l.- => E:.-F:.M:M:.-l.-‘ """ subst, attr, mode = s subst0, subst1, _mode = subst assert isinstance(_mode, NullScript) return m(m(m(subst0)), m(m(subst1), attr), m(mode))
def _promote_and_split(s): """ E:F:.O:M:.t.- => E:.-F:.O:M:.-t.-‘ E:F:.M:M:.l.- => E:.-F:.M:M:.-l.-‘ """ subst, attr, mode = s subst0, subst1, _mode = subst assert isinstance(_mode, NullScript) return m(m(m(subst0)) ,m(m(subst1), attr) ,m(mode))
def migrate_EMOto(scri): " E:M:O:.t.o.- => E:M:.-O:.-t.o.-'" if not set(scri.singular_sequences).issubset( script("E:M:O:.t.o.-").singular_sequences_set): return scri s, a, _m = scri.children ss, sa, sm = s.children return m(m(m(ss, sa)), m(m(sm)), m(a, _m))
def translate_noetic(s): """M:.O:.-O:.O:.-B:.T:.n.-' => s.M:O:.O:O:.-""" subst, attr, mode = s return m(script('s.'), m(subst.children[0].children[0], subst.children[1].children[0]), m(attr.children[0].children[0], attr.children[1].children[0]))
def _insert_attr_f(s): """O:O:.F:.- => O:O:.f.F:.-""" subst, attr, mode = s assert isinstance(mode, NullScript) return m(subst, script('f.'), attr)
def _double_rotate(s): subst, attr, mode = s mode = _rotate_sc(mode) return m(mode, subst, attr)
def _rotate_sc(s): subst, attr, mode = s return m(mode, subst, attr)
def translate_ecosystem_intl_col_tern(s): """O:.M:.-M:.-' => s.o.-k.o.-‘M:O:.-‘,M:.-',_""" subst, attr, mode = s return m(translate_ecosystem_intl_col(subst), m(m(attr)))
def set_bSU_subst(s): subst, attr, mode = s return m(script("b.-S:.U:.-'"), attr, mode)
def _level_3(s): s2, a2, m2 = s s1, a1, m1 = a2 return m(s2, m(s1, m(a1.children[0], m1.children[0])), m2)
def _fix_typo(s): """M:.-O:.-'M:.-wa.e.-'t.x.-s.y.-', => M:.-O:.-'M:.-wa.e.-'t.-x.-s.y.-',""" subst, attr, mode = s return m(subst, attr, script("t.-x.-s.y.-'"))
def _remove_attr_f(s): """O:O:.f.F:.- -> O:O:.F:.- """ subst, attr, mode = s return m(subst, mode)
def translate_tisse_intl_col(s): """O:M:.-O:M:.-we.h.-' => O:M:.-'O:M:.-'s.o.-k.o.-',""" subst, attr, mode = s return m(m(subst), m(attr), script("s.o.-k.o.-'"))
def add_row_(_s): """M:M:.-O:M:.+M:O:.-E:.-+s.y.-' S:E:.+M:M:.-E:.+O:M:.+M:O:.-E:.-+s.y.-'""" s, a, _m = _s.children # return m(m(script("S:E:.") + s.children[0]), m(script("E:.") + a.children[0]), _m) res = [] for ss_m in _m.singular_sequences: for ss_s in s.children[0].singular_sequences: res.append([ m(m(ss_s), m(script("E:.")), ss_m), m(m(ss_s), m(a.children[0]), ss_m) ]) for ss_a in a.children[0].singular_sequences: res.append([ m(m(script("S:E:.")), m(ss_a), ss_m), m(m(s.children[0]), m(ss_a), ss_m) ]) res.append([ m(m(script("S:E:.")), m(script("E:.")), _m), m(m(s.children[0]), m(a.children[0]), _m) ]) return res
def translate_ecosystem_intl_col(s): """O:.M:.- => s.o.-k.o.-'M:O:.-',""" subst, attr, mode = s return m(script("s.o.-k.o.-'"), m(m(m(attr.children[0], subst.children[0]))))