owl.rb revision e7b98e9afc1566c16deab31c630a1f272b549f1d
1516N/Amodule ParsingCallback::OWL
3N/A
3N/A IDENTIFIERS = %w(OWL OWL2)
3N/A
3N/A def self.defined_for?(logic_name)
3N/A IDENTIFIERS.include?(logic_name)
3N/A end
3N/A
3N/A class Callback < ParsingCallback::GenericCallback
3N/A
3N/A def pre_axiom(hash)
3N/A if is_annotation_sentence?(hash)
3N/A m = hash['text'].match(%r{
3N/A Class:\s+(?<entity_name><[^;]+>) # Entity/Symbol Identifier
3N/A \s+
3N/A Annotations:\s+(?<annotation_type>label|comment) # the type of annotation
3N/A \s+
3N/A "(?<annotation>.*)" # The actual annotation
3N/A \s*
3N/A (?<additionals>[^\s].*) # optional, e.g. a language tag like @pt}xm)
3N/A if m
3N/A entity = Entity.where(name: m['entity_name']).first
3N/A case m['annotation_type']
2199N/A when 'label'
3N/A entity.label = m['annotation']
3N/A when 'comment'
852N/A entity.comment = m['annotation']
59N/A end if entity
59N/A entity.save
1698N/A end
3N/A false
30N/A else
175N/A true
30N/A end
30N/A end
30N/A
30N/A def axiom(hash, axiom)
30N/A end
30N/A
30N/A def ontology_end(hash, ontology)
30N/A begin
30N/A TarjanTree.for(ontology)
30N/A rescue ActiveRecord::RecordNotFound => e
30N/A Rails.logger.warn "Could not create entity tree for: #{ontology.name} (#{ontology.id}) caused #{e}"
933N/A end
933N/A end
933N/A
416N/A private
933N/A def is_annotation_sentence?(axiom_hash)
933N/A axiom_hash['symbol_hashes'].each do |hash|
3N/A return true if hash['kind'] == 'AnnotationProperty'
933N/A end
933N/A false
852N/A end
416N/A
3N/A end
3N/A
3N/Aend
3N/A