# Path: yaya/config.py
# DICT_BIN_EXT = '.ya'
# DICT_BIN_REVERSE_EXT = '.reverse.ya'
# DATA_ROOT = "/home/tony/MyProject/YaYaNLP/data"
# CUSTOM_DICT_NAME = [os.path.join(DATA_ROOT, "dictionary", "custom", f) for f in [
#     u"CustomDictionary.txt",
#     u"上海地名.txt",
#     u"人名词典.txt",
#     u"全国地名大全.txt",
#     u"机构名词典.txt",
#     u"现代汉语补充词库.txt"]]
# CORE_DICT_NAME = os.path.join(DATA_ROOT, "dictionary", "CoreNatureDictionary.txt")
# CORE_BIGRAM_NAME = os.path.join(DATA_ROOT, "dictionary", "CoreNatureDictionary.ngram.txt")
# CORE_TR_PATH = os.path.join(DATA_ROOT, "dictionary", "person", "CoreNatureDictionary.tr.txt")
# CHAR_TYPE_PATH = os.path.join(DATA_ROOT, "dictionary", "other", "CharType.dat.yes")
# PERSON_TR_PATH = os.path.join(DATA_ROOT, "dictionary", "person", "nr.tr.txt")
# PERSON_DICT_NAME = os.path.join(DATA_ROOT, "dictionary", "person", "nr.txt")
# ORG_TR_PATH = os.path.join(DATA_ROOT, "dictionary", "organization", "nt.tr.txt")
# ORG_DICT_NAME = os.path.join(DATA_ROOT, "dictionary", "organization", "nt.txt")
# PLACE_TR_PATH = os.path.join(DATA_ROOT, "dictionary", "place", "ns.tr.txt")
# PLACE_DICT_NAME = os.path.join(DATA_ROOT, "dictionary", "place", "ns.txt")
# TRADITIONAL_CHINESE_DICT_NAME = os.path.join(DATA_ROOT, "dictionary", "tc", "TraditionalChinese.txt")
# class _Config:
# 
# Path: yaya/dictionary/chinese_traditional_dict.py
# class TraditionalChineseDict(ChinseTraditionalBaseDict):
#     def __init__(self):
#         self.trie = DoubleArrayTrie.load(config.TRADITIONAL_CHINESE_DICT_NAME,
#                                          lambda i: i[:i.find(u'=')],
#                                          lambda i: i.split('='))
#         self.trie.get_attr = lambda v: v
# 
#     def convert_traditional_to_simplified(self, text):
#         return self.convert_key_to_value(text)
# 
# class SimplifiedChineseDict(ChinseTraditionalBaseDict):
#     def __init__(self):
#         self.trie = DoubleArrayTrie.load(config.TRADITIONAL_CHINESE_DICT_NAME,
#                                          lambda i: i[i.find(u'=') + 1:],
#                                          lambda i: i.split('=')[::-1],
#                                          dict_bin_ext=config.DICT_BIN_REVERSE_EXT)
#         self.trie.get_attr = lambda v: v
# 
#     def convert_simplified_to_traditional(self, text):
#         return self.convert_key_to_value(text)


from unittest import TestCase
from yaya import config
from yaya.dictionary.chinese_traditional_dict import TraditionalChineseDict, SimplifiedChineseDict
# coding=utf-8


__author__ = 'tony'


class TestTraditionalChineseDict(TestCase):
    def test_convert_simplified_to_traditional(self):
        simplified = TraditionalChineseDict().convert_traditional_to_simplified(u"用筆記簿型電腦寫程式HelloWorld")
        self.assertEqual(simplified, u"用笔记本电脑写程序HelloWorld")

    def test_convert_traditional_to_simplified(self):
        config.Config.debug = True
        traditional = SimplifiedChineseDict().convert_simplified_to_traditional(u"用笔记本电脑写程序HelloWorld")
        self.assertEqual(traditional, u"用筆記簿型電腦寫程式HelloWorld")

    def test_traditional_chinese_dict_search_all_words(self):

