Closed fosterlynn closed 2 years ago
You could try to load the RDF file in a triple store (or some other libraries) and run a SPARQL query to get those results.
This query might still work or at least give you a start for that.
Thanx both! Indeed, Sirko's solution seems like a good solution. The query should indeed still work. Please let us know, Lynn, if this is working for you.
Thanks both! I will let you know! Small learning curve on my side first, but I will get there shortly. :)
Hello again. Sirko's query worked well, and I got my list of units. I added to the script to get the class/type, and include all the subclasses of Unit. Then for me as a SPARQL newbie, I did some manual manipulation for our purposes.
Here is what I used, in case it is useful to you.
Again, many thanks for your prompt help!
PREFIX om: <http://www.ontology-of-units-of-measure.org/resource/om-2/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT
?unit
?label
?labelLang
?symbol
?type
?definition
WHERE {
{ ?unit a om:Unit }
UNION { ?unit a om:PrefixedUnit }
UNION { ?unit a om:UnitMultiple }
UNION { ?unit a om:SingularUnit }
UNION { ?unit a om:CompoundUnit }
UNION { ?unit a om:LengthUnit }
UNION { ?unit a om:AreaUnit }
UNION { ?unit a om:VolumeUnit }
UNION { ?unit a om:AngleUnit }
UNION { ?unit a om:SolidAngleUnit }
UNION { ?unit a om:TimeUnit }
UNION { ?unit a om:MassUnit }
UNION { ?unit a om:QuantityOfDimensionOneUnit }
UNION { ?unit a om:NumberUnit }
UNION { ?unit a om:RatioUnit }
UNION { ?unit a om:PercentageUnit }
UNION { ?unit a om:MassFractionUnit }
UNION { ?unit a om:AreaFractionUnit }
UNION { ?unit a om:VolumeFractionUnit }
UNION { ?unit a om:RelativeHumidityUnit }
UNION { ?unit a om:FrequencyUnit }
UNION { ?unit a om:NumberDensityUnit }
UNION { ?unit a om:WavenumberUnit }
UNION { ?unit a om:AccelerationUnit }
UNION { ?unit a om:DensityUnit }
UNION { ?unit a om:SpecificVolumeUnit }
UNION { ?unit a om:SpeedUnit }
UNION { ?unit a om:ForceUnit }
UNION { ?unit a om:PressureUnit }
UNION { ?unit a om:StressUnit }
UNION { ?unit a om:TorqueUnit }
UNION { ?unit a om:MomentOfForceUnit }
UNION { ?unit a om:EnergyUnit }
UNION { ?unit a om:PowerUnit }
UNION { ?unit a om:SpecificEnergyUnit }
UNION { ?unit a om:AngularSpeedUnit }
UNION { ?unit a om:AngularAccelerationUnit }
UNION { ?unit a om:DynamicViscosityUnit }
UNION { ?unit a om:KinematicViscosityUnit }
UNION { ?unit a om:PowerDensityUnit }
UNION { ?unit a om:RadiantIntensityUnit }
UNION { ?unit a om:RadianceUnit }
UNION { ?unit a om:EnergyDensityUnit }
UNION { ?unit a om:ActionUnit }
UNION { ?unit a om:AngularMomentumUnit }
UNION { ?unit a om:FluidityUnit }
UNION { ?unit a om:MomentumUnit }
UNION { ?unit a om:MomentOfInertiaUnit }
UNION { ?unit a om:ShearRateUnit }
UNION { ?unit a om:SurfaceTensionUnit }
UNION { ?unit a om:VolumetricFlowRateUnit }
UNION { ?unit a om:DetectivityUnit }
UNION { ?unit a om:MassFlowUnit }
UNION { ?unit a om:AreaDensityUnit }
UNION { ?unit a om:AreaDensityRateUnit }
UNION { ?unit a om:ColumnNumberDensityUnit }
UNION { ?unit a om:ThermalDiffusivityUnit }
UNION { ?unit a om:TemperatureUnit }
UNION { ?unit a om:EntropyUnit }
UNION { ?unit a om:HeatCapacityUnit }
UNION { ?unit a om:SpecificEntropyUnit }
UNION { ?unit a om:SpecificHeatCapacityUnit }
UNION { ?unit a om:ThermalConductivityUnit }
UNION { ?unit a om:ThermalResistanceUnit }
UNION { ?unit a om:HeatTransferCoefficientUnit }
UNION { ?unit a om:TemperatureRateUnit }
UNION { ?unit a om:VolumetricHeatCapacityUnit }
UNION { ?unit a om:ElectricCurrentUnit }
UNION { ?unit a om:MagnetomotiveForceUnit }
UNION { ?unit a om:CurrentDensityUnit }
UNION { ?unit a om:ElectricChargeUnit }
UNION { ?unit a om:ElectricPotentialUnit }
UNION { ?unit a om:CapacitanceUnit }
UNION { ?unit a om:ElectricalResistanceUnit }
UNION { ?unit a om:ElectricalConductanceUnit }
UNION { ?unit a om:ElectricFieldUnit }
UNION { ?unit a om:ElectricChargeDensityUnit }
UNION { ?unit a om:ElectricFluxDensityUnit }
UNION { ?unit a om:MagneticFluxUnit }
UNION { ?unit a om:MagneticFieldUnit }
UNION { ?unit a om:MagneticFluxDensityUnit }
UNION { ?unit a om:InductanceUnit }
UNION { ?unit a om:Permeance-ElectromagneticUnit }
UNION { ?unit a om:PermeabilityOfFreeSpaceUnit }
UNION { ?unit a om:PermittivityUnit }
UNION { ?unit a om:ElectricDipoleMomentUnit }
UNION { ?unit a om:ReluctanceUnit }
UNION { ?unit a om:ElectricalResistivityUnit }
UNION { ?unit a om:ElectricalConductivityUnit }
UNION { ?unit a om:StrainUnit }
UNION { ?unit a om:AlfvenNumberUnit }
UNION { ?unit a om:CowlingNumberUnit }
UNION { ?unit a om:EulerNumberUnit }
UNION { ?unit a om:FirstCowlingNumberUnit }
UNION { ?unit a om:FourierNumberUnit }
UNION { ?unit a om:FourierNumberForMassTransferUnit }
UNION { ?unit a om:FroudeNumberUnit }
UNION { ?unit a om:GrashofNumberUnit }
UNION { ?unit a om:GrashofNumberForMassTransferUnit }
UNION { ?unit a om:HartmannNumberUnit }
UNION { ?unit a om:KnudsenNumberUnit }
UNION { ?unit a om:LewisNumberUnit }
UNION { ?unit a om:MachNumberUnit }
UNION { ?unit a om:MagneticReynoldsNumberUnit }
UNION { ?unit a om:NusseltNumberUnit }
UNION { ?unit a om:NusseltNumberForMassTransferUnit }
UNION { ?unit a om:PecletNumberUnit }
UNION { ?unit a om:PecletNumberForMassTransferUnit }
UNION { ?unit a om:PrandtlNumberUnit }
UNION { ?unit a om:RayleighNumberUnit }
UNION { ?unit a om:ReynoldsNumberUnit }
UNION { ?unit a om:SchmidtNumberUnit }
UNION { ?unit a om:StantonNumberUnit }
UNION { ?unit a om:StantonNumberForMassTransferUnit }
UNION { ?unit a om:StrouhalNumberUnit }
UNION { ?unit a om:WeberNumberUnit }
UNION { ?unit a om:AmountOfSubstanceUnit }
UNION { ?unit a om:AmountOfSubstanceConcentrationUnit }
UNION { ?unit a om:AmountOfSubstanceFractionUnit }
UNION { ?unit a om:MolarEnergyUnit }
UNION { ?unit a om:MolarEntropyUnit }
UNION { ?unit a om:MolarHeatCapacityUnit }
UNION { ?unit a om:GasConstantUnit }
UNION { ?unit a om:MolalityUnit }
UNION { ?unit a om:MolarMassUnit }
UNION { ?unit a om:MolarVolumeUnit }
UNION { ?unit a om:AmountOfSubstanceFlowUnit }
UNION { ?unit a om:CatalyticActivityUnit }
UNION { ?unit a om:CatalyticActivityConcentrationUnit }
UNION { ?unit a om:SpecificCatalyticActivityUnit }
UNION { ?unit a om:LuminousIntensityUnit }
UNION { ?unit a om:LuminanceUnit }
UNION { ?unit a om:LuminousEnergyUnit }
UNION { ?unit a om:LuminousFluxUnit }
UNION { ?unit a om:IlluminanceUnit }
UNION { ?unit a om:ExposureUnit }
UNION { ?unit a om:LuminousEfficacyUnit }
UNION { ?unit a om:AbsorbedDoseUnit }
UNION { ?unit a om:DoseEquivalentUnit }
UNION { ?unit a om:ActivityUnit }
UNION { ?unit a om:ExposureToXAndGammaRaysUnit }
UNION { ?unit a om:AbsorbedDoseRateUnit }
UNION { ?unit a om:DynamicRangeUnit }
UNION { ?unit a om:QuantumEfficiencyUnit }
UNION { ?unit a om:MagnitudeUnit }
UNION { ?unit a om:ResponsivityUnit }
UNION { ?unit a om:CurvatureConstantUnit }
UNION { ?unit a om:DecelerationParameterUnit }
UNION { ?unit a om:DensityParameterUnit }
UNION { ?unit a om:HubbleConstantUnit }
UNION { ?unit a om:Permeability-EarthScienceUnit }
UNION { ?unit a om:MaterialsScienceUnit }
UNION { ?unit a om:ViableCountUnit }
UNION { ?unit a om:VolumetricViableCountUnit }
UNION { ?unit a om:SpecificViableCountUnit }
UNION { ?unit a om:AmountOfMoneyUnit }
UNION { ?unit a om:SpecificAmountOfMoneyUnit }
UNION { ?unit a om:InformationCapacityUnit }
UNION { ?unit a om:SymbolRateUnit }
UNION { ?unit a om:PixelCountUnit }
UNION { ?unit a om:FontSizeUnit }
UNION { ?unit a om:UnitDivision }
UNION { ?unit a om:GramPerPrefixedLitre }
UNION { ?unit a om:MetrePerPrefixedSecond-Time }
UNION { ?unit a om:MetrePerPrefixedSecond-TimeSquared }
UNION { ?unit a om:MolePerPrefixedLitre }
UNION { ?unit a om:MolePerPrefixedMetre }
UNION { ?unit a om:PrefixedGramPerLitre }
UNION { ?unit a om:PrefixedGramPerPrefixedLitre }
UNION { ?unit a om:PrefixedMetrePerPrefixedSecond-TimeSquared }
UNION { ?unit a om:PrefixedMetrePerPrefixedSecond-TimeSquared }
UNION { ?unit a om:PrefixedMetrePerPrefixedSecond-Time }
UNION { ?unit a om:PrefixedMetrePerSecond-Time }
UNION { ?unit a om:PrefixedMetrePerSecond-TimeSquared }
UNION { ?unit a om:PrefixedMolePerLitre }
UNION { ?unit a om:PrefixedMolePerMetre }
UNION { ?unit a om:PrefixedMolePerPrefixedLitre }
UNION { ?unit a om:PrefixedMolePerPrefixedMetre }
UNION { ?unit a om:SquarePrefixedMetre }
UNION { ?unit a om:PrefixedSecond-TimeSquared }
UNION { ?unit a om:CubicPrefixedMetre }
UNION { ?unit a om:SquarePrefixedMetre }
UNION { ?unit a om:UnitMultiplication }
UNION { ?unit a om:PrefixedMetrePrefixedGram }
UNION { ?unit a om:UnitExponentiation }
UNION { ?unit a om:CelsiusTemperatureUnit }
UNION { ?unit a om:FahrenheitTemperatureUnit }
UNION { ?unit a om:RankineTemperatureUnit }
UNION { ?unit a om:ReaumurTemperatureUnit }
UNION { ?unit a om:ThermodynamicTemperatureUnit }
UNION { ?unit a om:PrefixedAmpere }
UNION { ?unit a om:PrefixedAre }
UNION { ?unit a om:PrefixedBecquerel }
UNION { ?unit a om:PrefixedBit }
UNION { ?unit a om:PrefixedByte }
UNION { ?unit a om:PrefixedCalorie-Mean }
UNION { ?unit a om:PrefixedCandela }
UNION { ?unit a om:PrefixedCoulomb }
UNION { ?unit a om:PrefixedDegreeCelsius }
UNION { ?unit a om:PrefixedElectronvolt }
UNION { ?unit a om:PrefixedFarad }
UNION { ?unit a om:PrefixedGram }
UNION { ?unit a om:PrefixedGray }
UNION { ?unit a om:PrefixedHenry }
UNION { ?unit a om:PrefixedHertz }
UNION { ?unit a om:PrefixedJoule }
UNION { ?unit a om:PrefixedKatal }
UNION { ?unit a om:PrefixedKelvin }
UNION { ?unit a om:PrefixedLitre }
UNION { ?unit a om:PrefixedLumen }
UNION { ?unit a om:PrefixedLux }
UNION { ?unit a om:PrefixedMetre }
UNION { ?unit a om:PrefixedMolair }
UNION { ?unit a om:PrefixedMole }
UNION { ?unit a om:PrefixedNewton }
UNION { ?unit a om:PrefixedOhm }
UNION { ?unit a om:PrefixedPascal }
UNION { ?unit a om:PrefixedPoise }
UNION { ?unit a om:PrefixedRadian }
UNION { ?unit a om:PrefixedSecond-Time }
UNION { ?unit a om:PrefixedSiemens }
UNION { ?unit a om:PrefixedSievert }
UNION { ?unit a om:PrefixedSteradian }
UNION { ?unit a om:PrefixedStokes }
UNION { ?unit a om:PrefixedTesla }
UNION { ?unit a om:PrefixedTonne }
UNION { ?unit a om:PrefixedUnifiedAtomicMassUnit }
UNION { ?unit a om:PrefixedVolt }
UNION { ?unit a om:PrefixedWatt }
UNION { ?unit a om:PrefixedWeber }
OPTIONAL {
?unit rdfs:label ?label
BIND( LANG(?label) AS ?labelLang )
}
OPTIONAL { ?unit om:symbol ?symbol }
OPTIONAL { ?unit rdfs:comment ?definition }
OPTIONAL { ?unit rdf:type ?type }
}
Hi Lynn, Glad this works, and happy to have helped! One question, if you allow me: I see you have a large WHERE clause, referring to all subclasses of om:Unit. Is that necessary because you have added the rdf:type of the units in your SELECT? Cheers, Hajo
One question, if you allow me: I see you have a large WHERE clause, referring to all subclasses of om:Unit. Is that necessary because you have added the rdf:type of the units in your SELECT?
No, it wasn't because of the rdf:type addition. In the original query, I was only getting back units that were type Unit, it wasn't smart enough to automatically bring back units of Unit's subclasses. (There might be more elegant ways to do what I did, but that worked.) In some cases, the units were associated to more than one type, so of course I got duplicate rows, but I just got rid of those manually from the result set.
Clear, thanx! :)
In some cases, the units were associated to more than one type, so of course I got duplicate rows, but I just got rid of those manually from the result set.
Then I guess the DISTINCT didn't work that well either. :/
Then I guess the DISTINCT didn't work that well either. :/
Right, they weren't distinct because it was making records out of triples. I got a row for each language too. And each language/type combination. :)
Wow, that's a lot of rows! ;)
I'm looking for a list of units (including Unit, PrefixedUnit, UnitExponentiation, etc.), in any standard data format, so that our different user groups can pick a much smaller selection of the units they want to have for their specific application, and we can load them into their instance. We basically need class name, a label, and a symbol, plus any useful categorization
I've looked around here, and briefly checked out the python conversion app, neither of which seemed like it could easily provide such a list. Now I am manually going through the raw git file here, which will give me what I want, but is taking quite a while.
Is there something I missed? (Apologies if so!) I would very much appreciate any help you can give.
If I am doing it the only or best way, then I'm happy to do it and return to you a list of units when I am done.