Exemplo n.º 1
0
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])
Exemplo n.º 2
0
 def p_script_lvl_0(self, p):
     """ script_lvl_0 : PRIMITIVE LAYER0_MARK
                         | REMARKABLE_ADDITION LAYER0_MARK"""
     if p[1] == 'E':
         p[0] = NullScript(layer=0)
     elif p[1] in REMARKABLE_ADDITION:
         p[0] = AdditiveScript(character=p[1])
     else:
         p[0] = MultiplicativeScript(character=p[1])
Exemplo n.º 3
0
    def test_rank2_2d(self):
        term = sc("O:M:.M:M:.-+M:M:.O:M:.-")

        root_table = self.dic.tables.root(term)
        h = self.dic.tables[root_table]
        first_t = self.dic.tables[h.tables[1]]
        term = sc(AdditiveScript([first_t.columns[4],first_t.columns[5],first_t.columns[3]]), factorize=True)

        self.assertEqual(self.dic.tables[term].rank, 2)
Exemplo n.º 4
0
def _rotate_sc_additive(s):
    """
    s.-S:.U:.-'l.-S:.O:.-'n.-S:.U:.-',+M:.-'M:.-'n.-S:.U:.-',  =>
    n.-S:.U:.-'s.-S:.U:.-'l.-S:.O:.-',+n.-S:.U:.-‘M:.-‘M:.-‘,"""

    if isinstance(s, AdditiveScript):
        return AdditiveScript([_rotate_sc(_s) for _s in s])
    else:
        return _rotate_sc(s)
Exemplo n.º 5
0
def translate_formes_visuelles(s):
    """s.u.-'O:M:.-'O:.-',+s.u.-'M:O:.-O:.-'M:.-', => b.-S:.U:.-'O:M:.-'O:.-', + b.-S:.U:.-'M:O:.-O:.-'M:.-',"""
    def set_bSU_subst(s):
        subst, attr, mode = s
        return m(script("b.-S:.U:.-'"), attr, mode)

    if isinstance(s, AdditiveScript):
        return AdditiveScript([set_bSU_subst(i) for i in s.children])
    else:
        return set_bSU_subst(s)
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
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)
Exemplo n.º 8
0
 def _script(self, p):
     if len(p) == 3:
         p[0] = MultiplicativeScript(substance=AdditiveScript(p[1]))
     elif len(p) == 4:
         p[0] = MultiplicativeScript(substance=AdditiveScript(p[1]),
                                     attribute=AdditiveScript(p[2]))
     else:
         p[0] = MultiplicativeScript(substance=AdditiveScript(p[1]),
                                     attribute=AdditiveScript(p[2]),
                                     mode=AdditiveScript(p[3]))
Exemplo n.º 9
0
def pack_factorisation(facto_list):
    """
    :param facto_list: list of script or tuple of factorisation
    :return:
    """
    _sum = []
    for f in facto_list:
        if isinstance(f, Script):
            _sum.append(f)
        else:
            # tuple of factorisation
            _sum.append(
                MultiplicativeScript(children=(pack_factorisation(l_f)
                                               for l_f in f)))

    if len(_sum) == 1:
        return _sum[0]
    else:
        return AdditiveScript(children=_sum)
Exemplo n.º 10
0
    def test_duplicate_addition(self):
        script = AdditiveScript(children=[
            AdditiveScript(children=[
                MultiplicativeScript(character='wa'),
                MultiplicativeScript(character='wo')
            ]),
            AdditiveScript(children=[
                MultiplicativeScript(character='j'),
                AdditiveScript(children=[
                    MultiplicativeScript(character='i'),
                    MultiplicativeScript(attribute=AdditiveScript(
                        character='M'),
                                         substance=AdditiveScript(
                                             character='O'),
                                         mode=MultiplicativeScript(
                                             character='U'))
                ])
            ])
        ])

        self.assertTrue(
            all(isinstance(s, MultiplicativeScript) for s in script.children))
Exemplo n.º 11
0
 def test_reduction_single_add(self):
     script = self.parser.parse("M:.-',M:.-',S:.-'B:.-'n.-S:.U:.-',_")
     self.assertIsInstance(script, MultiplicativeScript)
     script = MultiplicativeScript(substance=AdditiveScript(
         children=[script]))
     self.assertIsInstance(script.children[0], MultiplicativeScript)
Exemplo n.º 12
0
def add(scripts: List[Script]):
    layer = max(s.layer for s in scripts)
    _scripts = [promote(s, layer=layer) for s in scripts]
    return AdditiveScript(children=_scripts)
Exemplo n.º 13
0
 def test_str(self):
     self.assertIsNotNone(MultiplicativeScript(character='A')._str)
     self.assertIsNotNone(AdditiveScript(character='O')._str)
Exemplo n.º 14
0
 def p_additive_script_lvl_0(self, p):
     """ additive_script_lvl_0 : sum_lvl_0"""
     p[0] = AdditiveScript(children=p[1])
Exemplo n.º 15
0
 def _additive(self, p):
     p[0] = AdditiveScript(children=p[1])
Exemplo n.º 16
0
def migrate_merge(s0, s1):
    """migrate just the root
    s.M:O:.O:O:.- O:O:.M:O:.s.-  => O:O:.M:O:.s.- + s.M:O:.O:O:.-"""

    return AdditiveScript(children=[s0, s1])