2014年3月25日

摘要: >>> def gender_features(word):... return {'last_letter': word[-1]}>>> gender_features('Shrek'){'last_letter': 'k'}>>> from nltk.corpus import names>>> import random>>> names = ([(name, 'male') for name in names.word 阅读全文

posted @ 2014-03-25 12:01 wintor12 阅读(478) 评论(0) 推荐(0) 编辑

摘要: In particular, the "value" of a structured object such as a list is actually just areferenceto the object.>>> foo = ['Monty', 'Python']>>> bar = foo >>> foo[1] = 'Bodkin' >>> bar['Monty', 'Bodkin']for item in set(s 阅读全文

posted @ 2014-03-25 10:24 wintor12 阅读(135) 评论(0) 推荐(0) 编辑

摘要: >>> from urllib import urlopen>>> url = "http://www.google.com">>> raw = urlopen(url).read()>>> tokens = nltk.word_tokenize(raw)>>> text = nltk.Text(tokens)>>> text.collocations()>>> f = open('document.txt')>>> 阅读全文

posted @ 2014-03-25 03:31 wintor12 阅读(656) 评论(0) 推荐(0) 编辑

摘要: ExampleDescriptionfileids()the files of the corpusfileids([categories])the files of the corpus corresponding to these categoriescategories()the categories of the corpuscategories([fileids])the categories of the corpus corresponding to these filesraw()the raw content of the corpusraw(fileids=[f1,f2,f 阅读全文

posted @ 2014-03-25 03:02 wintor12 阅读(433) 评论(0) 推荐(0) 编辑

摘要: from nltk.book import *>>> type(text1)http://nltk.googlecode.com/svn/trunk/doc/api/nltk.text.Text-class.htmltext1.concordance("monstrous")text1.similar("monstrous")sorted(set(text3))>>> f = FreqDist(text1)>>> fhttp://nltk.googlecode.com/svn/trunk/doc/ap 阅读全文

posted @ 2014-03-25 02:47 wintor12 阅读(439) 评论(0) 推荐(0) 编辑


Copyright © 2024 wintor12
Powered by .NET 9.0 on Kubernetes