Skip to content

Commit

Permalink
Update QUDT and add unit parsing (#101)
Browse files Browse the repository at this point in the history
- Add `Unit.altSymbols`
- Add `Qudt.parseUnit()`
- Add unit index structures in `Qudt` to improve performance of unit searches and factor unit matching
- Bump java version in github actions
  • Loading branch information
fkleedorfer authored Dec 11, 2024
1 parent 0dc4e58 commit 00a71eb
Show file tree
Hide file tree
Showing 56 changed files with 35,757 additions and 84,118 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,19 @@ jobs:
# Set up java with maven cache
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'
cache: 'maven'

# import the secret key
- name: Set up Apache Maven Central
uses: actions/setup-java@v3
with: # running setup-java again overwrites the settings.xml
distribution: 'temurin'
java-version: '11'
java-version: '17'
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add `Unit.altSymbols`
- Add `Qudt.parseUnit()`
- Add unit index structures in `Qudt` to improve performance of unit searches and factor unit matching

### Changed

- Bump QUDT version to [2.1.46](https://github.com/qudt/qudt-public-repo/releases/tag/v2.1.46)

## [6.7.0] - 2024-04-04

### Changed
Expand Down
41 changes: 27 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@


<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<qudt.release.version>v2.1.37</qudt.release.version>
<spotless.format.version>1.9</spotless.format.version>
<qudt.release.version>2.1.46</qudt.release.version>
<spotless.format.version>1.25.0</spotless.format.version>
</properties>

<scm>
Expand Down Expand Up @@ -90,6 +90,11 @@
<artifactId>hamcrest-library</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.5.0-M2</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
Expand Down Expand Up @@ -148,7 +153,7 @@
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.27.2</version>
<version>2.44.0.BETA3</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand Down Expand Up @@ -178,6 +183,23 @@
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<configuration>
<rdf>
<includes>
<include>**/*.ttl</include>
</includes>
<excludes>
<exclude>**/target/**/*.*</exclude>
</excludes>
<format>
<failOnWarning>false</failOnWarning>
<verify>true</verify>
<turtleFormatterVersion>1.2.14</turtleFormatterVersion>
<turtle>
<predicateOrder>rdf:type,owl:imports</predicateOrder>
<firstPredicateInNewLine>true</firstPredicateInNewLine>
</turtle>
</format>
</rdf>
<formats>
<!-- you can define as many formats as you want, each is independent -->
<format>
Expand Down Expand Up @@ -309,15 +331,6 @@
</plugins>
</build>
</profile>
<profile>
<id>jdk17</id>
<activation>
<jdk>17</jdk>
</activation>
<properties>
<spotless.format.version>1.15.0</spotless.format.version>
</properties>
</profile>
</profiles>
<distributionManagement>
<snapshotRepository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ public class DataGenerator {
private static final String CONSTANTS_OUTFILE = "qudt-constants.ttl";

// QUDT files
private static final String UNITS_FILE = "qudt/vocab/unit/VOCAB_QUDT-UNITS-ALL-v2.1.ttl";
private static final String UNITS_FILE = "qudt/vocab/unit/VOCAB_QUDT-UNITS-ALL.ttl";
private static final String CURRENCIES_FILE =
"qudt/vocab/currency/VOCAB_QUDT-UNITS-CURRENCY-v2.1.ttl";
private static final String PREFIXES_FILE = "qudt/vocab/prefixes/VOCAB_QUDT-PREFIXES-v2.1.ttl";
"qudt/vocab/currency/VOCAB_QUDT-UNITS-CURRENCY.ttl";
private static final String PREFIXES_FILE = "qudt/vocab/prefixes/VOCAB_QUDT-PREFIXES.ttl";
private static final String QUANTITYKINDS_FILE =
"qudt/vocab/quantitykinds/VOCAB_QUDT-QUANTITY-KINDS-ALL-v2.1.ttl";
"qudt/vocab/quantitykinds/VOCAB_QUDT-QUANTITY-KINDS-ALL.ttl";

private static final String CONSTANTS_FILE =
"qudt/vocab/constants/VOCAB_QUDT-CONSTANTS-v2.1.ttl";
private static final String CONSTANTS_FILE = "qudt/vocab/constants/VOCAB_QUDT-CONSTANTS.ttl";

// queries
private static final String FACTOR_UNITS_QUERY = "factorUnit.rq";
Expand All @@ -52,6 +51,8 @@ public class DataGenerator {

private static final String DELETE_FROM_UNITS_BY_QUERY_PATTERN =
"delete-from-units-by-query[N].rq";
private static final String DELETE_FROM_QUANTITYKINDS_BY_QUERY_PATTERN =
"delete-from-quantitykinds-by-query[N].rq";
// additional data
private static final String SI_BASE_UNITS_DATA = "si-base-units.ttl";
private static final String ADD_TO_UNITS = "add-to-units.ttl";
Expand All @@ -61,7 +62,7 @@ public class DataGenerator {
private static final String UNITS_EXPECTED_DATA = "tmpExpected/qudt-unit.ttl";

private static final String SYSTEM_OF_UNITS_FILE =
"qudt/vocab/systems/VOCAB_QUDT-SYSTEM-OF-UNITS-ALL-v2.1.ttl";
"qudt/vocab/systems/VOCAB_QUDT-SYSTEM-OF-UNITS-ALL.ttl";

private static final String SYSTEM_OF_UNITS_QUERY = "system-of-units.rq";

Expand Down Expand Up @@ -135,9 +136,9 @@ private void processQuantityKinds() {
Repository outputRepo = new SailRepository(new MemoryStore());
try (RepositoryConnection outputCon = outputRepo.getConnection()) {
RdfOps.addStatementsFromFile(outputCon, QUANTITYKINDS_FILE);
// the currencies file contains the qk:Currency definition:
RdfOps.addStatementsFromFile(outputCon, CURRENCIES_FILE);
// remove unwanted individual triples
RdfOps.updateDataUsingNQueries(
outputCon, DELETE_FROM_QUANTITYKINDS_BY_QUERY_PATTERN, 5);
RdfOps.removeStatementsFromFile(outputCon, DELETE_FROM_QUANTITYKINDS);
// add missing triples
RdfOps.addStatementsFromFile(outputCon, ADD_TO_QUANTITYKINDS);
Expand Down
11 changes: 2 additions & 9 deletions qudtlib-data-gen/src/main/resources/add-to-quantitykinds.ttl
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix qudt: <http://qudt.org/schema/qudt/> .
@prefix unit: <http://qudt.org/vocab/unit/> .
@prefix qkdv: <http://qudt.org/vocab/dimensionvector/> .
@prefix quantitykind: <http://qudt.org/vocab/quantitykind/> .
@prefix sou: <http://qudt.org/vocab/sou/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .


8 changes: 2 additions & 6 deletions qudtlib-data-gen/src/main/resources/add-to-units.ttl
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
@prefix qudt: <http://qudt.org/schema/qudt/> .
@prefix unit: <http://qudt.org/vocab/unit/> .
@prefix sou: <http://qudt.org/vocab/sou/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix quantitykind: <http://qudt.org/vocab/quantitykind/> .
@prefix prefix: <http://qudt.org/vocab/prefix/> .


Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PREFIX qudt: <http://qudt.org/schema/qudt/>
PREFIX unit: <http://qudt.org/vocab/unit/>
prefix quantitykind: <http://qudt.org/vocab/quantitykind/>
DELETE { ?qk ?b ?c . ?d ?e ?qk }
WHERE { { ?qk ?b ?c .} union { ?d ?e ?qk }
VALUES ?qk { quantitykind:VaporPermeability }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PREFIX qudt: <http://qudt.org/schema/qudt/>
PREFIX unit: <http://qudt.org/vocab/unit/>
prefix quantitykind: <http://qudt.org/vocab/quantitykind/>
DELETE { ?d ?e ?qk }
WHERE { ?d ?e ?qk
VALUES ?qk { quantitykind:VaporPermeability }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PREFIX qudt: <http://qudt.org/schema/qudt/>
PREFIX unit: <http://qudt.org/vocab/unit/>
prefix quantitykind: <http://qudt.org/vocab/quantitykind/>
DELETE { ?u qudt:symbol ?symb }
INSERT { ?u qudt:symbol ?repl }
WHERE {
?u qudt:symbol ?symb
filter(regex(?symb, "^1/.+"))
BIND (replace(?symb, "^1", "") as ?repl)
}
11 changes: 1 addition & 10 deletions qudtlib-data-gen/src/main/resources/delete-from-units.ttl
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix qudt: <http://qudt.org/schema/qudt/> .
@prefix unit: <http://qudt.org/vocab/unit/> .
@prefix qkdv: <http://qudt.org/vocab/dimensionvector/> .
@prefix qk: <http://qudt.org/vocab/quantitykind/> .
@prefix sou: <http://qudt.org/vocab/sou/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix prefix: <http://qudt.org/vocab/prefix/> .


Loading

0 comments on commit 00a71eb

Please sign in to comment.