資源簡介
基于nltk實現對英文短文本的名詞抽取,規則可以自己制定。
代碼片段和文件信息
import?nltk
import?re
import?csv
from?xlwt?import?*
#nltk.download(‘punkt‘)
#對句子進行詞匯分割和正規化,有些情況如aren‘t需要分割為are和n’t;或者i‘m要分割為i和’m。
#tokens_1=nltk.word_tokenize(‘what?your‘)
#print(tokens_1)
import?nltk
lowersetence=‘I?would?not?doubt?to?see?an?upgrade?to?Tropical?Harvey?as?soon?as?we?have?a?closed?low?via?hurricane?hunters...?PTC?09L?5pm?Adv.?should?have?it‘.lower()
text?=?nltk.word_tokenize(lowersetence)
sentence=nltk.pos_tag(text)
#grammar?=?“NP:{}“
grammar?=?r“““
????????????NP:{
- 上一篇:指定步數節點內容的PROCAST仿真結果導出
- 下一篇:KCFpython算法
評論
共有 條評論