def test_rank2_2d(self): term = self.dic.terms[sc("O:M:.M:M:.-+M:M:.O:M:.-")] root_table = term.tables[1] h = root_table term = self.dic.terms[sc([h.columns[4],h.columns[5],h.columns[3]])] self.assertEqual(term.rank, 2)
def test_rank2_2d(self): term = self.dic.terms[sc("O:M:.M:M:.-+M:M:.O:M:.-")] root_table = term.tables[1] h = root_table term = self.dic.terms[sc([h.columns[4], h.columns[5], h.columns[3]])] self.assertEqual(term.rank, 2)
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 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)
def test_compare(self): s1 = self.parser.parse("U:S:+T:S:. + S:S:S:+B:. + U:+S:T:B:.") s2 = self.parser.parse("U:T:S:+B:. + S:S:+T:B:. + U:+S:S:S:.") # print(old_canonical(s1)) # print(old_canonical(s2)) self.assertTrue(s1 > s2) s1 = sc('o.O:M:.-') s2 = sc('E:O:.T:M:.-') self.assertLess(s2, s1) # Lot of test to do : # - testing invalid ieml construction # - testing redondant element in ieml addition # -
def test_rank5_2d(self): term = self.dic.tables[sc("O:M:.M:M:.-+M:M:.O:M:.-")] # Build table for the paradigm of rank 3 (root_table.headers[1][2]) root_table = self.dic.tables[term.tables[1]] root_table = root_table.rows[2] h = self.dic.tables[root_table].rows[0] self.assertEqual(self.dic.tables[h].rank, 5)
def test_rank5_2d(self): term = self.dic.terms[sc("O:M:.M:M:.-+M:M:.O:M:.-")] # Build table for the paradigm of rank 3 (root_table.headers[1][2]) root_table = term.tables[1] root_table = root_table.rows[2] h = root_table.rows[0] self.assertEqual(h.rank, 5)
def test_script_class(self): self.assertEqual(sc('E:').script_class, AUXILIARY_CLASS) self.assertEqual(sc('O:').script_class, VERB_CLASS) self.assertEqual(sc('M:').script_class, NOUN_CLASS) self.assertEqual(sc('E:+O:').script_class, VERB_CLASS) self.assertEqual(sc('O:+M:').script_class, NOUN_CLASS) self.assertEqual(sc('I:').script_class, NOUN_CLASS)
def test_additive_script_layer_0(self): script = sc("I:") tables = script.tables row_headers = [self.parser.parse("I:"), ] tab_headers = [self.parser.parse("I:"),] cells = np.empty(6, dtype=object) cells[0] = self.parser.parse("E:") cells[1] = self.parser.parse("U:") cells[2] = self.parser.parse("A:") cells[3] = self.parser.parse("S:") cells[4] = self.parser.parse("B:") cells[5] = self.parser.parse("T:") row_col_h = list(tables[0].headers.values())[0] self.assertEqual(len(tables), 1, "Correct number of tables generated") self.assertTrue(tables[0].cells.shape == cells.shape, "Table has the correct shape") self.assertEqual(row_col_h[0], row_headers, "Row headers are generated correctly") self.assertEqual(list(tables[0].headers), tab_headers, "Tab headers are generated correctly") self.assertTrue((tables[0].cells == cells).all(), "Cells are generated correctly") self.assertTrue(tables[0].paradigm == script, "Table has correct paradigm")
def test_terms_comparison(self): s_a = sc("S:M:.e.-M:M:.u.-'+B:M:.e.-M:M:.a.-'+T:M:.e.-M:M:.i.-'") s_b = sc("S:M:.e.-M:M:.u.-'") self.assertLess(s_b, s_a)
def test_order_primitive(self): primitives = [sc(p + ':') for p in PRIMITIVES] primitives.sort() res = ''.join([str(p)[0:1] for p in primitives]) self.assertEqual(res, 'EUASBT', msg='Primitives not correctly sorted.')
def test_rank3_2d(self): t = self.dic.terms[sc("c.-'O:M:.-'n.o.-s.o.-',")] self.assertEqual(t.rank, 3)
def test_too_many_singular_sequences(self): with self.assertRaises(TooManySingularSequences): sc('F:F:F:.F:F:F:.-')
def test_rank3_2d(self): t = self.dic.tables[sc("c.-'O:M:.-'n.o.-s.o.-',")] self.assertEqual(t.rank, 3)
def test_paradigm_from_multiple_tables(self): term = self.dic.tables[sc("S:M:.e.-M:M:.u.-wa.e.-'+B:M:.e.-M:M:.a.-wa.e.-'+T:M:.e.-M:M:.i.-wa.e.-'")] self.assertEqual(term.rank, 1)
def test_additive_parent_paradigm(self): term = self.dic.tables[sc("O:M:.M:M:.-")] self.assertEqual(term.rank, 1)
def test_paradigm_from_multiple_tables(self): term = self.dic.terms[sc("S:M:.e.-M:M:.u.-wa.e.-'+B:M:.e.-M:M:.a.-wa.e.-'+T:M:.e.-M:M:.i.-wa.e.-'")] self.assertEqual(term.rank, 1)
def test_additive_parent_paradigm(self): term = self.dic.terms[sc("O:M:.M:M:.-")] self.assertEqual(term.rank, 1)
def test_factorisation(self): s = sc("E:.-T:.n.+f.-+U:.n.+S:+T:S:.-l.-'") s.tables_script