(candidate_dict, reference_dict)
| 13 | return nltk.translate.meteor_score.single_meteor_score(word_tokenize(reference), word_tokenize(candidate)) |
| 14 | |
| 15 | def count_stats(candidate_dict, reference_dict): |
| 16 | count_match = [0 for _ in candidate_dict] |
| 17 | count_diff = [0 for _ in candidate_dict] |
| 18 | |
| 19 | for i, k in enumerate(candidate_dict.keys()): |
| 20 | pred_parts = candidate_dict[k] |
| 21 | tgt_parts = reference_dict[k] |
| 22 | |
| 23 | if len(pred_parts) == len(tgt_parts): |
| 24 | count_match[i] = 1 |
| 25 | |
| 26 | count_diff[i] = abs(len(pred_parts) - len(tgt_parts)) |
| 27 | |
| 28 | count_match_score = np.mean(count_match) |
| 29 | count_diff_score = np.mean(count_diff) |
| 30 | |
| 31 | return { |
| 32 | "count_match_score": count_match_score, |
| 33 | "count_diff_score": count_diff_score |
| 34 | } |
| 35 | |
| 36 | def f1_metric(candidate_dict, reference_dict, pairwise_metric): |
| 37 | all_best_p = [0 for _ in candidate_dict] |
nothing calls this directly
no outgoing calls
no test coverage detected