當前位置: 首頁>>代碼示例>>Python>>正文


Python corpora.TextCorpus方法代碼示例

本文整理匯總了Python中gensim.corpora.TextCorpus方法的典型用法代碼示例。如果您正苦於以下問題:Python corpora.TextCorpus方法的具體用法?Python corpora.TextCorpus怎麽用?Python corpora.TextCorpus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gensim.corpora的用法示例。


在下文中一共展示了corpora.TextCorpus方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_save_load_ability

# 需要導入模塊: from gensim import corpora [as 別名]
# 或者: from gensim.corpora import TextCorpus [as 別名]
def test_save_load_ability(self):
        """
        Make sure we can save and load (un/pickle) TextCorpus objects (as long
        as the underlying input isn't a file-like object; we cannot pickle those).
        """
        # construct corpus from file
        corpusname = datapath('miIslita.cor')
        miislita = CorpusMiislita(corpusname)

        # pickle to disk
        tmpf = get_tmpfile('tc_test.cpickle')
        miislita.save(tmpf)

        miislita2 = CorpusMiislita.load(tmpf)

        self.assertEqual(len(miislita), len(miislita2))
        self.assertEqual(miislita.dictionary.token2id, miislita2.dictionary.token2id) 
開發者ID:largelymfs,項目名稱:topical_word_embeddings,代碼行數:19,代碼來源:test_miislita.py

示例2: test_textcorpus

# 需要導入模塊: from gensim import corpora [as 別名]
# 或者: from gensim.corpora import TextCorpus [as 別名]
def test_textcorpus(self):
        """Make sure TextCorpus can be serialized to disk. """
        # construct corpus from file
        miislita = CorpusMiislita(datapath('head500.noblanks.cor.bz2'))

        # make sure serializing works
        ftmp = get_tmpfile('test_textcorpus.mm')
        corpora.MmCorpus.save_corpus(ftmp, miislita)
        self.assertTrue(os.path.exists(ftmp))

        # make sure deserializing gives the same result
        miislita2 = corpora.MmCorpus(ftmp)
        self.assertEqual(list(miislita), list(miislita2)) 
開發者ID:largelymfs,項目名稱:topical_word_embeddings,代碼行數:15,代碼來源:test_miislita.py

示例3: __init__

# 需要導入模塊: from gensim import corpora [as 別名]
# 或者: from gensim.corpora import TextCorpus [as 別名]
def __init__(self, corpusPath, tokenRegexStr):
		if tokenRegexStr is None:
			tokenRegexStr = GensimTermiteCorpusReader.DEFAULT_TOKEN_REGEX
		self.tokenRegexStr = tokenRegexStr
		self.tokenRegex = re.compile(self.tokenRegexStr)
		self.docIds = []
		corpora.TextCorpus.__init__(self, corpusPath) 
開發者ID:uwdata,項目名稱:termite-data-server,代碼行數:9,代碼來源:GensimLDA.py


注:本文中的gensim.corpora.TextCorpus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。