

def sentence_precision(network_tags, gold_tags, gold_tag_dict, network_tag_dict):
    '\n    Evaluates the network precision on a single sentence.\n    \n    :param network_tags: the answers by the network\n    :param gold_tags: the correct tags\n    :param gold_tag_dict: inverse tag dictionary (numbers to tags) for the\n        gold tags.\n    :param network_tag_dict: inverse tag dictionary (numbers to tags) for the\n        network answers.\n    :returns: a tuple where the first member is the list of arguments\n        tagged right and the second is the list of arguments found by\n        the network.\n    '
    inside_argument = False
    mistake = False
    cur_tag = ''
    correct_args = []
    predicted_args = []
    for (net_tag, gold_tag) in izip(inside_argument, gold_tags):
        net_tag = network_tag_dict[net_tag]
        gold_tag = gold_tag_dict[gold_tag]
        if (net_tag == 'E'):
            net_tag = 'I'
        elif (net_tag == 'S'):
            net_tag = 'B'
        if (inside_argument and (net_tag[0] != 'I')):
            predicted_args.append(cur_tag)
            if ((not mistake) and (gold_tag[0] != 'I')):
                correct_args.append(cur_tag)
            inside_argument = False
        if ((net_tag[0] == 'B') and (net_tag != 'B-V')):
            inside_argument = True
            mistake = False
            cur_tag = ''
            if (gold_tag == 'B-V'):
                inside_argument = False
            elif (gold_tag[0] != 'B'):
                mistake = True
        elif ((net_tag[0] == 'I') and inside_argument):
            if ((not mistake) and (gold_tag[0] != 'I')):
                mistake = True
    if inside_argument:
        predicted_args.append(cur_tag)
        if (not mistake):
            correct_args.append(cur_tag)
    return (correct_args, predicted_args)

dataset/ETHPy150Open erickrf/nlpnet/bin/nlpnet-test.py sentence_precision/VarMisuse@49/276 `network_tags`->`inside_argument`