simple_bioc 0.0.12 → 0.0.13

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
  SHA1:
3
- metadata.gz: 85e59da540b4e77a5802b72315e9a9a8e7c60a71
4
- data.tar.gz: 5d0db6bfd1c2fd8fd3ea713de9f60aeff0c7b365
3
+ metadata.gz: db44fee4f6e45f654411f55a3a5bf56794e439e7
4
+ data.tar.gz: c407b58528e2e24a3720f922d671bd5f953b02de
5
5
  SHA512:
6
- metadata.gz: db1b62532952cfc88237d359dc70d1c5aa0abbc6152455b2245f0229b4e8138985fc716adba6f9648e358de50342e5de984f48f52ea59a59560b3ebc46efd75a
7
- data.tar.gz: 398312f95e42cd2f36371509a4a85a1c35bd670f60cb30b54556aa0fbb75810764578bb1ff726d5a140966480d6e64510ee28f93a047b146d48543362e4b3395
6
+ metadata.gz: f05837f3817efed20bb56e81cc7781d224d7246ca405157d02aabe2193b50163d7e8c7190e0dfa50a53a28908614659415883b8d4569ac06eb27d1cd36077a3a
7
+ data.tar.gz: d300ea89b5a31bac10a42f11a16e22d54c188b2a9f9798354a55b781c74920cf9f80a3d2b5c64a161c9abb2d9c179dcc5d28eb354c505dc4579927b3c1d072fe
@@ -1,39 +1,41 @@
1
- module LocationAdjuster
2
- def adjust_annotation_offsets
3
- obj = self
4
- return if obj.nil?
5
- obj.annotations.each do |a|
6
- positions = find_all_locations(obj, a.text)
7
- a.locations.each do |l|
8
- l.offset = choose_offset_candidate(l.offset, positions)
1
+ module SimpleBioC
2
+ module LocationAdjuster
3
+ def adjust_annotation_offsets
4
+ obj = self
5
+ return if obj.nil?
6
+ obj.annotations.each do |a|
7
+ positions = find_all_locations(obj, a.text)
8
+ a.locations.each do |l|
9
+ l.offset = choose_offset_candidate(l.offset, positions)
10
+ end
9
11
  end
10
12
  end
11
- end
12
-
13
- module_function
13
+
14
+ module_function
14
15
 
15
- def find_all_locations(obj, text)
16
- positions = []
17
- return positions if obj.nil? || obj.text.nil?
18
- pos = obj.text.index(text)
19
- until pos.nil?
20
- positions << (pos + obj.offset)
21
- pos = obj.text.index(text, pos + 1)
16
+ def find_all_locations(obj, text)
17
+ positions = []
18
+ return positions if obj.nil? || obj.text.nil?
19
+ pos = obj.text.index(text)
20
+ until pos.nil?
21
+ positions << (pos + obj.offset)
22
+ pos = obj.text.index(text, pos + 1)
23
+ end
24
+ return positions
22
25
  end
23
- return positions
24
- end
25
26
 
26
- def choose_offset_candidate(offset, positions)
27
- min_diff = 99999
28
- offset = offset.to_i
29
- ret = offset
30
- positions.each do |p|
31
- diff = (offset - p).abs
32
- if diff < min_diff
33
- ret = p
34
- min_diff = diff
27
+ def choose_offset_candidate(offset, positions)
28
+ min_diff = 99999
29
+ offset = offset.to_i
30
+ ret = offset
31
+ positions.each do |p|
32
+ diff = (offset - p).abs
33
+ if diff < min_diff
34
+ ret = p
35
+ min_diff = diff
36
+ end
35
37
  end
38
+ return ret
36
39
  end
37
- return ret
38
40
  end
39
41
  end
@@ -1,3 +1,4 @@
1
+ require 'simple_bioc/location_adjuster'
1
2
  module SimpleBioC
2
3
  class Passage
3
4
  include LocationAdjuster
@@ -1,3 +1,4 @@
1
+ require 'simple_bioc/location_adjuster'
1
2
  module SimpleBioC
2
3
  class Sentence
3
4
  include LocationAdjuster
@@ -1,3 +1,3 @@
1
1
  module SimpleBioC
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_bioc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dongseop Kwon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-24 00:00:00.000000000 Z
11
+ date: 2016-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri