如果您查看您的 nltk_data 文件夹,您会发现 wordnet 和其他所有 NLTK 语料库一样只是一堆纯文本文件。因此,必须有一种方法来格式化印地语 wordnet,就像使用 NLTK 一样来使用这些功能。以下是正在读取这些文件的 nltk.corpus.reader.wordnet 对象的摘录:
#: A list of file identifiers for all the fileids used by this
#: corpus reader.
_FILES = ('cntlist.rev', 'lexnames', 'index.sense',
'index.adj', 'index.adv', 'index.noun', 'index.verb',
'data.adj', 'data.adv', 'data.noun', 'data.verb',
'adj.exc', 'adv.exc', 'noun.exc', 'verb.exc', )
def __init__(self, root):
"""
Construct a new wordnet corpus reader, with the given root
directory.
"""
super(WordNetCorpusReader, self).__init__(root, self._FILES,
encoding=self._ENCODING)
我想您并不真的需要生成所有这些文件,但更重要的是必须使用“index.sense”文件进行词义消歧。这不是由 NLTK 生成的,但必须在此之前进行预处理,或者必须以以下格式随印地语 wordnet 一起提供 - http://wordnet.princeton.edu/wordnet/man/senseidx.5WN.html。
完成所有步骤后,我只需转到 ../nltk/corpus/reader/wordnet.py 并创建一个副本,您可以在其中更改根目录和文件名,也许还有一些其他依赖项,但仍然使用功能或更改现有课程中所需的内容(不推荐)。
附:我在谷歌上搜索了一下,得到了http://www.cs.utexas.edu/~rashish/cs365ppt.pdf 的链接,它引用了有关该主题的许多其他来源。