Beispiel #1
0
    def test_from_dict(self):
        assert Mrs.from_dict({}) == Mrs()

        m1 = Mrs.from_dict({
            'relations': [{
                'label': 'h1',
                'predicate': '_rain_v_1',
                'arguments': {
                    'ARG0': 'e2'
                }
            }],
            'constraints': [],
            'variables': {
                'h1': {
                    'type': 'h'
                },
                'e2': {
                    'type': 'e'
                }
            }
        })
        m2 = Mrs(rels=[
            EP(FIRST_NODEID, sp('"_rain_v_1_rel"'), 'h1', {'ARG0': 'e2'})
        ])
        assert m1 == m2
Beispiel #2
0
 def mrs(self):
     """
     Deserialize and return an Mrs object for simplemrs or
     JSON-formatted MRS data; otherwise return the original string.
     """
     mrs = self.get('mrs')
     if mrs is not None:
         if isinstance(mrs, dict):
             mrs = Mrs.from_dict(mrs)
         elif isinstance(mrs, stringtypes):
             mrs = simplemrs.loads_one(mrs)
     return mrs
Beispiel #3
0
 def mrs(self):
     """
     Deserialize and return an Mrs object for simplemrs or
     JSON-formatted MRS data; otherwise return the original string.
     """
     mrs = self.get('mrs')
     if mrs is not None:
         if isinstance(mrs, dict):
             mrs = Mrs.from_dict(mrs)
         elif isinstance(mrs, stringtypes):
             mrs = simplemrs.loads_one(mrs)
     return mrs