pubannotation_evaluator 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fa609f2eaa40072aaf68f19d943908cf959c68c951cfabe7c530fae96efdbe8
4
- data.tar.gz: 66e92d37b5db14676152c17d777ff25071844e3e4297ec8bb5cd4633cc867470
3
+ metadata.gz: 806a1cccb5be0bc733f7deb05fe647d03816235a28bffec791aeb450a33cca46
4
+ data.tar.gz: a10d449746dd75e7923a4c08e82e1c6e8ac7310ddf9524b876c61327d88e8936
5
5
  SHA512:
6
- metadata.gz: ca65f506b81afaa8eb2fc8af8acebda766db0a66ec8d317796df7934ed6f92227ba7364004f6c7bfe507c790c067bea67d4887c7137b2cf980f35fe6efcdca7d
7
- data.tar.gz: '0607055296bb34c586a7d8c03e91a71d5781a76478ae1673501dc29fe85eeda0f55e6e10584b906d9b2b8268bbf08cefef7815328723dee20cce16c8b5cf912a'
6
+ metadata.gz: 27486eff982a8a8972a03aa42d9eeca6f7598d9bf76631ba2881251be786bde75254b02b9502701e5601a81e7b6edb052d852ef3d1f006477a213bde602b3631
7
+ data.tar.gz: 6ea8c8f982c327a86c5cfa61a51a8f5bc4d3d03edd75d407ca720bf3494ab572d4d78f86c114d87211d533cb8172984d467f9267ef75b137168510207b35e623
@@ -3,17 +3,17 @@ class PubannotationEvaluator
3
3
  SOFT_MATCH_WORDS = 2
4
4
  EXACT_TYPE_MATCH = 'study_type == reference_type ? 1 : 0'
5
5
 
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)
7
- @soft_match_chatacters = soft_match_chatacters
8
- @soft_match_words = soft_match_words
6
+ def initialize(soft_match_chatacters, soft_match_words, denotation_type_match, relation_type_match)
7
+ @soft_match_chatacters = soft_match_chatacters || SOFT_MATCH_CHARACTERS
8
+ @soft_match_words = soft_match_words || SOFT_MATCH_WORDS
9
9
  @denotation_type_match = eval <<-HEREDOC
10
10
  Proc.new do |study_type, reference_type|
11
- #{denotation_type_match}
11
+ #{denotation_type_match || EXACT_TYPE_MATCH}
12
12
  end
13
13
  HEREDOC
14
14
  @relation_type_match = eval <<-HEREDOC
15
15
  Proc.new do |study_type, reference_type|
16
- #{relation_type_match}
16
+ #{relation_type_match || EXACT_TYPE_MATCH}
17
17
  end
18
18
  HEREDOC
19
19
  end
@@ -41,7 +41,6 @@ class PubannotationEvaluator
41
41
  comparison_modifications.collect{|a| a.merge(type: :modification)}
42
42
 
43
43
  docspec = {sourcedb:study_annotations[:sourcedb], sourceid:study_annotations[:sourceid]}
44
- docspec[:divid] = study_annotations[:divid] if study_annotations.has_key?(:divid)
45
44
  comparison.collect{|d| d.merge(docspec)}
46
45
  end
47
46
 
@@ -71,6 +70,8 @@ class PubannotationEvaluator
71
70
  matches = find_denotation_matches(mmatches)
72
71
  false_positives = study_denotations - matches.collect{|r| r[:study]}
73
72
  false_negatives = reference_denotations - matches.collect{|r| r[:reference]}
73
+ false_positives.each{|r| r.merge!(text:text[r[:span][:begin]...r[:span][:end]])}
74
+ false_negatives.each{|r| r.merge!(text:text[r[:span][:begin]...r[:span][:end]])}
74
75
  comparison = matches + false_positives.collect{|s| {study:s}} + false_negatives.collect{|r| {reference:r}}
75
76
  [comparison, mmatches]
76
77
  end
@@ -83,8 +84,11 @@ class PubannotationEvaluator
83
84
  mmatches = []
84
85
  study_denotations.each do |s|
85
86
  r_begin = reference_denotations.bsearch_index{|r| r[:span][:end] > s[:span][:begin]}
87
+ break if r_begin.nil?
88
+
86
89
  r_end = reference_denotations.bsearch_index{|r| r[:span][:begin] > s[:span][:end]}
87
90
  r_end = r_end.nil? ? -1 : r_end - 1
91
+
88
92
  reference_denotations[r_begin .. r_end].each do |r|
89
93
  relatedness = get_relatedness_of_denotations(s, r, text)
90
94
  mmatches << {study:s, reference:r, weight:relatedness} if relatedness > 0
@@ -165,8 +169,7 @@ class PubannotationEvaluator
165
169
 
166
170
  # predicate match
167
171
  match_pred_weight = @relation_type_match.call(s[:pred], r[:pred])
168
-
169
- return (match_subj[:weight] + match_obj[:weight] + match_pred_weight).to_f / 3
172
+ # return (match_subj[:weight] + match_obj[:weight] + match_pred_weight).to_f / 3
170
173
  end
171
174
 
172
175
  def find_relation_matches(matches)
@@ -192,11 +195,11 @@ class PubannotationEvaluator
192
195
  r_matched = []
193
196
  matches_group_by_s = matches.group_by{|m| m[:study]}
194
197
  matches_group_by_s.each_value do |m|
198
+ m.delete_if{|i| r_matched.include?(i[:reference])}
195
199
  if m.length == 1
196
200
  s_matched << m[0][:study]
197
201
  r_matched << m[0][:reference]
198
- else
199
- m.delete_if{|i| r_matched.include?(i[:reference])}
202
+ elsif m.length > 1
200
203
  m_sel = m.max{|a, b| comp.call(a, b)}
201
204
  m.replace([m_sel])
202
205
  s_matched << m_sel[:study]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubannotation_evaluator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jin-Dong Kim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-30 00:00:00.000000000 Z
11
+ date: 2021-12-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A tool to evaluate the accuracy of a set of annotations.
14
14
  email: jdkim@dbcls.rois.ac.jp
@@ -39,8 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  requirements: []
42
- rubyforge_project:
43
- rubygems_version: 2.7.9
42
+ rubygems_version: 3.0.9
44
43
  signing_key:
45
44
  specification_version: 4
46
45
  summary: It compares a set of annotations (study annotations) against another set