当前位置: 首页>>代码示例>>Python>>正文


Python snowball.EnglishStemmer方法代码示例

本文整理汇总了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() 
开发者ID:GoogleCloudPlatform,项目名称:cloud-vision,代码行数:29,代码来源:textindex.py


注:本文中的nltk.stem.snowball.EnglishStemmer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。