自然语言处理中的缩写



我从事情绪分析。缩写词是自然语言中使用最广泛的缩写词之一。我使用Spellcheker来纠正拼写错误,使用这种方法的问题之一是它将缩写翻译成最接近英语的单词。这会影响情绪检测。有没有任何代码或方法可以根据它们的相邻单词来扩展这些缩写?

hello这里有一个可能有用的示例

import spacy
from scispacy.abbreviation import AbbreviationDetector
nlp=spacy.load("en_core_web_sm")
abbreviation_pipe=AbbreviationDetector(nlp)
text="stackoverflow (SO) is a question and answer site for professional and enth_usiast programmers.SO roxks!"
nlp.add_pipe(abbreviation_pipe)
def replace_acronyms(text):
doc=nlp(txt)
altered_tok=[tok.text for tok in doc]
print(doc._.abbreviations)
for abrv in doc._.abbreviations:
altered_tok[abrv.start]=str(abrv._.long_form)
return(" "join(altered_tok))
replace_acronyms(text)
replace_acronyms("Top executives of Microsoft(MS) and General Motors (GM) met today in NewYord")

最新更新