7161N/A# This model is namespaced in the module OntologyMember because the class
7161N/A# Symbol is already taken by ruby.
7161N/Amodule OntologyMember
7161N/A class Symbol < LocIdBaseModel
7161N/A include Metadatable
7161N/A include Symbol::Searching
7161N/A include Symbol::Readability
7161N/A
7161N/A belongs_to :ontology
7161N/A belongs_to :symbol_group
7161N/A has_and_belongs_to_many :sentences
7161N/A has_and_belongs_to_many :oops_responses
7161N/A
7161N/A # associations for SineAxiomSelection
7161N/A has_one :sine_symbol_commonness, class_name: SineSymbolCommonness,
dependent: :destroy
has_many :sine_symbol_axiom_triggers, dependent: :destroy
attr_accessible :label, :comment
scope :kind, ->(kind) { where kind: kind }
def self.find_with_locid(locid, _iri = nil)
LocId.where(locid: locid).first.try(:specific)
end
def self.groups_by_kind
groups = select('kind, count(*) AS count').group(:kind).
order('count DESC, kind').all
groups << Struct.new(:kind, :count).new('Symbol', 0) if groups.empty?
groups
end
def to_s
display_name || name
end
def generate_locid_string
sep = '//'
locid_portion =
if name.include?('://')
Rack::Utils.escape_path(name)
else
name
end
"#{ontology.locid}#{sep}#{locid_portion}"
end
end
end