我正在做一个基本的文本挖掘应用程序,我需要找到一个确定的单词(关键字)并捕获这个单词后面的n个单词。例如,在本文中,我想抓住关键字POPULATION后面的3个单词:
补充表格由59个详细表格组成,这些表格以2016年1年微观数据为基础,针对人口超过20000人的地区。这些补充估计数可通过美国FactFinder和人口普查局的应用程序编程接口获得,其地理摘要级别与美国社区调查中的相同。
下一步是拆分字符串并找到数字,但这是我已经解决的问题。我尝试过不同的方法(regex等),但没有成功。我该怎么做?你知道吗
Tags:
你有两种方法来解决它
1使用解霸
jieba.cut
它能把你的句子拼成文字
只要找到“人口”然后找到下三个词
2使用溢出
将文本拆分为单词,找到关键字的索引,抓住下一个索引处的单词:
如果您希望将三个单词的列表
wanted_words
重新编成一个字符串,请使用你可以使用nltk库。你知道吗
相关问题 更多 >
编程相关推荐