tao_rdfizer 0.9.13 → 0.10
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/tao_rdfizer/tao_rdfizer.rb +19 -7
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2f897b03c9e6856aaf752fd645808c47e6d52422ea1b6934b44b694d8d0d9a1
|
4
|
+
data.tar.gz: 8d9fb426258bf3fceabb6471a81fcaeb99cd18dcace251575a0f2f715fa4d787
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0d230f25945bf45aed05f8f0cb3d46113d5eb4213b17ce4812cbfbcfa5636d540343b8ee8fe94cf1bbbc1a1eb4db35ac076bf1d7cd3cb7abdd92db446c94f41
|
7
|
+
data.tar.gz: 6f00c1aeb735b8e76da2e9185ad141c0c29c1d45d94faad1b3d89ec903a1c931e22957f4f356dce24ff6beadd53a77ac7fcd5aad2c17cb281a5d0128cd062b89
|
@@ -35,6 +35,7 @@ class TAO::RDFizer
|
|
35
35
|
end
|
36
36
|
|
37
37
|
denotations = []
|
38
|
+
attributes = []
|
38
39
|
relations = []
|
39
40
|
spans = []
|
40
41
|
|
@@ -47,25 +48,36 @@ class TAO::RDFizer
|
|
47
48
|
end
|
48
49
|
|
49
50
|
# denotations and relations
|
50
|
-
_denotations = annotations[:denotations]
|
51
|
-
|
52
|
-
|
53
|
-
_relations = [] if _relations.nil?
|
51
|
+
_denotations = annotations[:denotations] || []
|
52
|
+
_attributes = annotations[:attributes] || []
|
53
|
+
_relations = annotations[:relations] || []
|
54
54
|
if @mode == :spans && annotations.has_key?(:tracks)
|
55
55
|
annotations[:tracks].each do |track|
|
56
56
|
_denotations += track[:denotations]
|
57
|
+
_attributes += track[:attributes]
|
57
58
|
_relations += track[:relations]
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
61
62
|
begin
|
62
63
|
if @mode == :annotations
|
64
|
+
# index attributes
|
65
|
+
attributesh = _attributes.inject({}) do |h, a|
|
66
|
+
if a[:pred].end_with?('_id')
|
67
|
+
subj = a[:subj]
|
68
|
+
h[subj] = [] unless h.has_key? subj
|
69
|
+
h[subj] << a[:obj]
|
70
|
+
end
|
71
|
+
h
|
72
|
+
end
|
73
|
+
|
63
74
|
# denotations preprocessing
|
64
75
|
_denotations.each do |d|
|
65
76
|
span_uri = "<#{text_uri}/spans/#{d[:span][:begin]}-#{d[:span][:end]}>"
|
66
77
|
d[:span_uri] = span_uri
|
67
78
|
d[:obj_uri] = "#{prefix_for_this}:#{text_id}-#{d[:id]}"
|
68
|
-
d[:
|
79
|
+
class_uris = attributesh[d[:id]].push(d[:obj])
|
80
|
+
d[:class_uris] = class_uris.map{|uri| find_uri(uri, namespaces, prefix_for_this)}
|
69
81
|
rescue ArgumentError => e
|
70
82
|
raise ArgumentError, "[#{sourcedb}-#{sourceid}-#{d[:id]}] " + e.message
|
71
83
|
end
|
@@ -101,7 +113,7 @@ class TAO::RDFizer
|
|
101
113
|
s[:text] = text[s[:begin] ... s[:end]]
|
102
114
|
end
|
103
115
|
|
104
|
-
# index
|
116
|
+
# index spans
|
105
117
|
spanh = _spans.inject({}){|r, s| r[s[:span_uri]] = s; r}
|
106
118
|
|
107
119
|
# add denotation information
|
@@ -194,7 +206,7 @@ class TAO::RDFizer
|
|
194
206
|
ERB_ANNOTATIONS_TTL = <<~HEREDOC
|
195
207
|
<% denotations.each do |d| -%>
|
196
208
|
<%= d[:obj_uri] %> tao:denoted_by <%= d[:span_uri] %> ;
|
197
|
-
|
209
|
+
<%= d[:class_uris].map{|c| "\trdf:type " + c}.join(" ;\n") + " ." %>
|
198
210
|
<% end -%>
|
199
211
|
<%# relations -%>
|
200
212
|
<% relations.each do |r| -%>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tao_rdfizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.10'
|
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: 2020-
|
11
|
+
date: 2020-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: It uses TAO (text annotation ontology) for representation of annotations
|
14
14
|
to text.
|
@@ -40,8 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
requirements: []
|
43
|
-
|
44
|
-
rubygems_version: 2.7.9
|
43
|
+
rubygems_version: 3.0.8
|
45
44
|
signing_key:
|
46
45
|
specification_version: 4
|
47
46
|
summary: A RDF statement generator for annotations in the PubAnnotation JSON format.
|