本文整理匯總了Python中nltk.stem.snowball.EnglishStemmer方法的典型用法代碼示例。如果您正苦於以下問題:Python snowball.EnglishStemmer方法的具體用法?Python snowball.EnglishStemmer怎麽用?Python snowball.EnglishStemmer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nltk.stem.snowball
的用法示例。
在下文中一共展示了snowball.EnglishStemmer方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from nltk.stem import snowball [as 別名]
# 或者: from nltk.stem.snowball import EnglishStemmer [as 別名]
def __init__(self, tokenizer=nltk.word_tokenize,
stemmer=EnglishStemmer(),
stopwords=nltk.corpus.stopwords.words('english')):
"""Create an inverted index.
Args:
tokenizer -- NLTK compatible tokenizer function
stemmer -- NLTK compatible stemmer
stopwords -- list of ignored words
This code assumes that a local redis server is running, and assumes
that you're not already using 'db0' and 'db1' of that installation
for some other purpose. Change these client calls if necessary for
your redis config.
"""
# db 0 holds the token (words) inverted index.
self.redis_token_client = redis.StrictRedis(db=0)
# db 1 holds the filename--> text mapping.
self.redis_docs_client = redis.StrictRedis(db=1)
# Do an initial check on the redis connection. If redis is not up,
# the constructor call will fail.
self.redis_docs_client.ping()
self.tokenizer = tokenizer
self.stemmer = stemmer
self.__unique_id = 0
self.stopwords = set(stopwords) if stopwords else set()