# Path: yaya/config.py
# DICT_BIN_EXT = '.ya'
# DICT_BIN_REVERSE_EXT = '.reverse.ya'
# DATA_ROOT = "/home/tony/MyProject/YaYaNLP/data"
# CUSTOM_DICT_NAME = [os.path.join(DATA_ROOT, "dictionary", "custom", f) for f in [
#     u"CustomDictionary.txt",
#     u"上海地名.txt",
#     u"人名词典.txt",
#     u"全国地名大全.txt",
#     u"机构名词典.txt",
#     u"现代汉语补充词库.txt"]]
# CORE_DICT_NAME = os.path.join(DATA_ROOT, "dictionary", "CoreNatureDictionary.txt")
# CORE_BIGRAM_NAME = os.path.join(DATA_ROOT, "dictionary", "CoreNatureDictionary.ngram.txt")
# CORE_TR_PATH = os.path.join(DATA_ROOT, "dictionary", "person", "CoreNatureDictionary.tr.txt")
# CHAR_TYPE_PATH = os.path.join(DATA_ROOT, "dictionary", "other", "CharType.dat.yes")
# PERSON_TR_PATH = os.path.join(DATA_ROOT, "dictionary", "person", "nr.tr.txt")
# PERSON_DICT_NAME = os.path.join(DATA_ROOT, "dictionary", "person", "nr.txt")
# ORG_TR_PATH = os.path.join(DATA_ROOT, "dictionary", "organization", "nt.tr.txt")
# ORG_DICT_NAME = os.path.join(DATA_ROOT, "dictionary", "organization", "nt.txt")
# PLACE_TR_PATH = os.path.join(DATA_ROOT, "dictionary", "place", "ns.tr.txt")
# PLACE_DICT_NAME = os.path.join(DATA_ROOT, "dictionary", "place", "ns.txt")
# TRADITIONAL_CHINESE_DICT_NAME = os.path.join(DATA_ROOT, "dictionary", "tc", "TraditionalChinese.txt")
# class _Config:
# 
# Path: yaya/dictionary/chinese_traditional_dict.py
# class TraditionalChineseDict(ChinseTraditionalBaseDict):
#     def __init__(self):
#         self.trie = DoubleArrayTrie.load(config.TRADITIONAL_CHINESE_DICT_NAME,
#                                          lambda i: i[:i.find(u'=')],
#                                          lambda i: i.split('='))
#         self.trie.get_attr = lambda v: v
# 
#     def convert_traditional_to_simplified(self, text):
#         return self.convert_key_to_value(text)
# 
# class SimplifiedChineseDict(ChinseTraditionalBaseDict):
#     def __init__(self):
#         self.trie = DoubleArrayTrie.load(config.TRADITIONAL_CHINESE_DICT_NAME,
#                                          lambda i: i[i.find(u'=') + 1:],
#                                          lambda i: i.split('=')[::-1],
#                                          dict_bin_ext=config.DICT_BIN_REVERSE_EXT)
#         self.trie.get_attr = lambda v: v
# 
#     def convert_simplified_to_traditional(self, text):
#         return self.convert_key_to_value(text)


# Path: test/test_traditionalChineseDict.py
from unittest import TestCase
from yaya import config
from yaya.dictionary.chinese_traditional_dict import TraditionalChineseDict, SimplifiedChineseDict

# coding=utf-8


__author__ = 'tony'


class TestTraditionalChineseDict(TestCase):
    def test_convert_simplified_to_traditional(self):
        simplified = TraditionalChineseDict().convert_traditional_to_simplified(u"用筆記簿型電腦寫程式HelloWorld")
        self.assertEqual(simplified, u"用笔记本电脑写程序HelloWorld")

    def test_convert_traditional_to_simplified(self):
        config.Config.debug = True
        traditional = SimplifiedChineseDict().convert_simplified_to_traditional(u"用笔记本电脑写程序HelloWorld")
        self.assertEqual(traditional, u"用筆記簿型電腦寫程式HelloWorld")

    def test_traditional_chinese_dict_search_all_words(self):

        searcher = TraditionalChineseDict().trie.search(u"用筆記簿型電腦寫程式HelloWorld")