0

我学会了使用多语言给 POS 标记印度尼西亚文本。

import polyglot
from polyglot.text import Text, Word

text=Text("Menurut dia, Syahganda, dikenal sebagai penggiat isu-isu pertanahan serta perburuhan.")
print text.pos_tags

但是出现了错误:

Traceback (most recent call last):
  File "polyglot-tagger.py", line 35, in <module>
    arrTag=text.pos_tags
  File "/usr/local/lib/python2.7/dist-packages/polyglot/decorators.py", line 20, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/usr/local/lib/python2.7/dist-packages/polyglot/text.py", line 147, in pos_tags
    for word,t in self.pos_tagger.annotate(self.words):
  File "/usr/local/lib/python2.7/dist-packages/polyglot/decorators.py", line 20, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/usr/local/lib/python2.7/dist-packages/polyglot/text.py", line 100, in pos_tagger
    return get_pos_tagger(lang=self.language.code)
  File "/usr/local/lib/python2.7/dist-packages/polyglot/decorators.py", line 30, in memoizer
    cache[key] = obj(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/polyglot/tag/base.py", line 147, in get_pos_tagger
    return POSTagger(lang=lang)
  File "/usr/local/lib/python2.7/dist-packages/polyglot/tag/base.py", line 126, in __init__
    super(POSTagger, self).__init__(lang=lang)
  File "/usr/local/lib/python2.7/dist-packages/polyglot/tag/base.py", line 40, in __init__
    self.predictor = self._load_network()
  File "/usr/local/lib/python2.7/dist-packages/polyglot/tag/base.py", line 134, in _load_network
    self.model = load_pos_model(lang=self.lang, version=2)
  File "/usr/local/lib/python2.7/dist-packages/polyglot/decorators.py", line 30, in memoizer
    cache[key] = obj(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/polyglot/load.py", line 114, in load_pos_model
    p = locate_resource(src_dir, lang)
  File "/usr/local/lib/python2.7/dist-packages/polyglot/load.py", line 47, in locate_resource
    if downloader.status(package_id) != downloader.INSTALLED:
  File "/usr/local/lib/python2.7/dist-packages/polyglot/downloader.py", line 737, in status
    info = self._info_or_id(info_or_id)
  File "/usr/local/lib/python2.7/dist-packages/polyglot/downloader.py", line 507, in _info_or_id
    return self.info(info_or_id)
  File "/usr/local/lib/python2.7/dist-packages/polyglot/downloader.py", line 933, in info
    raise ValueError('Package %r not found in index' % id)
ValueError: Package u'pos2.ms' not found in index

当我尝试下载 pos2.ms(Part-of-speech Model for Malay) 时,它在model中不存在。我应该怎么办?

**我使用 Ubuntu 和 python 2.7

感谢您之前的帮助

4

1 回答 1

-1

Check the language coverage for Malay http://polyglot.readthedocs.org/en/latest/POS.html#languages-coverage

We are planning to add more languages in the futrue

于 2016-03-08T19:11:16.390 回答