我正在尝试为 nltk.concordance 运行以下代码,但它没有给出任何结果。有人可以指导我我做错了什么吗?
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')
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
No matches
Run Code Online (Sandbox Code Playgroud)
TIA 寻求帮助
您必须Text从一系列字符串创建一个实例。使用Tokenizerfromnltk.tokenize来标记你的句子:
> 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
Run Code Online (Sandbox Code Playgroud)