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 +4 -4
- data/lib/simple_bioc/location_adjuster.rb +32 -30
- data/lib/simple_bioc/passage.rb +1 -0
- data/lib/simple_bioc/sentence.rb +1 -0
- data/lib/simple_bioc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db44fee4f6e45f654411f55a3a5bf56794e439e7
|
4
|
+
data.tar.gz: c407b58528e2e24a3720f922d671bd5f953b02de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f05837f3817efed20bb56e81cc7781d224d7246ca405157d02aabe2193b50163d7e8c7190e0dfa50a53a28908614659415883b8d4569ac06eb27d1cd36077a3a
|
7
|
+
data.tar.gz: d300ea89b5a31bac10a42f11a16e22d54c188b2a9f9798354a55b781c74920cf9f80a3d2b5c64a161c9abb2d9c179dcc5d28eb354c505dc4579927b3c1d072fe
|
@@ -1,39 +1,41 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
12
|
-
|
13
|
-
module_function
|
13
|
+
|
14
|
+
module_function
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
data/lib/simple_bioc/passage.rb
CHANGED
data/lib/simple_bioc/sentence.rb
CHANGED
data/lib/simple_bioc/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2016-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|