pubannotation_evaluator 1.0.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ba6d5024226dba72a62356ced9473f6d9c3d0761bf2591240a9463d539b9d47
4
- data.tar.gz: 5fc854a7de2767f26b57d02e7bbf5b371613a08f49a10c3fed9aa2a9e055b2b7
3
+ metadata.gz: 221340084b2e71edebc25671fe196d05f0e17ebeb3b2b9e8bca72c0fd6c42266
4
+ data.tar.gz: 2c88f506c78a19a43d72c5c009cc40d0c586146b9e13d02bb5075a9460162596
5
5
  SHA512:
6
- metadata.gz: 57c31f7d5c7d4a9400ceed1f582c92c093bf2ea5d47960d57a24b9c1d99cf6e5d9c94e6f138a298f6b0213b01d6bf562d44147ce964a94285aa8182a45ce74e5
7
- data.tar.gz: 9e6bb76a8db19410bd4a66c8442b0cc19a5b50397c63d134bf9128b13963071cd015604588a073ad2c1b3ee91bba76f10ffca2c75ff8a9f8774026b13e26fca2
6
+ metadata.gz: 6ab795d95e7a6e44406932e132c65f0a5391f4a2623bba8d35126cdec68e7ae9c097d2dc2bb7da7e8f9db121d147a9dbf18a52e3b9f9f040bf272efbe468e1f1
7
+ data.tar.gz: 40efce24c19bfe9b2d4b62065a553a1b218a36703c6e1e2b074462788afabb68fbe3b4fce9ab666fc74e2fe0147bc7405206d02b784db5fcfe5fb6878c7961ac
@@ -84,6 +84,11 @@ if verbose
84
84
 
85
85
  false_negatives = comparison.select{|m| m[:study].nil? && m[:reference]}
86
86
  evaluation[:false_negatives] = false_negatives unless false_negatives.empty?
87
+
88
+ true_positives = comparison.select{|m| m[:study] && m[:reference]}
89
+ evaluation[:true_positives] = true_positives unless true_positives.empty?
87
90
  end
88
91
 
89
- puts JSON.generate(evaluation)
92
+ puts JSON.generate(evaluation)
93
+
94
+ # puts JSON.generate(comparison)
@@ -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
+ study_denotations.each{|r| r.merge!(text:text[r[:span][:begin]...r[:span][:end]])}
74
+ reference_denotations.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
@@ -168,8 +169,7 @@ class PubannotationEvaluator
168
169
 
169
170
  # predicate match
170
171
  match_pred_weight = @relation_type_match.call(s[:pred], r[:pred])
171
-
172
- 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
173
173
  end
174
174
 
175
175
  def find_relation_matches(matches)
@@ -195,11 +195,11 @@ class PubannotationEvaluator
195
195
  r_matched = []
196
196
  matches_group_by_s = matches.group_by{|m| m[:study]}
197
197
  matches_group_by_s.each_value do |m|
198
+ m.delete_if{|i| r_matched.include?(i[:reference])}
198
199
  if m.length == 1
199
200
  s_matched << m[0][:study]
200
201
  r_matched << m[0][:reference]
201
- else
202
- m.delete_if{|i| r_matched.include?(i[:reference])}
202
+ elsif m.length > 1
203
203
  m_sel = m.max{|a, b| comp.call(a, b)}
204
204
  m.replace([m_sel])
205
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.3
4
+ version: 1.2.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-22 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