simple_bioc 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/simple_bioc/bioc_merger.rb +5 -4
- data/lib/simple_bioc/version.rb +1 -1
- data/spec/file_check_spec.rb +9 -11
- data/xml/353.xml +5387 -0
- data/xml/9864355.xml +1 -0
- data/xml/9864355_1.xml +1 -0
- data/xml/9864355_2.xml +1974 -0
- data/xml/9864355_3.xml +1 -0
- data/xml/merge/output.xml +3654 -510
- data/xml/output.xml +7714 -0
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74a3d6d3513cdaa61df2b88050b9a44cf0852ed1
|
4
|
+
data.tar.gz: 8c14726b89b7d2f79ffc63b8db0ac5427d38640a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2559a63848b14f15b0a26a745ae7d1a58d677fbfd520b7f42467e76a2b69bdffda4eeedf73319c79a3d13abcbf7ad008f87899c36111dd6ae1e6591767a0e281
|
7
|
+
data.tar.gz: c25c91ce425ed2b1a4050898ae61415507c4720c9c54b660461d0ebb7535ffe1d821142cc0db9dc66d18e74c9153c3d74a7590395f4fa3c574958e06ba4332f6
|
@@ -45,7 +45,7 @@ module BioCMerger
|
|
45
45
|
if p_d.sentences.size == p_s.sentences.size
|
46
46
|
p_d.sentences.each_with_index do |s_d, index|
|
47
47
|
s_s = p_s.sentences[index]
|
48
|
-
copy_infons(s_d, s_s
|
48
|
+
copy_infons(s_d, s_s)
|
49
49
|
copy_text(s_d, s_s)
|
50
50
|
copy_relations(doc_d, s_d, s_s, id_map)
|
51
51
|
copy_annotations(doc_d, s_d, s_s, id_map)
|
@@ -132,8 +132,8 @@ module BioCMerger
|
|
132
132
|
new_r.id = choose_id(doc, relation.id, id_map)
|
133
133
|
relation.nodes.each do |n|
|
134
134
|
node = SimpleBioC::Node.new(new_r)
|
135
|
-
node.refid =
|
136
|
-
node.role =
|
135
|
+
node.refid = n.refid
|
136
|
+
node.role = n.role
|
137
137
|
new_r.nodes << node
|
138
138
|
end
|
139
139
|
copy_infons(new_r, relation)
|
@@ -157,7 +157,7 @@ module BioCMerger
|
|
157
157
|
end
|
158
158
|
|
159
159
|
def choose_id(doc, id, id_map)
|
160
|
-
new_id = id
|
160
|
+
new_id = id || "id"
|
161
161
|
node = doc.find_node(new_id)
|
162
162
|
|
163
163
|
until node.nil? do
|
@@ -193,6 +193,7 @@ module BioCMerger
|
|
193
193
|
|
194
194
|
def find_all_locations(obj, text)
|
195
195
|
positions = []
|
196
|
+
return positions if obj.nil? || obj.text.nil?
|
196
197
|
pos = obj.text.index(text)
|
197
198
|
until pos.nil?
|
198
199
|
positions << (pos + obj.offset)
|
data/lib/simple_bioc/version.rb
CHANGED
data/spec/file_check_spec.rb
CHANGED
@@ -41,15 +41,13 @@ describe "File Check" do
|
|
41
41
|
col5 = SimpleBioC.from_xml("./xml/merge/output.xml")
|
42
42
|
end
|
43
43
|
|
44
|
-
it "should
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
54
|
-
|
44
|
+
it "should load XML files successfully" do
|
45
|
+
Dir["./xml/*.xml"].each do |file_path|
|
46
|
+
puts "self-merge #{file_path}"
|
47
|
+
collection1 = SimpleBioC.from_xml(file_path)
|
48
|
+
collection2 = SimpleBioC.from_xml(file_path)
|
49
|
+
SimpleBioC.merge(collection1, collection2)
|
50
|
+
output = SimpleBioC.to_xml(collection1)
|
51
|
+
end
|
52
|
+
end
|
55
53
|
end
|