19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/simple_bioc/pub_ann_writer.rb', line 19
def write_document(json, document, options)
json.sourceid document.id
json.sourcedb options[:sourcedb] || ""
json.project options[:project] || ""
json.target options[:target] || ""
json.text document.all_texts
json.denotations document.all_annotations do |a|
a.locations.each do |l|
json.span do
json.begin l.offset.to_i
json.end l.offset.to_i + l.length.to_i
end
json.obj a.infons.map{|k,v| v}.join(",")
json.id a.id unless a.id.nil?
end
end
json.relations document.all_relations do |r|
json.pred r.infons.map{|k,v| v}.join(",")
first = true
r.nodes.each do |n|
if first
json.obj n.refid
first = false
else
json.subj n.refid
end
end
json.id r.id unless r.id.nil?
end
end
|