首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NLTK协调不起作用

NLTK协调不起作用
EN

Stack Overflow用户
提问于 2017-02-11 18:02:18
回答 1查看 1.4K关注 0票数 2

我试图为nltk.concordance运行以下代码,但没有给出任何结果。有人能指点我我做错什么了吗?

代码语言:javascript
复制
import nltk.corpus  
from nltk.text import Text 

sent = '''China is an emerging FinTech hotbed thanks to its expanding middle class, rapid digitization and electronic payments adoption. But a new report from Citi found that, while China may be the market to watch for FinTech investments, the U.S. continues to thrive at the top of the B2B FinTech mountain.
According to Digital Disruption — Revisited: What FinTech VC Investments Tells Us About A Changing Industry, Citi expects an influx in venture capital across the FinTech startup scape. But not all markets are created equal. China saw more than half of the world’s FinTech investments in the first nine months of 2016, the bank noted.'''

content = sent.decode('utf-8') #else it throws error
textList = Text(content)
textList.concordance('FinTech')

我得到以下输出:

代码语言:javascript
复制
No matches

蒂娅请你帮忙

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-02-11 18:16:51

必须从字符串序列创建Text实例。使用Tokenizer from nltk.tokenize来标记您的句子:

代码语言:javascript
复制
> t = nltk.tokenize.WhitespaceTokenizer()  # or any other Tokenizer
> c = Text(t.tokenize(content))
> c.concordance(u'FinTech')
Displaying 6 of 6 matches:
                                    FinTech hotbed thanks to its expanding midd
hina may be the market to watch for FinTech investments, the U.S. continues to 
ues to thrive at the top of the B2B FinTech mountain. According to Digital Disr
igital Disruption — Revisited: What FinTech VC Investments Tells Us About A Cha
nflux in venture capital across the FinTech startup scape. But not all markets 
a saw more than half of the world’s FinTech investments in the first nine month
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42179322

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档