簡體   English   中英

NLTK協調不起作用

[英]NLTK Concordance not working

我正在嘗試為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')

我得到以下輸出:

No matches

TIA的幫助

您必須根據一系列字符串創建一個Text實例。 使用nltk.tokenizeTokenizer標記您的句子:

> 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM