module Spread2RDF::Mapping::Cell::Default

Public Class Methods

unit_mapping(value) click to toggle source
# File lib/spread2rdf/mapping/default_cell_mappings.rb, line 5
def self.unit_mapping(value)
  @qudt ||= RDF::Graph.load File.join(ONTOLOGY_DIR, 'unit-v1.1.ttl')
  query = RDF::Query.new(
      unit: { RDF::URI.new('http://qudt.org/schema/qudt#symbol') =>
                RDF::Literal.new(value, datatype: RDF::XSD.string) })
  solutions = query.execute(@qudt)
  raise "unit #{value} is not unique; possible candidates:
            #{solutions.map(&:unit).ai}" if solutions.count > 1
  raise "couldn't find a QUDT unit for unit '#{value}''" if solutions.empty?
  solutions.first.unit
end
uri_normalization(string) click to toggle source
# File lib/spread2rdf/mapping/default_cell_mappings.rb, line 17
def self.uri_normalization(string)
  string
    .gsub(' - ', '-')
    .gsub('- ', '-')
    .gsub(', ', '-')
    .gsub(' ', '_')
end