How to use the pyknp.knp.blist.BList function in pyknp

To help you get started, we’ve selected a few pyknp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ku-nlp / pyknp / pyknp / evaluate / dep.py View on Github external
def dependency(g, s, level=2, checkType=False, ignoreStart=True):
    assert isinstance(g, BList)
    assert isinstance(s, BList)
    assert isinstance(level, int)
    assert isinstance(checkType, bool)
    assert isinstance(ignoreStart, bool)
    if level != 1 and level != 2:
        raise KeyError

    spans = set([])
    g_spans = [g.get_tag_span(t.tag_id) for t in g.tag_list()]
    s_spans = [s.get_tag_span(t.tag_id) for t in s.tag_list()]
    if ignoreStart:
        for i, g_span in enumerate(g_spans):
            g_spans[i] = g_span[1]
        for i, s_span in enumerate(s_spans):
            s_spans[i] = s_span[1]
    spans = spans.union(set(g_spans))
    spans = spans.union(set(s_spans))
github ku-nlp / pyknp / pyknp / evaluate / phrase.py View on Github external
def phrase(g, s, level=0):
    assert isinstance(g, BList)
    assert isinstance(s, BList)
    assert isinstance(level, int)
    if level != 0:
        raise KeyError

    spans = set([])
    g_spans = [g.get_tag_span(t.tag_id) for t in g.tag_list()]
    s_spans = [s.get_tag_span(t.tag_id) for t in s.tag_list()]
    spans = spans.union(set(g_spans))
    spans = spans.union(set(s_spans))

    scorer = Scorer()
    for span in spans:
        try:
            gold_pid = g_spans.index(span)
        except ValueError:
github ku-nlp / pyknp / pyknp / evaluate / phrase.py View on Github external
def phrase(g, s, level=0):
    assert isinstance(g, BList)
    assert isinstance(s, BList)
    assert isinstance(level, int)
    if level != 0:
        raise KeyError

    spans = set([])
    g_spans = [g.get_tag_span(t.tag_id) for t in g.tag_list()]
    s_spans = [s.get_tag_span(t.tag_id) for t in s.tag_list()]
    spans = spans.union(set(g_spans))
    spans = spans.union(set(s_spans))

    scorer = Scorer()
    for span in spans:
        try:
            gold_pid = g_spans.index(span)
        except ValueError:
            scorer.fp += 1
github ku-nlp / pyknp / pyknp / evaluate / dep.py View on Github external
def dependency(g, s, level=2, checkType=False, ignoreStart=True):
    assert isinstance(g, BList)
    assert isinstance(s, BList)
    assert isinstance(level, int)
    assert isinstance(checkType, bool)
    assert isinstance(ignoreStart, bool)
    if level != 1 and level != 2:
        raise KeyError

    spans = set([])
    g_spans = [g.get_tag_span(t.tag_id) for t in g.tag_list()]
    s_spans = [s.get_tag_span(t.tag_id) for t in s.tag_list()]
    if ignoreStart:
        for i, g_span in enumerate(g_spans):
            g_spans[i] = g_span[1]
        for i, s_span in enumerate(s_spans):
            s_spans[i] = s_span[1]
    spans = spans.union(set(g_spans))

pyknp

Python module for JUMAN/KNP

See COPYING
Latest version published 3 years ago

Package Health Score

52 / 100
Full package analysis

Similar packages