Blame view

fsabuilder/morfeuszbuilder/segrules/test/parserTest.py 997 Bytes
Michał Lenart authored
1
2
3
4
5
6
7
8
9
'''
Created on 18 lut 2014

@author: mlenart
'''
import unittest
import os
from morfeuszbuilder.segrules import rulesParser
from morfeuszbuilder.tagset import tagset
Michał Lenart authored
10
from morfeuszbuilder.fsa import visualizer, serializer
Michał Lenart authored
11
12

class Test(unittest.TestCase):
Michał Lenart authored
13
14
15
16
17
18
19
20
21
22
23
24
25
26

    def testParser(self):
        print 'do test'
        t = tagset.Tagset(os.path.join(os.path.dirname(__file__), 'polimorf.tagset'))
        parser = rulesParser.RulesParser(t)
        rulesManager = parser.parse(os.path.join(os.path.dirname(__file__), 'segmenty.dat'))
        fsa = rulesManager.getDFA({'aggl': 'permissive', 'praet': 'split'})
        for s in fsa.dfs():
            s.debug()
        print 'states:', len(list(fsa.dfs()))
        print 'transitions:', fsa.getTransitionsNum()
        visualizer.Visualizer().visualize(fsa, charLabels=False)
        print 'size:', len(serializer.SimpleSerializer(fsa).fsa2bytearray(bytearray()))
        print 'done'
Michał Lenart authored
27
28
29
30

if __name__ == "__main__":
    unittest.main()
#     testParser()