【问题标题】:How to specify additional tokens for tokenizator?如何为标记器指定额外的标记?
【发布时间】:2019-05-24 12:30:44
【问题描述】:

我想用gensim.utils.tokenize() 标记文本。我想添加一些可以被识别为单个标记的短语,例如:'New York', 'Long Island'

gensim 可以吗?如果没有,还有哪些库可以使用?

【问题讨论】:

    标签: python nlp token tokenize gensim


    【解决方案1】:

    我找到了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?']
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-13
      相关资源
      最近更新 更多