本文整理汇总了Python中Pipeline.get_entailment方法的典型用法代码示例。如果您正苦于以下问题:Python Pipeline.get_entailment方法的具体用法?Python Pipeline.get_entailment怎么用?Python Pipeline.get_entailment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pipeline
的用法示例。
在下文中一共展示了Pipeline.get_entailment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runTest
# 需要导入模块: import Pipeline [as 别名]
# 或者: from Pipeline import get_entailment [as 别名]
def runTest(self):
alignments, alignments_score = self.aligner.align(
self.p_str_tokens, self.h_str_tokens, self.weights)
#print 'Alignments:\n'
for a in alignments:
print a
prediction = Pipeline.get_entailment(
self.p_str_tokens, self.h, alignments)
logging.info('Target: %s' % self.target)
logging.info('Prediction: %s' % prediction)
self.assertEqual(prediction, self.target)
示例2: runTest
# 需要导入模块: import Pipeline [as 别名]
# 或者: from Pipeline import get_entailment [as 别名]
def runTest(self):
start = time()
alignments, alignments_score = self.aligner.align(
self.p_str_tokens, self.h_str_tokens, self.weights)
print "Alignment %s" % (time() - start)
#print 'Alignments:\n'
for a in alignments:
print a
prediction = Pipeline.get_entailment(
self.p_str_tokens, self.h, alignments)
logging.info('Target: %s' % self.target)
logging.info('Prediction: %s' % prediction)
print 'Answer: %s' % self.answer[prediction]
self.assertEqual(prediction, self.target)
示例3: word_tokenize
# 需要导入模块: import Pipeline [as 别名]
# 或者: from Pipeline import get_entailment [as 别名]
pair_id = pair.attrib['id']
p = pair.find('t').text
h = pair.find('h').text
print p.encode('utf-8', 'replace')
print h.encode('utf-8', 'replace')
print target, '\n'
p_str_tokens = word_tokenize(p)
h_str_tokens = word_tokenize(h)
weights = 'default'
alignments, alignments_score = aligner.align(
p_str_tokens, h_str_tokens, weights)
#print 'Alignments:\n'
#for a in alignments:
#print a
try:
prediction = Pipeline.get_entailment(p_str_tokens, h, alignments)
print 'target:', target
print 'prediction:', answer[prediction]
if target != answer[prediction]:
print 'Pair id %s incorrect' % pair_id
incorrect += 1
else:
print 'Pair id %s CORRECT' % pair_id
correct += 1
total += 1
except:
error += 1
total += 1
pass
print 'Total:', total