如何为分词器指定额外的分词?
How to specify additional tokens for tokenizator?
我想用 gensim.utils.tokenize()
标记文本。我想添加一些会被识别为单个标记的短语,例如:'New York', 'Long Island'
。
gensim 可以吗?如果没有,可以使用哪些其他库?
我找到了 nltk
的解决方案:
tokenizer = nltk.tokenize.mwe.MWETokenizer([('hors', "d'oeuvre")], separator=' ')
tokenizer.tokenize("An hors d'oeuvre tonight, sir?".split())
['An', "hors d'oeuvre", 'tonight,', 'sir?']
我想用 gensim.utils.tokenize()
标记文本。我想添加一些会被识别为单个标记的短语,例如:'New York', 'Long Island'
。
gensim 可以吗?如果没有,可以使用哪些其他库?
我找到了 nltk
的解决方案:
tokenizer = nltk.tokenize.mwe.MWETokenizer([('hors', "d'oeuvre")], separator=' ')
tokenizer.tokenize("An hors d'oeuvre tonight, sir?".split())
['An', "hors d'oeuvre", 'tonight,', 'sir?']