如果要下载布朗语料库的目录,就需要通过brown.categories()来获取分类名,然后通过Path.mkdir()来建立同名目录,接着遍历目录下的文件,对等写入本地目录,代码如下: from nltk.corpus import brown as b #导入布朗语料库,起一个别名b from pathlib import Path for folder in b.categories(): Path(folder).mkdir(e...
from nltk.corpus import brown as b #导入布朗语料库,起一个别名b from pathlib import Path for f...
# 需要导入模块: from nltk.corpus import brown [as 别名]# 或者: from nltk.corpus.brown importtagged_sents[as 别名]defdemo(train_size=100, test_size=100, java_home=None, mallet_home=None):fromnltk.corpusimportbrownimporttextwrap# Define a very simple feature detectordeffd(sentence, index):wo...
defdemo(train_size=100, test_size=100, java_home=None, mallet_home=None):fromnltk.corpusimportbrownimporttextwrap# Define a very simple feature detectordeffd(sentence, index):word = sentence[index]returndict(word=word, suffix=word[-2:], len=len(word))# Let nltk know where java & mallet...
['can','could','may','might','must','will']23cfdist =nltk.ConditionalFreqDist(24(genre, word)25forgenreingenres26forwordinnltk.corpus.brown.words(categories=genre)27ifwordinmodals)28counts ={}29forgenreingenres:30counts[genre] = [cfdist[genre][word]forwordinmodals]31bar_chart(genres, ...
dev Rely on NLTK and Brown corpus Apr 19, 2018 export first commit to Heroku May 10, 2018 randomsentence Rename the major module to SentenceMaker, plan to make a web showcase… May 10, 2018 tests Rename the major module to SentenceMaker, plan to make a web showcase… May 10, 2018 ...
开发者ID:447327642,项目名称:nltk-examples,代码行数:8,代码来源:ch02_ex.py 示例6: brown_diversity ▲点赞 1▼ defbrown_diversity():"""calculate and display lexical diversity score (token/token_type) for each brown corpus category"""cfd = nltk.ConditionalFreqDist((category, word)forcategoryinbr...
end = int(m.group(2))fromnltk.corpusimportmovie_reviewsascorpusreturn[corpus.sents(fileid)forfileidincorpus.fileids()[start:end]] 开发者ID:zjusuyong,项目名称:multi_grain_lda,代码行数:7,代码来源:vocabulary_for_mglda.py 示例5: find_ngrams ...