我是 NLP 新手,无法在任何地方找到合适的解决方案。我想将句子中以空格分隔的不完整单词组合成完整单词。
例如下面的不完整单词句子
Sl ight s t randing at the root of the mes en tery
应更改为
Slight stranding at the root of the mesentery
请帮助我,因为我不知道从哪里开始。
如果您的主要目标是从本文中提取特定信息,您可以创建一个数据集并训练 spaCy NER 模型来执行相同的操作。
text = "The quick brown fox jumps over the lazy dog"
def introduce_spaces(text):
for i in enumerate(text, p=0.1):
if random.random() > p:
text.insert(i, " ")
return text
>>> {"text": "The qu ick b row n fo x jumps over the lazy dog", "entities":[("COLOR", 10, 7), ("ANIMAL", 12, 15), ...]}
请注意,这是一个非常粗糙的实现。如果您了解文本中的空间分布,则可以实现类似的操作。您必须实施案件的分配。
训练完模型后,您将能够识别和提取信息,即使其空间是分开的。