本文整理汇总了Python中corpus.Corpus.train_test_split方法的典型用法代码示例。如果您正苦于以下问题:Python Corpus.train_test_split方法的具体用法?Python Corpus.train_test_split怎么用?Python Corpus.train_test_split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corpus.Corpus
的用法示例。
在下文中一共展示了Corpus.train_test_split方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: len
# 需要导入模块: from corpus import Corpus [as 别名]
# 或者: from corpus.Corpus import train_test_split [as 别名]
doc.add(Field("answer", ii['Answer'], t1))
doc.add(Field("qid", ii['Question ID'], t1))
doc.add(Field("category", ii['category'], t1))
doc.add(Field("position", ii['Sentence Position'], t1))
doc.add(Field("question", ii['Question Text'], t2))
doc.add(Field("wiki_plain",
self.wiki_reader.get_text(ii['Answer']), t2))
writer.addDocument(doc)
if __name__ == '__main__':
if len(sys.argv) < 2:
print IndexDocs.__doc__
sys.exit(1)
lucene.initVM(vmargs=['-Djava.awt.headless=true'])
print 'lucene', lucene.VERSION
start = datetime.now()
try:
train_path = sys.argv[1]
train_set = Corpus()
train_set.read(train_path)
train_bench, test_bench = train_set.train_test_split()
base_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
IndexDocs(train_bench, os.path.join(base_dir, INDEX_DIR),
StandardAnalyzer(Version.LUCENE_CURRENT))
end = datetime.now()
print end - start
except Exception, e:
print "Failed: ", e
raise e