【问题标题】:How to parse a string to words?如何将字符串解析为单词?
【发布时间】:2015-03-11 17:51:29
【问题描述】:

如何解析文本如

“文本分割是将书面文本分割成有意义的单元的过程,例如单词、句子或主题。--Mr.Wikipedia”

Words=["Text","segmentation","is","the","process","of","dividing","written","text","into","有意义的","单位","例如","as","words","sentences","or","topics","Mr.Wikipedia]"

我已经尝试过替换技术,但最终得到了几个连续的空格。

【问题讨论】:

  • 哇,我一定累了,我把 nlp 读成 php 并在意识到它不是 php 之前添加了一个完整的答案
  • 以任何方式发布答案

标签: string algorithm nlp


【解决方案1】:

如果您使用 Python 编写代码,请使用 NLTK(请参阅 NLTK book

import nltk
sentence = "Text segmentation is the process of dividing written text into meaningful units, such as words, sentences, or topics. --Mr.Wikipedia"
words = nltk.word_tokenize(sentence)

对于 Java,请尝试 OpenNLP tokenizer

【讨论】:

    猜你喜欢
    • 2011-01-19
    • 1970-01-01
    • 2015-02-16
    • 1970-01-01
    • 2011-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多