本文整理汇总了Python中decoder.Decoder.decode_for_predict方法的典型用法代码示例。如果您正苦于以下问题:Python Decoder.decode_for_predict方法的具体用法?Python Decoder.decode_for_predict怎么用?Python Decoder.decode_for_predict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类decoder.Decoder
的用法示例。
在下文中一共展示了Decoder.decode_for_predict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _predict_processing
# 需要导入模块: from decoder import Decoder [as 别名]
# 或者: from decoder.Decoder import decode_for_predict [as 别名]
def _predict_processing(self , predict_path , output_path) :
if isinstance(output_path , file) :
output_f = output_path
else :
if output_path == "stdout" :
output_f = sys.stdout
else :
output_f = open(output_path , "w")
logging.info("set output %s " %(output_f.name))
logging.info("reading instance from %s . predicting ." %(predict_path))
for instance , separator_data in DatasetHandler.read_predict_data(predict_path) :
self.constrain.set_constrain_data(separator_data)
predict_tags = Decoder.decode_for_predict(self.extractor , self.model , self.constrain , instance)
segmented_line = self._processing_unigrams_and_tags2segmented_line(instance,predict_tags)
output_f.write("%s" %( "".join([segmented_line , os.linesep]) ) )
if output_f is not sys.stdout :
output_f.close()
logging.info("predicting done.")
示例2: _4training_evaluate_processing
# 需要导入模块: from decoder import Decoder [as 别名]
# 或者: from decoder.Decoder import decode_for_predict [as 别名]
def _4training_evaluate_processing(self , dev_path) :
nr_processing_right = 0
nr_gold = 0
nr_processing = 0
for instance in DatasetHandler.read_dev_data(dev_path) :
unigrams , gold_tags = Segmentor._processing_one_segmented_WSAtom_instance2unigrams_and_tags(instance)
predict_tags = Decoder.decode_for_predict(self.extractor , self.model , self.constrain , unigrams)
gold_coor_seq = self.__innerfunc_4evaluate_generate_word_coordinate_sequence_from_tags(gold_tags)
predict_coor_seq = self.__innerfunc_4evaluate_generate_word_coordinate_sequence_from_tags(predict_tags)
cur_nr_gold , cur_nr_processing , cur_nr_processing_right = (
self.__innerfunc_4evaluate_get_nr_gold_and_processing_and_processing_right(gold_coor_seq , predict_coor_seq)
)
nr_gold += cur_nr_gold
nr_processing += cur_nr_processing
nr_processing_right += cur_nr_processing_right
p , r , f = self.__innerfunc_4evaluate_calculate_prf(nr_gold , nr_processing , nr_processing_right)
print >>sys.stderr , ("Eval result :\np : %.2f%% r : %.2f%% f : %.2f%%\n"
"total word num : %d total predict word num : %d predict right num : %d ")%(
p * 100 , r * 100, f * 100 , nr_gold , nr_processing , nr_processing_right
)
return f