Class: PubannotationEvaluator
- Inherits:
-
Object
- Object
- PubannotationEvaluator
- Defined in:
- lib/pubannotation_evaluator/pubannotation_evaluator.rb
Constant Summary collapse
- SOFT_MATCH_CHARACTERS =
20- SOFT_MATCH_WORDS =
2- EXACT_TYPE_MATCH =
'study_type == reference_type ? 1 : 0'
Instance Method Summary collapse
-
#compare(study_annotations, reference_annotations) ⇒ Object
To compare two sets of annotations.
-
#evaluate(comparison) ⇒ Object
To produce evaluations based on comparison.
- #get_false_negatives(comparison, project_name) ⇒ Object
- #get_false_positives(comparison, project_name) ⇒ Object
-
#initialize(soft_match_chatacters = SOFT_MATCH_CHARACTERS, soft_match_words = SOFT_MATCH_WORDS, denotation_type_match = EXACT_TYPE_MATCH, relation_type_match = EXACT_TYPE_MATCH) ⇒ PubannotationEvaluator
constructor
A new instance of PubannotationEvaluator.
Constructor Details
#initialize(soft_match_chatacters = SOFT_MATCH_CHARACTERS, soft_match_words = SOFT_MATCH_WORDS, denotation_type_match = EXACT_TYPE_MATCH, relation_type_match = EXACT_TYPE_MATCH) ⇒ PubannotationEvaluator
Returns a new instance of PubannotationEvaluator.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/pubannotation_evaluator/pubannotation_evaluator.rb', line 6 def initialize(soft_match_chatacters = SOFT_MATCH_CHARACTERS, soft_match_words = SOFT_MATCH_WORDS, denotation_type_match = EXACT_TYPE_MATCH, relation_type_match = EXACT_TYPE_MATCH) @soft_match_chatacters = soft_match_chatacters @soft_match_words = soft_match_words @denotation_type_match = eval <<-HEREDOC Proc.new do |study_type, reference_type| #{denotation_type_match} end HEREDOC @relation_type_match = eval <<-HEREDOC Proc.new do |study_type, reference_type| #{relation_type_match} end HEREDOC end |
Instance Method Details
#compare(study_annotations, reference_annotations) ⇒ Object
To compare two sets of annotations
Attributes
-
study_annotations: annotations to be studied -
reference_annotations: annotations to be compared against
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/pubannotation_evaluator/pubannotation_evaluator.rb', line 27 def compare(study_annotations, reference_annotations) study_annotations[:denotations] ||= [] study_annotations[:relations] ||= [] study_annotations[:modifications] ||= [] reference_annotations[:denotations] ||= [] reference_annotations[:relations] ||= [] reference_annotations[:modifications] ||= [] comparison_denotations, mmatches_denotations = compare_denotations(study_annotations[:denotations], reference_annotations[:denotations], reference_annotations[:text]) comparison_relations = compare_relations(study_annotations[:relations], reference_annotations[:relations], mmatches_denotations) comparison_modifications = compare_modifications(study_annotations[:modofications], reference_annotations[:modofications], comparison_denotations, comparison_relations) comparison = comparison_denotations.collect{|a| a.merge(type: :denotation)} + comparison_relations.collect{|a| a.merge(type: :relation)} + comparison_modifications.collect{|a| a.merge(type: :modification)} docspec = {sourcedb:study_annotations[:sourcedb], sourceid:study_annotations[:sourceid]} docspec[:divid] = study_annotations[:divid] if study_annotations.has_key?(:divid) comparison.collect{|d| d.merge(docspec)} end |
#evaluate(comparison) ⇒ Object
To produce evaluations based on comparison.
Attributes
-
comparison: the mapping between study and reference annotations
53 54 55 56 57 |
# File 'lib/pubannotation_evaluator/pubannotation_evaluator.rb', line 53 def evaluate(comparison) counts = count(comparison) measures = measure(counts) {counts:counts, measures:measures} end |
#get_false_negatives(comparison, project_name) ⇒ Object
63 64 65 |
# File 'lib/pubannotation_evaluator/pubannotation_evaluator.rb', line 63 def get_false_negatives(comparison, project_name) comparison.select{|m| m[:study].nil? && m[:reference]} end |
#get_false_positives(comparison, project_name) ⇒ Object
59 60 61 |
# File 'lib/pubannotation_evaluator/pubannotation_evaluator.rb', line 59 def get_false_positives(comparison, project_name) comparison.select{|m| m[:study] && m[:reference].nil?} end |