【发布时间】:2019-05-23 17:59:07
【问题描述】:
背景:
我想使用正则表达式来搜索关键字。但是,我的关键字有多个同义词。例如,关键字positive 可以包含以下我认为等于positive 的词:"+", "pos", "POS", "Positive", "POSITIVE"
我尝试过查看Create a dataframe with NLTK synonyms 和http://www.nltk.org/howto/wordnet.html,但我认为这不是我要找的东西
目标:
1) 为给定关键字创建同义词(例如positive)
2) 使用正则表达式在语料库中搜索关键字(例如positive)
示例:
toy_corpus = 'patient is POS which makes them ideal to treatment '
我认为获得它的步骤如下所示:
1) 定义positive 的同义词
例如positive = ["pos", "POS", "Positive", "POSITIVE", "+"]
2) 使用正则表达式查找关键字POS
问题
我该如何实现这一目标?
【问题讨论】:
标签: regex python-3.x nlp pattern-matching corpus