Skip to content

Commit 00a71eb

Browse files
authored
Update QUDT and add unit parsing (#101)
- 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
1 parent 0dc4e58 commit 00a71eb

File tree

56 files changed

+35757
-84118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+35757
-84118
lines changed

.github/workflows/maven.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616

1717
steps:
1818
- uses: actions/checkout@v3
19-
- name: Set up JDK 11
19+
- name: Set up JDK 17
2020
uses: actions/setup-java@v3
2121
with:
22-
java-version: '11'
22+
java-version: '17'
2323
distribution: 'temurin'
2424
cache: maven
2525
- name: Build with Maven

.github/workflows/release-and-deploy.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,19 @@ jobs:
6868
6969
# Set up java with maven cache
7070
- uses: actions/checkout@v3
71-
- name: Set up JDK 11
71+
- name: Set up JDK 17
7272
uses: actions/setup-java@v3
7373
with:
7474
distribution: 'temurin'
75-
java-version: '11'
75+
java-version: '17'
7676
cache: 'maven'
7777

7878
# import the secret key
7979
- name: Set up Apache Maven Central
8080
uses: actions/setup-java@v3
8181
with: # running setup-java again overwrites the settings.xml
8282
distribution: 'temurin'
83-
java-version: '11'
83+
java-version: '17'
8484
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
8585
server-username: MAVEN_USERNAME # env variable for username in deploy
8686
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add `Unit.altSymbols`
13+
- Add `Qudt.parseUnit()`
14+
- Add unit index structures in `Qudt` to improve performance of unit searches and factor unit matching
15+
16+
### Changed
17+
18+
- Bump QUDT version to [2.1.46](https://github.com/qudt/qudt-public-repo/releases/tag/v2.1.46)
19+
1020
## [6.7.0] - 2024-04-04
1121

1222
### Changed

pom.xml

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@
4646

4747

4848
<properties>
49-
<maven.compiler.source>11</maven.compiler.source>
50-
<maven.compiler.target>11</maven.compiler.target>
49+
<maven.compiler.source>17</maven.compiler.source>
50+
<maven.compiler.target>17</maven.compiler.target>
5151
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
52-
<qudt.release.version>v2.1.37</qudt.release.version>
53-
<spotless.format.version>1.9</spotless.format.version>
52+
<qudt.release.version>2.1.46</qudt.release.version>
53+
<spotless.format.version>1.25.0</spotless.format.version>
5454
</properties>
5555

5656
<scm>
@@ -90,6 +90,11 @@
9090
<artifactId>hamcrest-library</artifactId>
9191
<version>2.2</version>
9292
</dependency>
93+
<dependency>
94+
<groupId>org.apache.commons</groupId>
95+
<artifactId>commons-collections4</artifactId>
96+
<version>4.5.0-M2</version>
97+
</dependency>
9398
</dependencies>
9499
</dependencyManagement>
95100
<build>
@@ -148,7 +153,7 @@
148153
<plugin>
149154
<groupId>com.diffplug.spotless</groupId>
150155
<artifactId>spotless-maven-plugin</artifactId>
151-
<version>2.27.2</version>
156+
<version>2.44.0.BETA3</version>
152157
</plugin>
153158
<plugin>
154159
<groupId>org.codehaus.mojo</groupId>
@@ -178,6 +183,23 @@
178183
<groupId>com.diffplug.spotless</groupId>
179184
<artifactId>spotless-maven-plugin</artifactId>
180185
<configuration>
186+
<rdf>
187+
<includes>
188+
<include>**/*.ttl</include>
189+
</includes>
190+
<excludes>
191+
<exclude>**/target/**/*.*</exclude>
192+
</excludes>
193+
<format>
194+
<failOnWarning>false</failOnWarning>
195+
<verify>true</verify>
196+
<turtleFormatterVersion>1.2.14</turtleFormatterVersion>
197+
<turtle>
198+
<predicateOrder>rdf:type,owl:imports</predicateOrder>
199+
<firstPredicateInNewLine>true</firstPredicateInNewLine>
200+
</turtle>
201+
</format>
202+
</rdf>
181203
<formats>
182204
<!-- you can define as many formats as you want, each is independent -->
183205
<format>
@@ -309,15 +331,6 @@
309331
</plugins>
310332
</build>
311333
</profile>
312-
<profile>
313-
<id>jdk17</id>
314-
<activation>
315-
<jdk>17</jdk>
316-
</activation>
317-
<properties>
318-
<spotless.format.version>1.15.0</spotless.format.version>
319-
</properties>
320-
</profile>
321334
</profiles>
322335
<distributionManagement>
323336
<snapshotRepository>

qudtlib-data-gen/src/main/java/io/github/qudtlib/data/DataGenerator.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,14 @@ public class DataGenerator {
3434
private static final String CONSTANTS_OUTFILE = "qudt-constants.ttl";
3535

3636
// QUDT files
37-
private static final String UNITS_FILE = "qudt/vocab/unit/VOCAB_QUDT-UNITS-ALL-v2.1.ttl";
37+
private static final String UNITS_FILE = "qudt/vocab/unit/VOCAB_QUDT-UNITS-ALL.ttl";
3838
private static final String CURRENCIES_FILE =
39-
"qudt/vocab/currency/VOCAB_QUDT-UNITS-CURRENCY-v2.1.ttl";
40-
private static final String PREFIXES_FILE = "qudt/vocab/prefixes/VOCAB_QUDT-PREFIXES-v2.1.ttl";
39+
"qudt/vocab/currency/VOCAB_QUDT-UNITS-CURRENCY.ttl";
40+
private static final String PREFIXES_FILE = "qudt/vocab/prefixes/VOCAB_QUDT-PREFIXES.ttl";
4141
private static final String QUANTITYKINDS_FILE =
42-
"qudt/vocab/quantitykinds/VOCAB_QUDT-QUANTITY-KINDS-ALL-v2.1.ttl";
42+
"qudt/vocab/quantitykinds/VOCAB_QUDT-QUANTITY-KINDS-ALL.ttl";
4343

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

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

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

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

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

@@ -135,9 +136,9 @@ private void processQuantityKinds() {
135136
Repository outputRepo = new SailRepository(new MemoryStore());
136137
try (RepositoryConnection outputCon = outputRepo.getConnection()) {
137138
RdfOps.addStatementsFromFile(outputCon, QUANTITYKINDS_FILE);
138-
// the currencies file contains the qk:Currency definition:
139-
RdfOps.addStatementsFromFile(outputCon, CURRENCIES_FILE);
140139
// remove unwanted individual triples
140+
RdfOps.updateDataUsingNQueries(
141+
outputCon, DELETE_FROM_QUANTITYKINDS_BY_QUERY_PATTERN, 5);
141142
RdfOps.removeStatementsFromFile(outputCon, DELETE_FROM_QUANTITYKINDS);
142143
// add missing triples
143144
RdfOps.addStatementsFromFile(outputCon, ADD_TO_QUANTITYKINDS);
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
2-
@prefix qudt: <http://qudt.org/schema/qudt/> .
3-
@prefix unit: <http://qudt.org/vocab/unit/> .
4-
@prefix qkdv: <http://qudt.org/vocab/dimensionvector/> .
5-
@prefix quantitykind: <http://qudt.org/vocab/quantitykind/> .
6-
@prefix sou: <http://qudt.org/vocab/sou/> .
7-
@prefix dcterms: <http://purl.org/dc/terms/> .
8-
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
9-
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
1+
2+
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
@prefix qudt: <http://qudt.org/schema/qudt/> .
2-
@prefix unit: <http://qudt.org/vocab/unit/> .
3-
@prefix sou: <http://qudt.org/vocab/sou/> .
4-
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
5-
@prefix quantitykind: <http://qudt.org/vocab/quantitykind/> .
6-
@prefix prefix: <http://qudt.org/vocab/prefix/> .
1+
2+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
PREFIX qudt: <http://qudt.org/schema/qudt/>
2+
PREFIX unit: <http://qudt.org/vocab/unit/>
3+
prefix quantitykind: <http://qudt.org/vocab/quantitykind/>
4+
DELETE { ?qk ?b ?c . ?d ?e ?qk }
5+
WHERE { { ?qk ?b ?c .} union { ?d ?e ?qk }
6+
VALUES ?qk { quantitykind:VaporPermeability }
7+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+

qudtlib-data-gen/src/main/resources/delete-from-units-by-query1.rq

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
PREFIX qudt: <http://qudt.org/schema/qudt/>
2+
PREFIX unit: <http://qudt.org/vocab/unit/>
3+
prefix quantitykind: <http://qudt.org/vocab/quantitykind/>
4+
DELETE { ?d ?e ?qk }
5+
WHERE { ?d ?e ?qk
6+
VALUES ?qk { quantitykind:VaporPermeability }
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
PREFIX qudt: <http://qudt.org/schema/qudt/>
2+
PREFIX unit: <http://qudt.org/vocab/unit/>
3+
prefix quantitykind: <http://qudt.org/vocab/quantitykind/>
4+
DELETE { ?u qudt:symbol ?symb }
5+
INSERT { ?u qudt:symbol ?repl }
6+
WHERE {
7+
?u qudt:symbol ?symb
8+
filter(regex(?symb, "^1/.+"))
9+
BIND (replace(?symb, "^1", "") as ?repl)
10+
}
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,2 @@
1-
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
2-
@prefix qudt: <http://qudt.org/schema/qudt/> .
3-
@prefix unit: <http://qudt.org/vocab/unit/> .
4-
@prefix qkdv: <http://qudt.org/vocab/dimensionvector/> .
5-
@prefix qk: <http://qudt.org/vocab/quantitykind/> .
6-
@prefix sou: <http://qudt.org/vocab/sou/> .
7-
@prefix dcterms: <http://purl.org/dc/terms/> .
8-
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
9-
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
10-
@prefix prefix: <http://qudt.org/vocab/prefix/> .
1+
112

0 commit comments

Comments
 (0)