我需要获取一个文本并删除\n字符,我相信我已经完成了。下一个任务是从不应该出现的单词中删除连字符,而是将连字符保留在应该出现的复合单词中。例如,“encyclo-\npedia”到“encyclopedia”和“long-\nterm”到“long-term”。建议将其与原文进行比较。在
with open('C:\Users\Paul\Desktop\Comp_Ling_Research_1\BROWN_A1_hypenated.txt', 'rU') as myfile:
data=myfile.read().replace('\n', '')
我对该做什么有一个大概的想法,但是NLP对我来说是一个全新的概念。在
第一步是保留一组有效的单词,如果您的断字单词在有效单词集中,则取消断字。Ubuntu在/usr/share/dict/american english上有一个有效单词列表。过于简单的版本可能看起来像:
你需要处理标点符号、大写字母等等,但这就是问题所在。在
相关问题 更多 >
编程相关推荐