【问题标题】:NLP : Error/Unknown/misspelled text Detection model of a patient's medical text fileNLP : 患者医疗文本文件的错误/未知/拼写错误文本检测模型
【发布时间】:2020-04-03 14:12:20
【问题描述】:

我从互联网上获得的患者病历文本文件很少,我想识别/查找质量差的文件(拼写错误的单词/单词之间的特殊字符/错误的单词)和质量好的文件(干净text)。我想使用文本挖掘/NLP 构建错误检测模型。

1)有人可以帮助我了解特征提取和模型选择的方法和解决方案。 2)是否有医疗记录的医疗语料库来识别拼写错误/错误的单词。

【问题讨论】:

    标签: nlp data-science text-mining medical


    【解决方案1】:

    如果您的目标是简单地纠正这些拼写错误的单词以提高您想要执行的任何下游任务的性能,那么我可以建议一种对我来说效果很好的简单方法。

    1. 首先标记您的文本(我推荐 scispacy 用于医学文本)
    2. 仅通过从您的语料库中的所有单词构建的每个唯一单词的计数来识别可能的“质量差”单词,例如所有出现
    3. 将在您的语料库中出现 > 3 次的单词(我们假设这些单词都拼写正确)添加到常规英语词典中。如果你的语料库很大,这对于捕获医学术语来说是完全足够的。否则使用医学词典,例如UMLS 或 https://github.com/glutanimate/wordlist-medicalterms-en 添加常规词典中没有的医学词汇
    4. 通过使用 Levenshtein 距离算法并与我们的字典进行比较,使用 pyspellchecker 来识别拼写错误。
    5. pyspellchecker 认为的错误替换错别字。

    一个基本的例子:

    import spacy
    import scispacy
    from collections import Counter
    from spellchecker import SpellChecker
    
    nlp = spacy.load('en_core_sci_md') # sciSpaCy
    word_freq = Counter()
    
    for doc in corpus:
        tokens = nlp.tokenizer(doc)
        tokenised_text = ""
    
        for token in tokens:
            tokenised_text = tokenised_text + token.text + " "
    
        word_freq.update(tokenised_text.split())
    
    infreq_words = [word for word in word_freq.keys() if word_freq[word] <= 3 and word[0].isdigit() == False]
    freq_words = [word for word in word_freq.keys() if word_freq[word] > 3]
    add_to_dictionary = " ".join(freq_words)
    f=open("medical_dict.txt", "w+")
    f.write(add_to_dictionary)
    f.close()
    
    spell = SpellChecker()
    spell.distance = 1  # set the distance parameter to just 1 edit away - much quicker
    spell.word_frequency.load_text_file('medical_dict.txt')
    
    misspelled = spell.unknown(infreq_words)
    misspell_dict = {}
    for i, word in enumerate(misspelled):
        if (word != spell.correction(word)):
            misspell_dict[word] = spell.correction(word)
    
    print(list(misspell_dict.items())[:10])
    

    我还建议使用正则表达式来修复任何其他可以系统纠正的“质量差”的词。

    【讨论】:

    • 感谢 amin 的回复:) 我有几个问题,在我提出问题之前,我的目标实际上是建立一个强大的错误检测模型,可以识别患者的病历页面是否属于质量差(错误的术语、拼写错误的单词、特殊字符如 AAAAA、btfhj${>*£..等,而不是拼写校正模型
    • 我的问题是,我相信我们不能简单地通过假设所有字数小于 3 来识别质量差的单词(例如:stamach 拼写错误应该是胃)而是有任何可能推导出特征并建立一个模型,如 svm、随机森林......等来分类或预测页面是干净的单词好还是拼写错误的坏,spl.chars 单词......等
    • 不用担心 Mukesh,您的文件是否有标签说明哪些文件质量不好?如果他们这样做,请像 Akshat 建议的那样尝试 BioBERT。否则,您需要尝试无监督的方法。例如。类似towardsdatascience.com/…
    【解决方案2】:

    你可以做 biobert 来做上下文拼写检查,

    链接:https://github.com/dmis-lab/biobert

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多