Cross Reference: owl.rb
xref
: /
ontohub
/
lib
/
parsing_callback
/
owl.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
owl.rb revision 151a86e6ccf772e932db2a15868dc1d96d9bb345
1516
N/A
module
ParsingCallback
::
OWL
49
N/A
49
N/A
IDENTIFIERS
= %w
(
OWL
OWL2
)
49
N/A
49
N/A
def
self.defined
_for
?
(
logic_name
)
49
N/A
IDENTIFIERS.include
?
(
logic_name
)
49
N/A
end
49
N/A
49
N/A
class
Callback
<
ParsingCallback
::
GenericCallback
49
N/A
49
N/A
def
pre_axiom
(
hash
)
49
N/A
if
is_annotation_sentence
?
(
hash
)
49
N/A
m =
hash
[
'text'
].
match
(%r
{
49
N/A
Class
:\s+
(?<
symbol_name
>.+?)
# Symbol Identifier
49
N/A
\s+
49
N/A
Annotations
:\s+
(?<
annotation_type
>
label
|
comment
)
# the type of annotation
49
N/A
\s+
49
N/A
"(?<annotation>.*)"
# The actual annotation
49
N/A
\s*
49
N/A
(?<
additionals
>[^\s].*)
# optional,
e.g
. a language tag like @pt}xm)
49
N/A
if
m
49
N/A
symbol
=
Symbol.where
(
name
: m[
'symbol_name'
])
.
first
2205
N/A
case
m[
'annotation_type'
]
3047
N/A
when
'label'
2205
N/A
symbol.label
= m[
'annotation'
]
49
N/A
symbol.save
49
N/A
when
'comment'
49
N/A
symbol.comment
= m[
'annotation'
]
49
N/A
symbol.save
49
N/A
end
if
symbol
49
N/A
end
1859
N/A
false
1859
N/A
else
51
N/A
true
289
N/A
end
941
N/A
end
1859
N/A
1859
N/A
def
axiom
(
hash
,
axiom
)
49
N/A
end
49
N/A
49
N/A
def
ontology_end
(
hash
,
ontology
)
49
N/A
begin
1846
N/A
TarjanTree.for
(
ontology
)
1846
N/A
rescue
ActiveRecord
::
RecordNotFound
=> e
51
N/A
Rails.logger.warn
"Could not create symbol tree for: #{
ontology.name
} (#{
ontology.id
}) caused #{e}"
72
N/A
end
2205
N/A
end
2205
N/A
2205
N/A
private
2205
N/A
def
is_annotation_sentence
?
(
axiom_hash
)
2639
N/A
axiom_hash
[
'symbol_hashes'
].
each
do
|
hash
|
51
N/A
return
true
if
hash
[
'kind'
] ==
'AnnotationProperty'
307
N/A
end
307
N/A
false
307
N/A
end
2205
N/A
2205
N/A
end
2205
N/A
2205
N/A
end
2205
N/A