# Path: yaya/dictionary/person_dict.py
# class PersonDict:
#     def __init__(self):
#         self.trie = DoubleArrayTrie.load(config.PERSON_DICT_NAME, enum_cls=NR)
#         self.matrix = HMMMatrix.load(config.PERSON_TR_PATH, NR)


import os
import yaya.config
from unittest import TestCase
from yaya.collection.dict import *
from yaya.dictionary.person_dict import PersonDict
        self.assertNotEqual(trie.transition(u"西", p), -1)
        self.assertEqual(trie.transition(u"东", p), -1)

    def test_dat_output(self):
        dat = DoubleArrayTrie()
        dat.build(key=[u"江河湖海"], v=[u"江河湖海 n 1"])
        state = dat.transition(u'江河湖海', 1)
        self.assertGreater(state, -1)
        self.assertIsNotNone(dat.output(state))
        self.assertEqual(dat.output(state), dat.get(u"江河湖海")[1])

        # state = CoreDict().trie.transition(u"大海", 1)
        # self.assertGreater(state, -1)
        # self.assertEqual(CoreDict().trie.output(state), CoreDict().trie.get(u'大海')[1])



class TestAttribute(TestCase):
    def test_total_freq(self):
        text = "测试 n 10 nz 3 p 4"
        attr = Attribute(attr=text.split()[1:])
        self.assertEqual(attr.total_frequency, 17)
        # self.assertEqual(attr.get_nature_frequency('n'), 10)
        self.assertEqual(attr.get_nature_frequency(NATURE.n), 10)
        self.assertEqual(attr.get_nature_frequency(NATURE.nz), 3)
        self.assertEqual(attr.get_nature_frequency(NATURE.p), 4)


class TestAllDict(TestCase):
    def test_PersonDict(self):

# Path: yaya/dictionary/person_dict.py
# class PersonDict:
#     def __init__(self):
#         self.trie = DoubleArrayTrie.load(config.PERSON_DICT_NAME, enum_cls=NR)
#         self.matrix = HMMMatrix.load(config.PERSON_TR_PATH, NR)


# Path: test/test_dict.py
import os
import yaya.config
from unittest import TestCase
from yaya.collection.dict import *
from yaya.dictionary.person_dict import PersonDict

        self.assertNotEqual(trie.transition(u"西", p), -1)
        self.assertEqual(trie.transition(u"东", p), -1)

    def test_dat_output(self):
        dat = DoubleArrayTrie()
        dat.build(key=[u"江河湖海"], v=[u"江河湖海 n 1"])
        state = dat.transition(u'江河湖海', 1)
        self.assertGreater(state, -1)
        self.assertIsNotNone(dat.output(state))
        self.assertEqual(dat.output(state), dat.get(u"江河湖海")[1])

        # state = CoreDict().trie.transition(u"大海", 1)
        # self.assertGreater(state, -1)
        # self.assertEqual(CoreDict().trie.output(state), CoreDict().trie.get(u'大海')[1])



class TestAttribute(TestCase):
    def test_total_freq(self):
        text = "测试 n 10 nz 3 p 4"
        attr = Attribute(attr=text.split()[1:])
        self.assertEqual(attr.total_frequency, 17)
        # self.assertEqual(attr.get_nature_frequency('n'), 10)
        self.assertEqual(attr.get_nature_frequency(NATURE.n), 10)
        self.assertEqual(attr.get_nature_frequency(NATURE.nz), 3)
        self.assertEqual(attr.get_nature_frequency(NATURE.p), 4)


class TestAllDict(TestCase):
    def test_PersonDict(self):

        self.assertNotEqual(PersonDict().trie.exact_match_search(u"籍"), -1)