将空格分隔的不完整单词组合成有意义的单词

问题描述 投票:0回答:1

我是 NLP 新手,无法在任何地方找到合适的解决方案。我想将句子中以空格分隔的不完整单词组合成完整单词。

例如下面的不完整单词句子

Sl  ight s t randing at the   root  of the   mes en tery

应更改为

Slight stranding at the root of the mesentery

请帮助我,因为我不知道从哪里开始。

python nlp text-processing
1个回答
0
投票

如果您的主要目标是从本文中提取特定信息,您可以创建一个数据集并训练 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), ...]}

请注意,这是一个非常粗糙的实现。如果您了解文本中的空间分布,则可以实现类似的操作。您必须实施案件的分配。

  • 注释语料库:您很可能不知道分布。在这种情况下,您需要自己创建一个数据集。您可以使用 prodigy 来做到这一点。

训练完模型后,您将能够识别和提取信息,即使其空间是分开的。

© www.soinside.com 2019 - 2024. All rights reserved.