本文整理汇总了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()