Class: Unitsdb::Commands::Qudt::TtlParser
- Inherits:
-
Object
- Object
- Unitsdb::Commands::Qudt::TtlParser
- Defined in:
- lib/unitsdb/commands/qudt/ttl_parser.rb
Constant Summary collapse
- QUDT_VOCABULARIES =
QUDT 3.1.2 vocabulary URLs
{ units: "http://qudt.org/3.1.2/vocab/unit", quantitykinds: "http://qudt.org/3.1.2/vocab/quantitykind", dimensionvectors: "http://qudt.org/3.1.2/vocab/dimensionvector", sou: "http://qudt.org/3.1.2/vocab/sou", prefixes: "http://qudt.org/3.1.2/vocab/prefix", }.freeze
- QUDT_PREDICATES =
QUDT predicates
{ label: RDF::URI("http://www.w3.org/2000/01/rdf-schema#label"), symbol: RDF::URI("http://qudt.org/schema/qudt/symbol"), has_quantity_kind: RDF::URI("http://qudt.org/schema/qudt/hasQuantityKind"), has_dimension_vector: RDF::URI("http://qudt.org/schema/qudt/hasDimensionVector"), conversion_multiplier: RDF::URI("http://qudt.org/schema/qudt/conversionMultiplier"), conversion_offset: RDF::URI("http://qudt.org/schema/qudt/conversionOffset"), description: RDF::URI("http://purl.org/dc/elements/1.1/description"), abbreviation: RDF::URI("http://qudt.org/schema/qudt/abbreviation"), si_exact_match: RDF::URI("http://qudt.org/schema/qudt/siExactMatch"), dimension_exponent_for_length: RDF::URI("http://qudt.org/schema/qudt/dimensionExponentForLength"), dimension_exponent_for_mass: RDF::URI("http://qudt.org/schema/qudt/dimensionExponentForMass"), dimension_exponent_for_time: RDF::URI("http://qudt.org/schema/qudt/dimensionExponentForTime"), dimension_exponent_for_electric_current: RDF::URI("http://qudt.org/schema/qudt/dimensionExponentForElectricCurrent"), dimension_exponent_for_thermodynamic_temperature: RDF::URI("http://qudt.org/schema/qudt/dimensionExponentForThermodynamicTemperature"), dimension_exponent_for_amount_of_substance: RDF::URI("http://qudt.org/schema/qudt/dimensionExponentForAmountOfSubstance"), dimension_exponent_for_luminous_intensity: RDF::URI("http://qudt.org/schema/qudt/dimensionExponentForLuminousIntensity"), prefix_multiplier: RDF::URI("http://qudt.org/schema/qudt/prefixMultiplier"), prefix_multiplier_sn: RDF::URI("http://qudt.org/schema/qudt/prefixMultiplierSN"), ucum_code: RDF::URI("http://qudt.org/schema/qudt/ucumCode"), rdf_type: RDF::URI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), dc_description: RDF::URI("http://purl.org/dc/terms/description"), }.freeze
Class Method Summary collapse
-
.get_entities_from_qudt(entity_type, vocabularies) ⇒ Object
Get entities from vocabularies by type.
-
.parse_qudt_vocabularies(source_type: :url, ttl_dir: nil) ⇒ Object
Parse QUDT vocabularies from TTL files or URLs.
Class Method Details
.get_entities_from_qudt(entity_type, vocabularies) ⇒ Object
Get entities from vocabularies by type
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/unitsdb/commands/qudt/ttl_parser.rb', line 84 def get_entities_from_qudt(entity_type, vocabularies) case entity_type when "units" vocabularies.units when "quantities" vocabularies.quantity_kinds when "dimensions" vocabularies.dimension_vectors when "unit_systems" vocabularies.systems_of_units when "prefixes" vocabularies.prefixes else [] end end |
.parse_qudt_vocabularies(source_type: :url, ttl_dir: nil) ⇒ Object
Parse QUDT vocabularies from TTL files or URLs
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/unitsdb/commands/qudt/ttl_parser.rb', line 49 def parse_qudt_vocabularies(source_type: :url, ttl_dir: nil) vocabularies = QudtVocabularies.new QUDT_VOCABULARIES.each do |vocab_type, url| puts "Parsing #{vocab_type} vocabulary..." ttl_content = if source_type == :file && ttl_dir read_ttl_file(ttl_dir, vocab_type) else download_ttl_content(url) end graph = parse_ttl_content(ttl_content) entities = extract_entities(graph, vocab_type, url) case vocab_type when :units vocabularies.units = entities when :quantitykinds vocabularies.quantity_kinds = entities when :dimensionvectors vocabularies.dimension_vectors = entities when :sou vocabularies.systems_of_units = entities when :prefixes vocabularies.prefixes = entities end puts "Found #{entities.size} #{vocab_type}" end vocabularies end |