wongc7 / ontosem

OntoSem TMR and Intermediate Results Visualizer
0 stars 0 forks source link

Handle [attribute]_constraint_info #15

Closed wongc7 closed 7 years ago

wongc7 commented 7 years ago

There seems to be a -_constraint_info attribute added that displays semantic information that explains a decision made by the analyzer. Currently it displays as [object Object] (which should be addressed in issue #9), and beyond that it may be possible to display it separately from the remaining attributes. We could possibly reuse the lexicon entry template.

Example TMR (see TEACH-1 and RETIRE-1):

{'results': [{'TMR': {'HUMAN-1': {'AGENT-OF': 'TEACH-1',
                                  'HAS-SURNAME': 'MARY',
                                  'concept': 'HUMAN',
                                  'from-sense': 'PERSON-NAME',
                                  'is-in-subtree': 'OBJECT',
                                  'lex-source': 'onomasticon',
                                  'preference': 3,
                                  'sem-preference': 0,
                                  'sent-word-ind': [0, [0]],
                                  'token': 'Mary'},
                      'HUMAN-2': {'HAS-SURNAME': 'GEORGE',
                                  'concept': 'HUMAN',
                                  'from-sense': 'PERSON-NAME',
                                  'is-in-subtree': 'OBJECT',
                                  'lex-source': 'onomasticon',
                                  'preference': 3,
                                  'sem-preference': 0,
                                  'sent-word-ind': [0, [2]],
                                  'token': 'George'},
                      'HUMAN-3': {'AGENT-OF': 'RETIRE-1',
                                  'GENDER': 'FEMALE',
                                  'concept': 'HUMAN',
                                  'from-sense': 'SHE-N1',
                                  'is-in-subtree': 'OBJECT',
                                  'preference': 1,
                                  'sem-preference': 0,
                                  'sent-word-ind': [0, [6]],
                                  'token': 'she'},
                      'RETIRE-1': {'AGENT': 'HUMAN-3',
                                   'AGENT_constraint_info': {'match': 'SEM',
                                                             'matched_constraint': 'HUMAN',
                                                             'type': 'onto',
                                                             'variable': '^$VAR1'},
                                   'TIME': ['<', 'FIND-ANCHOR-TIME'],
                                   'concept': 'RETIRE',
                                   'from-sense': 'RETIRE-V1',
                                   'is-in-subtree': 'EVENT',
                                   'preference': 1,
                                   'sem-preference': 1,
                                   'sent-word-ind': [0, [7]],
                                   'token': 'retired'},
                      'TEACH-1': {'AGENT': 'HUMAN-1',
                                  'AGENT_constraint_info': {'match': 'SEM',
                                                            'matched_constraint': 'HUMAN',
                                                            'type': 'onto',
                                                            'variable': '^$VAR1'},
                                  'TIME': ['<', 'FIND-ANCHOR-TIME'],
                                  'TIME-1': ['>', ['SEEK-COMPARED-EVENT']],
                                  'concept': 'TEACH',
                                  'from-sense': 'TEACH-V1',
                                  'is-in-subtree': 'EVENT',
                                  'preference': 1,
                                  'sem-preference': 1,
                                  'sent-word-ind': [0, [1, 4, 5]],
                                  'token': 'taught'},
                      'rejected-words': {3: 'MATH'},
                      'total-confidence': 11,
                      'total-preference': 9},
              'concept_counts': {'HUMAN': {'count': 3, 'word-info': [[0, 'top'], [2, 'top'], [6, 'top']]},
                                 'RETIRE': {'count': 1, 'word-info': [[7, 'top']]},
                                 'TEACH': {'count': 1, 'word-info': [[1, 'top']]}},
              'words': {0: 'PERSON-NAME',
                        1: 'TEACH-V1',
                        2: 'PERSON-NAME',
                        4: 'AND-CONJ1',
                        5: 'LATER-ADV1',
                        6: 'SHE-N1',
                        7: 'RETIRE-V1'}},
             {'TMR': {'HUMAN-1': {'AGENT-OF': 'TEACH-1',
                                  'HAS-SURNAME': 'MARY',
                                  'concept': 'HUMAN',
                                  'from-sense': 'PERSON-NAME',
                                  'is-in-subtree': 'OBJECT',
                                  'lex-source': 'onomasticon',
                                  'preference': 3,
                                  'sem-preference': 0,
                                  'sent-word-ind': [0, [0]],
                                  'token': 'Mary'},
                      'HUMAN-2': {'HAS-SURNAME': 'GEORGE',
                                  'concept': 'HUMAN',
                                  'from-sense': 'PERSON-NAME',
                                  'is-in-subtree': 'OBJECT',
                                  'lex-source': 'onomasticon',
                                  'preference': 3,
                                  'sem-preference': 0,
                                  'sent-word-ind': [0, [2]],
                                  'token': 'George'},
                      'HUMAN-3': {'AGENT-OF': 'RETIRE-1',
                                  'GENDER': 'FEMALE',
                                  'concept': 'HUMAN',
                                  'from-sense': 'SHE-N1',
                                  'is-in-subtree': 'OBJECT',
                                  'preference': 1,
                                  'sem-preference': 0,
                                  'sent-word-ind': [0, [6]],
                                  'token': 'she'},
                      'RETIRE-1': {'AGENT': 'HUMAN-3',
                                   'AGENT_constraint_info': {'match': 'SEM',
                                                             'matched_constraint': 'HUMAN',
                                                             'type': 'onto',
                                                             'variable': '^$VAR1'},
                                   'TIME': ['<', 'FIND-ANCHOR-TIME'],
                                   'concept': 'RETIRE',
                                   'from-sense': 'RETIRE-V1',
                                   'is-in-subtree': 'EVENT',
                                   'preference': 1,
                                   'sem-preference': 1,
                                   'sent-word-ind': [0, [7]],
                                   'token': 'retired'},
                      'SET-1': {'ELEMENTS': ['^$VAR1', '^$VAR2'],
                                'concept': 'SET',
                                'from-sense': 'AND-CONJ3',
                                'is-in-subtree': 'PROPERTY',
                                'preference': -1,
                                'sem-preference': 0,
                                'sent-word-ind': [0, [4]],
                                'token': 'and'},
                      'TEACH-1': {'AGENT': 'HUMAN-1',
                                  'AGENT_constraint_info': {'match': 'SEM',
                                                            'matched_constraint': 'HUMAN',
                                                            'type': 'onto',
                                                            'variable': '^$VAR1'},
                                  'TIME': ['<', 'FIND-ANCHOR-TIME'],
                                  'TIME-1': ['>', ['SEEK-COMPARED-EVENT']],
                                  'concept': 'TEACH',
                                  'from-sense': 'TEACH-V1',
                                  'is-in-subtree': 'EVENT',
                                  'preference': 2,
                                  'sem-preference': 1,
                                  'sent-word-ind': [0, [1, 5]],
                                  'token': 'taught'},
                      'rejected-words': {3: 'MATH'},
                      'total-confidence': 11,
                      'total-preference': 9},
              'concept_counts': {'HUMAN': {'count': 3, 'word-info': [[0, 'top'], [2, 'top'], [6, 'top']]},
                                 'RETIRE': {'count': 1, 'word-info': [[7, 'top']]},
                                 'SET': {'count': 1, 'word-info': [[4, 'top']]},
                                 'TEACH': {'count': 1, 'word-info': [[1, 'top']]}},
              'words': {0: 'PERSON-NAME',
                        1: 'TEACH-V1',
                        2: 'PERSON-NAME',
                        4: 'AND-CONJ3',
                        5: 'LATER-ADV1',
                        6: 'SHE-N1',
                        7: 'RETIRE-V1'}}],
 'sent-num': 0,
 'sentence': 'Mary taught George math and then she retired.',
 'timestamp': '2016-Dec-29 20:58:05'}