本文整理汇总了Python中corpus.Corpus.emails_as_string方法的典型用法代码示例。如果您正苦于以下问题:Python Corpus.emails_as_string方法的具体用法?Python Corpus.emails_as_string怎么用?Python Corpus.emails_as_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corpus.Corpus
的用法示例。
在下文中一共展示了Corpus.emails_as_string方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_corpusContainsOnlyEmails
# 需要导入模块: from corpus import Corpus [as 别名]
# 或者: from corpus.Corpus import emails_as_string [as 别名]
def test_corpusContainsOnlyEmails(self):
"""Test reading the corpus with email messages only."""
corpus = Corpus(CORPUSDIR)
# Exercise the SUT
nitems = 0
for fname, contents in corpus.emails_as_string():
nitems += 1
# Validate the results
self.assertEqual(self.expected[fname], contents,
'The read file contents are not equal to the expected contents.')
self.assertEqual(nitems, NEMAILS,
'The emails_as_string() method did not return the right number of files.')
示例2: test_corpusContainsOnlyEmails
# 需要导入模块: from corpus import Corpus [as 别名]
# 或者: from corpus.Corpus import emails_as_string [as 别名]
def test_corpusContainsOnlyEmails(self):
"""Test reading the corpus with email messages only."""
corpus = Corpus(CORPUS_DIR)
# Exercise the SUT
observed = {}
for fname, contents in corpus.emails_as_string():
observed[fname] = contents
# Verify the results
self.assertEqual(len(self.expected), len(observed),
'The emails_as_string() method did not generate all the corpus files.')
self.assertEqual(self.expected, observed,
'The read file contents are not equal to the expected contents.')
示例3: test_corpusContainsAlsoSpecialFiles
# 需要导入模块: from corpus import Corpus [as 别名]
# 或者: from corpus.Corpus import emails_as_string [as 别名]
def test_corpusContainsAlsoSpecialFiles(self):
"""Test reading the corpus with special files."""
# Add a special file into the corpus dir
save_file_to_corpus_dir(
fname=SPECIAL_FILENAME, contents='fake', dirname=CORPUS_DIR)
corpus = Corpus(CORPUS_DIR)
# Exercise the SUT
observed = {}
for fname, contents in corpus.emails_as_string():
observed[fname] = contents
# Verify the results
self.assertEqual(len(self.expected), len(observed),
'The emails_as_string() method did not generate all the corpus files.')
self.assertEqual(self.expected, observed,
'The read file contents are not equal to the expected contents.')
示例4: test_corpusContainsAlsoSpecialFiles
# 需要导入模块: from corpus import Corpus [as 别名]
# 或者: from corpus.Corpus import emails_as_string [as 别名]
def test_corpusContainsAlsoSpecialFiles(self):
"""Test reading the corpus with special files."""
# Add a special file into the corpus dir
fname = TRUTH_FILENAME
contents = 'fake'
save_file_to_corpus_dir(fname, contents, CORPUSDIR)
# Exercise the SUT
corpus = Corpus(CORPUSDIR)
nitems = 0
for fname, contents in corpus.emails_as_string():
nitems += 1
# Validate results
self.assertEqual(self.expected[fname], contents,
'The read file contents are not equal to the expected contents.')
self.assertEqual(nitems, NEMAILS,
'The emails_as_string() method did not return the right number of files.')