當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。