Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Commit

Permalink
change mmseg interface to user the newest version
Browse files Browse the repository at this point in the history
  • Loading branch information
windreamer committed Jul 17, 2012
1 parent e2fb7fe commit 3144815
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pinyin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
__all__ = ["get_pinyin"]

base = os.path.abspath(os.path.dirname(__file__))
mmseg.mmseg.dict_load_words(base + "/data/mmseg/words-pytrans.dic")
mmseg.Dictionary.load_words(base + "/data/mmseg/words-pytrans.dic")
zh_cn = re.compile(ur'^[\u4e00-\u9fa5]+$')

dic_default_py = dict(tuple(l.strip().split(',')) for l in open(
Expand All @@ -30,8 +30,8 @@ def _pinyin(wz):
def get_pinyin(text):
if type(text) == unicode:
text = text.encode("utf-8")
wl = mmseg.seg_txt(text)
pyl = [_pinyin(wz) for wz in wl if zh_cn.match(wz.decode("utf-8"))]
wl = mmseg.Algorithm(text)
pyl = [_pinyin(wz.text) for wz in wl if zh_cn.match(wz.text.decode("utf-8"))]
return list(itertools.chain.from_iterable(pyl))

if __name__ == "__main__":
Expand Down

0 comments on commit 3144815

Please sign in to comment.