コード例 #1
0
ファイル: nlpnet-test.py プロジェクト: xuh5156/nlpnet
def prop_conll(verbs, props, sent_length):
    """
    Returns the string representation for a single sentence
    using the CoNLL format for evaluation.
    
    :param verbs: list of tuples (position, token)
    :param props: list of lists with IOBES tags.
    """
    # defaultdict to know what to print in the verbs column
    verb_dict = defaultdict(lambda: '-', verbs)
    lines = []

    for i in range(sent_length):
        verb = verb_dict[i]
        args = [utils.convert_iobes_to_bracket(x[i]) for x in props]
        lines.append('\t'.join([verb] + args))

    # add a line break at the end
    result = '%s\n' % '\n'.join(lines)
    return result.encode('utf-8')
コード例 #2
0
ファイル: nlpnet-test.py プロジェクト: erickrf/nlpnet
def prop_conll(verbs, props, sent_length):
    """
    Returns the string representation for a single sentence
    using the CoNLL format for evaluation.
    
    :param verbs: list of tuples (position, token)
    :param props: list of lists with IOBES tags.
    """
    # defaultdict to know what to print in the verbs column
    verb_dict = defaultdict(lambda: '-', verbs)
    lines = []
    
    for i in range(sent_length):
        verb = verb_dict[i]
        args = [utils.convert_iobes_to_bracket(x[i]) for x in props]
        lines.append('\t'.join([verb] + args))
    
    # add a line break at the end
    result = '%s\n' % '\n'.join(lines) 
    return result.encode('utf-8')