Пример #1
0
 def add(self, entry):
     self.add_metatype(entry.get('?metatype'), entry.get('where'))
     self.add_type(entry.get('?type'))
     self.add_mention(entry.get('?mention_span'),
                      trim_cv(entry.get('?type_statement_confidence')),
                      trim_cv(entry.get('?cluster_membership_confidence')),
                      trim_cv(entry.get('?mention_type_justification_confidence')),
                      entry.get('where'))
Пример #2
0
 def normalize_confidences(responses, cluster_id):
     max_confidence = None
     for response in responses.values():
         if response.get('cluster_id') != cluster_id: continue
         justification_confidence = trim_cv(response.get('justification_confidence'))
         if max_confidence is None:
             max_confidence = justification_confidence
         if justification_confidence > max_confidence:
             max_confidence = justification_confidence
     for response in responses.values():
         normalized_confidence_value = trim_cv(response.get('justification_confidence'))/max_confidence
         response.set('normalized_justification_confidence', normalized_confidence_value)
Пример #3
0
 def compute_weights(responses, APPLY_NORMALIZATION, APPLY_WEIGHTS):
     for response in responses.values():
         weight = 1
         if APPLY_WEIGHTS:
             if APPLY_NORMALIZATION:
                 weight = response.get('normalized_justification_confidence')
             else:
                 weight = trim_cv(response.get('justification_confidence'))
         response.set('weight', weight)
Пример #4
0
 def validate_importance_value(self, responses, schema, entry, attribute):
     importance_value = entry.get(attribute.get('name'))
     try:
         value = trim_cv(importance_value)
     except ValueError:
         self.record_event('INVALID_IMPORTANCE_VALUE', importance_value,
                           entry.get('where'))
         return False
     return True
Пример #5
0
 def get_aggregate_confidence(self, entry):
     field_names = [
         'type_statement_confidence', 'cluster_membership_confidence',
         'mention_type_justification_confidence'
     ]
     confidence = 1.0
     for field_name in field_names:
         confidence *= trim_cv(entry.get(field_name))
     return confidence
Пример #6
0
 def validate_confidence(self, responses, schema, entry, attribute):
     value = trim_cv(entry.get(attribute.get('name')))
     if schema.get('task') == 'task3' and schema.get('query_type') == 'GraphQuery' and value == 'NULL' and attribute.get('name') == 'edge_compound_justification_confidence':
         return True
     try: 
         float(value)
     except ValueError:
         entry.set(attribute.get('name'), 1)
         self.record_event('INVALID_CONFIDENCE', value, entry.get('where'))
         return False
     if not 0 < float(value) <= 1:
         self.record_event('INVALID_CONFIDENCE', value, entry.get('where'))
         return False
     return True
Пример #7
0
 def validate_confidence(self, responses, schema, entry, attribute):
     confidence_value = entry.get(attribute.get('name'))
     if schema.get('task') == 'task3' and schema.get(
             'name'
     ) == 'AIDA_PHASE2_TASK3_GR_RESPONSE' and attribute.get(
             'name'
     ) == 'predicate_justification_confidence' and confidence_value == 'NULL':
         return True
     try:
         value = trim_cv(confidence_value)
     except ValueError:
         self.record_event('INVALID_CONFIDENCE',
                           entry.get(attribute.get('name')),
                           entry.get('where'))
         value = 1.0
         entry.set(attribute.get('name'), '"{value}"'.format(value=value))
     if not 0 < value <= 1:
         self.record_event('INVALID_CONFIDENCE', value, entry.get('where'))
         value = 1.0
         entry.set(attribute.get('name'), '"{value}"'.format(value=value))
     return True