Skip to content

Error of seg after add_guaranteed_list #2

Description

@ryanzh-cr
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-27-3b13136d5e16> in <module>()
----> 1 j.seg(sample, pos=True)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jseg/jieba.py in seg(self, text, pos)
    277         gws = sorted(gws, key=lambda x: len(x), reverse=True)  # 長詞優先
    278         for gw in gws:
--> 279             if gw in sentence:
    280                 text = sentence.replace(gw, self._gw[gw])
    281

UnboundLocalError: local variable 'sentence' referenced before assignment

This error happens after adding user define dictionary and then do the seg.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions