当前位置: 首页>>代码示例>>Python>>正文


Python Decoder.decode_for_predict方法代码示例

本文整理汇总了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.")
开发者ID:memeda,项目名称:cws,代码行数:20,代码来源:segmentor.py

示例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
开发者ID:memeda,项目名称:cws,代码行数:23,代码来源:segmentor.py


注:本文中的decoder.Decoder.decode_for_predict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。