在没有标点符号的段落中执行句子分割?

8
我有一些格式不良的文字,缺少许多标点符号。我想知道是否有任何方法可以在缺少句号、分号、大写等情况下将文本分段成句子。

例如,考虑以下段落:"the lion is called the king of the forest it has a majestic appearance it eats flesh it can run very fast the roar of the lion is very famous"

此文本应被分割为不同的句子:
  • the lion is called the king of the forest
  • it has a majestic appearance
  • it eats flesh
  • it can run very fast
  • the roar of the lion is very famous
这个能做到吗?还是不可能实现?欢迎提出任何建议!

1
你可以训练一个序列分类器。获取大量的训练材料非常容易:使用任何包含标点符号的语料库,进行句子拆分,去除标点符号 - voilà。 - lenz
@lenz,用Python创建序列分类器的最简单方法是什么?你能在NLTK中做到这一点吗? - user6732360
是的,NLTK有一个分类模块。通常,初学者会通过朴素贝叶斯分类器来介绍监督式机器学习,这个概念相当简单易懂。 - lenz
@lenz 这个分类器的输入和输出会是什么? - user6732360
最近我发布了一个回答,可以看一下这个链接 - lenz
1个回答

2
你可以尝试使用这里提供的以下Python实现。
import torch

model, example_texts, languages, punct, apply_te = torch.hub.load(repo_or_dir='snakers4/silero-models', model='silero_te')

#your text goes here. I imagine it is contained in some list

input_text = input('Enter input text\n') 
apply_te(input_text, lan='en')

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接