Exemplo n.º 1
0
def test_from_dmrs(dogs_bark):
    from delphin import dmrs
    m = mrs.MRS(**dogs_bark)
    d = dmrs.DMRS(
        top=10002,
        index=10002,
        nodes=[
            dmrs.Node(10000, 'udef_q'),
            dmrs.Node(10001, '_dog_n_1', type='x',
                      properties={'NUM': 'pl'}),
            dmrs.Node(10002, '_bark_v_1', type='e',
                      properties={'TENSE': 'pres'})],
        links=[
            dmrs.Link(10000, 10001, 'RSTR', 'H'),
            dmrs.Link(10002, 10001, 'ARG1', 'NEQ')])
    _m = mrs.from_dmrs(d)

    # Issue #248
    labels = set(ep.label for ep in _m.rels)
    hcons = {hc.hi: hc.lo for hc in _m.hcons}
    assert _m.top not in labels
    assert _m.top in hcons
    assert hcons[_m.top] in labels
    # ensure equivalency
    assert mrs.is_isomorphic(m, _m)

    # try with no hook
    d.top = None
    d.index = None
    # it won't be isomorphic, just check for errors
    _m = mrs.from_dmrs(d)
    assert _m.top is None
    assert _m.index is None
    assert len(_m.rels) == 3
    assert len(_m.hcons) == 1
Exemplo n.º 2
0
def test_is_isomorphic_multi_pred2(m2, m2b):
    assert not mrs.is_isomorphic(m2, m2b)
Exemplo n.º 3
0
def test_is_isomorphic_pathological2(pathological1, pathological2):
    # be aware if the next ones take a long time to resolve
    assert not mrs.is_isomorphic(pathological1, pathological2)
Exemplo n.º 4
0
def test_is_isomorphic_arity(m1, m1g):
    assert not mrs.is_isomorphic(m1, m1g)  # diff arity
Exemplo n.º 5
0
def test_is_isomorphic_multi_pred(m2):
    assert mrs.is_isomorphic(m2, m2)
Exemplo n.º 6
0
def test_is_isomorphic_pred(m1, m1f):
    assert not mrs.is_isomorphic(m1, m1f)  # same structure, diff pred
Exemplo n.º 7
0
def test_is_isomorphic_top(m1, m1d, m1e):
    assert not mrs.is_isomorphic(m1, m1d)  # unlinked LTOP
    assert not mrs.is_isomorphic(m1, m1e)  # equated LTOP
Exemplo n.º 8
0
def test_is_isomorphic_properties(m1, m1c):
    assert not mrs.is_isomorphic(m1, m1c)  # diff TENSE value
    assert mrs.is_isomorphic(m1, m1c, properties=False)
Exemplo n.º 9
0
def test_is_isomorphic_lnk(m1, m1b):
    assert mrs.is_isomorphic(m1, m1b)  # diff Lnk only
Exemplo n.º 10
0
def test_is_isomorphic_identity(m1):
    assert mrs.is_isomorphic(m1, m1)