Cross Reference: categories.rb
xref
: /
ontohub
/
app
/
models
/
ontology
/
categories.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
categories.rb revision ee535131d1affd87e4c1733317557eabab69d9f5
1057
N/A
module
Ontology
::
Categories
1057
N/A
extend
ActiveSupport
::
Concern
1057
N/A
1057
N/A
included
do
1589
N/A
has_and_belongs_to_many
:
categories
1057
N/A
attr_accessible
:
parent_id
660
N/A
end
1057
N/A
1057
N/A
1057
N/A
def
create_categories
1057
N/A
if
self.logic.name
!=
'OWL2'
then
1057
N/A
raise
Exception.new
(
'Error: No OWL2'
)
1057
N/A
end
1057
N/A
classes
=
self.entities.select
{ |e|
e.kind
==
'Class'
}
1057
N/A
subclasses
=
self.sentences.select
{ |e|
e.text.include
?
(
'SubClassOf'
)
}
1057
N/A
classes.each
do
|c|
1057
N/A
Category.create
(:
name
=>
c.display
_name
||
c.name
)
1057
N/A
end
1057
N/A
1057
N/A
subclasses.each
do
|s|
660
N/A
c1
,
c2
=
s.extract
_class_names
3311
N/A
child
=
Category.find
_by_name
(
c1
)
1109
N/A
child.parent
=
Category.find
_by_name
(
c2
)
2506
N/A
child.save
!
2737
N/A
end
2737
N/A
end
2737
N/A
2437
N/A
end
2437
N/A