dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa result << superclass
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa result += superclasses(superclass)
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa def direct_superclasses(cls)
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa check_logic_is_owl
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa sentences.where('text LIKE ?', "Class: #{cls}%SubClassOf:%").
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa each do |sentence|
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa match = sentence.text.match(/SubClassOf: (?<superclass>\w+)\z/)
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa result << match[:superclass] if match
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa def subclasses(cls)
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa check_logic_is_owl
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa direct_subclasses(cls).each do |subclass|
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa result << subclass
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa result += subclasses(subclass)
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa def direct_subclasses(cls)
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa check_logic_is_owl
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa sentences.where('text LIKE ?', "Class: %SubClassOf: #{cls}").
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa each do |sentence|
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa match = sentence.text.match(/^Class: (?<subclass>\w+)/)
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa result << match[:subclass] if match
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa def check_logic_is_owl
dca00e3e210f3a3f814c63511f426128b1f3308cEugen Kuksa raise WrongLogicError('Expected OWL') unless logic.name.start_with?('OWL')