【发布时间】:2015-12-17 02:19:58
【问题描述】:
从集合导入 OrderedDict 导入json
def read_classification_from_file(dict_file1,dict_file2): 使用 open(dict_file1,'r') 作为 f: dict1 = json.load(f, object_pairs_hook=OrderedDict) 使用 open(dict_file2,'r') 作为 f: data2 = json.load(f, object_pairs_hook=OrderedDict)
# Creates list of lists pairing each value in
# dict1 with each value in dict2
return [[value1,value2]
for value1 in dict1.values()
for value2 in dict2.values()]
【问题讨论】:
-
你能澄清你的帖子吗?完全不清楚你想做什么。
-
第一个函数在您提供 truth_dict 和 pred_dict 字典时起作用,所以我想通过在 read_classification_from_file() 中打开 example1.txt 和 example2.txt 以不同的方式使用:然后我想要 compute_confusion_matrix(truth_dict , pred_dict, pos_tag=True, neg_tag=False): 在 read_classification_from_file() 中使用返回的字典:
-
或者如果我可以在compute_confusion_matrix中打开两个文件(truth_dict, pred_dict, pos_tag=True, neg_tag=False):如果可能的话会更好
标签: python