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