props icon indicating copy to clipboard operation
props copied to clipboard

Augment nested JSON KR with text for nodes

Open saraswat opened this issue 7 years ago • 0 comments

In Textual Knowledge Representation and Reasoning (which I define to be KR&R systems in which knowledge is represented by pieces of text, manipulated by symbolic and numeric techniques) , it is valuable to associate with the extracted structured elements the fragments of the original text that they represent. This text could be used, for example, when presenting an end user with a textual interface to the KR system or to generate a textual explanation.

As an example, the sentence:

Mr Macri also modified by decree the Media Law , one of the more controversial reforms 
passed by the Fernandez administration.

can be represented by:

{'lf': [{'mod': 'also',
         'pred': 'modified',
         'prepc_by': {
            'dobj': [{'word': ['Media', 'Law'], 'xtarget': '71'},
                         {'prep_of': 
                             {'mod': [{'mod': 'more', 'word': 'controversial'},
                                            {'pred': 'passed', 
                                             'prep_by': ['Fernandez',  'administration']}],            
                               'word': 'reforms'},
                            'word': 'one',
                            'xtarget': '59'}],
             'word': 'decree'},
         'subj': ['Mr', 'Macri']},
        {'pred': 'SameAs', 'sameAs_arg': [{'xref': '71'}, {'xref': '59'}]}]}

To express the association with fragments from the original text, we would say:

{'lf': [{'mod': 'also',
         'pred': 'modified',
         'prepc_by': {
            'dobj': [{'word': ['Media', 'Law'], 'xtarget': '71'},
                         {'prep_of': 
                             {'mod': [{'mod': 'more', 'word': 'controversial', 
                                             'text': '{mod}{word}'},
                                            {'pred': 'passed', 
                                              'prep_by': ['Fernandez', 'administration']}, 
                                              'text': '{pred} by {prep_by}'],            
                               'word': 'reforms',
                               'text': '{the mod[0]} {word} {mod[1]}'},
                            'word': 'one', 'text': '{word} of {prep_of}',
                            'xtarget': '59'}],
             'word': 'decree', 'text' : 'by {word} {dobj}'},
         'subj': ['Mr', 'Macri'],  'text': '{subj} {mod} {prep} {prepc_by}'},
        {'pred': 'SameAs', 'sameAs_arg': [{'xref': '71'}, {'xref': '59'}],
          'text': '\"{sameAs_arg[0]}\" is the same as \"{sameAs_arg[1]}\".'}
  ]}

Here when a text field is present in a form F, it is a format string that can reference the fields of F as variables. We adopt two conventions:

  • The text field defaults to {word}.
  • If a field G takes a list L as value, then the specifier {G} in a format string is replaced by ' '.join(L).

saraswat avatar Jun 26 '17 07:06 saraswat