Module: Spread2RDF::Mapping::Cell::Default

Defined in:
lib/spread2rdf/mapping/default_cell_mappings.rb

Class Method Summary collapse

Class Method Details

.unit_mapping(value) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# 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) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/spread2rdf/mapping/default_cell_mappings.rb', line 17

def self.uri_normalization(string)
  string
    .gsub(' - ', '-')
    .gsub('- ', '-')
    .gsub(', ', '-')
    .gsub(' ', '_')
end