# 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/const.py
# DOUBLE_MAX = 1.7976931348623157e+308
# TAG_PLACE = u"未##地"
# TAG_BIGIN = u"始##始"
# TAG_OTHER = u"未##它"
# TAG_GROUP = u"未##团"
# TAG_NUMBER = u"未##数"
# TAG_QUANTIFIER = u"未##量"
# TAG_PROPER = u"未##专"
# TAG_TIME = u"未##时"
# TAG_CLUSTER = u"未##串"
# TAG_END = u"末##末"
# TAG_PEOPLE = u"未##人"
# MAX_FREQUENCY = 25146057
# SMOOTHING_FACTOR = 1.0 / MAX_FREQUENCY + 0.00001
# SMOOTHING_PARAM = 0.1
# 
# Path: yaya/utility/bytearray.py
# class ByteArray:
#     @staticmethod
#     def load_from_file(filename):
#         f = FileIO(filename, 'rb')
#         data = f.readall()
#         return ByteArray(data)
# 
#     def __init__(self, data):
#         self.data = data
#         self.offset = 0
# 
#     def has_more(self):
#         return self.offset < len(self.data)
# 
#     def next_ushort(self):
#         data = struct.unpack_from('!h', self.data, self.offset)
#         self.offset += 2
#         return data[0]
# 
#     def next_uchar(self):
#         data = struct.unpack_from('!B', self.data, self.offset)
#         self.offset += 1
#         return data[0]


import time
        import sys
from yaya import config
from yaya.const import logger
from yaya.utility.bytearray import ByteArray
# coding=utf-8

__author__ = 'tony'

CT_SINGLE = 5  # 单字节
CT_DELIMITER = CT_SINGLE + 1  # 分隔符"!,.?()[]{}+=
CT_CHINESE = CT_SINGLE + 2  # 中文字符
CT_LETTER = CT_SINGLE + 3  # 字母
CT_NUM = CT_SINGLE + 4  # 数字
CT_INDEX = CT_SINGLE + 5  # 序号
CT_OTHER = CT_SINGLE + 12  # 其他

char_type = [[]] * 65536


def __init__():
    logger.info("字符类型对应表开始加载 %s", config.CHAR_TYPE_PATH)
    start = time.time()
    byte_array = ByteArray.load_from_file(config.CHAR_TYPE_PATH)
    if byte_array is None:

# 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/const.py
# DOUBLE_MAX = 1.7976931348623157e+308
# TAG_PLACE = u"未##地"
# TAG_BIGIN = u"始##始"
# TAG_OTHER = u"未##它"
# TAG_GROUP = u"未##团"
# TAG_NUMBER = u"未##数"
# TAG_QUANTIFIER = u"未##量"
# TAG_PROPER = u"未##专"
# TAG_TIME = u"未##时"
# TAG_CLUSTER = u"未##串"
# TAG_END = u"末##末"
# TAG_PEOPLE = u"未##人"
# MAX_FREQUENCY = 25146057
# SMOOTHING_FACTOR = 1.0 / MAX_FREQUENCY + 0.00001
# SMOOTHING_PARAM = 0.1
# 
# Path: yaya/utility/bytearray.py
# class ByteArray:
#     @staticmethod
#     def load_from_file(filename):
#         f = FileIO(filename, 'rb')
#         data = f.readall()
#         return ByteArray(data)
# 
#     def __init__(self, data):
#         self.data = data
#         self.offset = 0
# 
#     def has_more(self):
#         return self.offset < len(self.data)
# 
#     def next_ushort(self):
#         data = struct.unpack_from('!h', self.data, self.offset)
#         self.offset += 2
#         return data[0]
# 
#     def next_uchar(self):
#         data = struct.unpack_from('!B', self.data, self.offset)
#         self.offset += 1
#         return data[0]


# Path: yaya/utility/chartype.py
import time
        import sys
from yaya import config
from yaya.const import logger
from yaya.utility.bytearray import ByteArray

# coding=utf-8

__author__ = 'tony'

CT_SINGLE = 5  # 单字节
CT_DELIMITER = CT_SINGLE + 1  # 分隔符"!,.?()[]{}+=
CT_CHINESE = CT_SINGLE + 2  # 中文字符
CT_LETTER = CT_SINGLE + 3  # 字母
CT_NUM = CT_SINGLE + 4  # 数字
CT_INDEX = CT_SINGLE + 5  # 序号
CT_OTHER = CT_SINGLE + 12  # 其他

char_type = [[]] * 65536


def __init__():
    logger.info("字符类型对应表开始加载 %s", config.CHAR_TYPE_PATH)
    start = time.time()
    byte_array = ByteArray.load_from_file(config.CHAR_TYPE_PATH)
    if byte_array is None:

        logger.error("字符类型对应表加载失败：" + config.CHAR_TYPE_PATH)