Esempio 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
Esempio n. 2
0
def test_is_isomorphic_multi_pred2(m2, m2b):
    assert not mrs.is_isomorphic(m2, m2b)
Esempio 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)
Esempio n. 4
0
def test_is_isomorphic_arity(m1, m1g):
    assert not mrs.is_isomorphic(m1, m1g)  # diff arity
Esempio n. 5
0
def test_is_isomorphic_multi_pred(m2):
    assert mrs.is_isomorphic(m2, m2)
Esempio n. 6
0
def test_is_isomorphic_pred(m1, m1f):
    assert not mrs.is_isomorphic(m1, m1f)  # same structure, diff pred
Esempio 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
Esempio 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)
Esempio n. 9
0
def test_is_isomorphic_lnk(m1, m1b):
    assert mrs.is_isomorphic(m1, m1b)  # diff Lnk only
Esempio n. 10
0
def test_is_isomorphic_identity(m1):
    assert mrs.is_isomorphic(m1, m1)