Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change six.iteritems to six.itervalues #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions deepcrf/util.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import re
import numpy as np

from itertools import chain

import numpy as np
import six

pattern_num = re.compile(r'[0-9]')
Expand Down Expand Up @@ -240,9 +237,9 @@ def conll_eval(gold_predict_pairs, flag=True, tag_class=None):
f_measure = (2 * recall * precision) / (sum_recall_precision)
evals[tag_name] = [precision * 100.0, recall * 100.0, f_measure * 100.0]

correct_cnt = sum([ev['correct_cnt'] for tag_name, ev in six.iteritems(cnt_phrases_dict)])
gold_cnt = sum([ev['gold_cnt'] for tag_name, ev in six.iteritems(cnt_phrases_dict)])
predict_cnt = sum([ev['predict_cnt'] for tag_name, ev in six.iteritems(cnt_phrases_dict)])
correct_cnt = sum([ev['correct_cnt'] for ev in six.itervalues(cnt_phrases_dict)])
gold_cnt = sum([ev['gold_cnt'] for ev in six.itervalues(cnt_phrases_dict)])
predict_cnt = sum([ev['predict_cnt'] for ev in six.itervalues(cnt_phrases_dict)])

recall = correct_cnt / float(gold_cnt) if gold_cnt else 0.0
precision = correct_cnt / float(predict_cnt) if predict_cnt else 0.0
Expand Down