# Path: pypinyin/constants.py
# PHRASES_DICT = {}


from pypinyin.constants import PHRASES_DICT
class Seg(object):
    """正向最大匹配分词

    :type prefix_set: PrefixSet
    :param no_non_phrases: 是否严格按照词语分词，不允许把非词语的词当做词语进行分词
    :type no_non_phrases: bool
    """

    def __init__(self, prefix_set, no_non_phrases=False):
        self._prefix_set = prefix_set
        self._no_non_phrases = no_non_phrases

    def cut(self, text):
        """分词

        :param text: 待分词的文本
        :yield: 单个词语
        """
        remain = text
        while remain:
            matched = ''
            # 一次加一个字的匹配
            for index in range(len(remain)):
                word = remain[:index + 1]
                if word in self._prefix_set:
                    matched = word
                else:
                    # 前面的字符串是个词语
                    if (matched and (
                        (not self._no_non_phrases) or

# Path: pypinyin/constants.py
# PHRASES_DICT = {}


# Path: pypinyin/seg/mmseg.py
from pypinyin.constants import PHRASES_DICT

class Seg(object):
    """正向最大匹配分词

    :type prefix_set: PrefixSet
    :param no_non_phrases: 是否严格按照词语分词，不允许把非词语的词当做词语进行分词
    :type no_non_phrases: bool
    """

    def __init__(self, prefix_set, no_non_phrases=False):
        self._prefix_set = prefix_set
        self._no_non_phrases = no_non_phrases

    def cut(self, text):
        """分词

        :param text: 待分词的文本
        :yield: 单个词语
        """
        remain = text
        while remain:
            matched = ''
            # 一次加一个字的匹配
            for index in range(len(remain)):
                word = remain[:index + 1]
                if word in self._prefix_set:
                    matched = word
                else:
                    # 前面的字符串是个词语
                    if (matched and (
                        (not self._no_non_phrases) or

                        matched in PHRASES_DICT