【问题标题】:Convert text blob to sentences将文本 blob 转换为句子
【发布时间】:2021-02-06 00:50:13
【问题描述】:

可以使用 nltk 将文本块转换为句子。

例如:

sen = 'this is a test sentence1 this is a test sentence 2 this is a test'
tokens = nltk.sent_tokenize(sen)

len(tokens)

返回 1,但我希望三个句子的列表长度为 3:

Sentence 1 : this is a test sentence1 
Sentence 2 : this is a test sentence 2 
Sentence 3 : this is a test

【问题讨论】:

  • 英文句子不是用sentence分隔,而是用.?!...

标签: python nltk


【解决方案1】:

由于TextBlob 根据标点符号识别句子,您无法单独使用 nltk 识别句子。你应该看看this。它使用机器学习来尝试识别句子的结尾在哪里并自动填充标点符号。

从那里你可以将你的输出插入到TextBlob,它会分割段落。

【讨论】:

    猜你喜欢
    • 2018-04-15
    • 1970-01-01
    • 2013-01-29
    • 2011-11-05
    • 1970-01-01
    • 2015-02-17
    • 1970-01-01
    • 1970-01-01
    • 2015-03-12
    相关资源
    最近更新 更多