Skip to content

Commit 8ee2f7d

Browse files
authored
Merge pull request #1 from ardoco/feature/architecture-determinism
Add Architecture Tests & Minimal Determinism
2 parents e9d6b05 + 42c34e7 commit 8ee2f7d

File tree

8 files changed

+277
-223
lines changed

8 files changed

+277
-223
lines changed

pom.xml

Lines changed: 26 additions & 182 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44

5-
<groupId>io.github.ardoco</groupId>
5+
<parent>
6+
<groupId>io.github.ardoco</groupId>
7+
<artifactId>parent</artifactId>
8+
<version>2.0.0-SNAPSHOT</version>
9+
</parent>
10+
611
<artifactId>named-architecture-entity-recognition</artifactId>
712
<version>1.0.0-SNAPSHOT</version>
813

@@ -28,7 +33,6 @@
2833
<timezone>GMT+1</timezone>
2934
</developer>
3035
</developers>
31-
3236
<scm>
3337
<connection>scm:git:git://github.com/ArDoCo/NamedArchitectureEntityRecognition.git</connection>
3438
<developerConnection>scm:git:ssh://github.com:ArDoCo/NamedArchitectureEntityRecognition.git</developerConnection>
@@ -50,16 +54,6 @@
5054
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5155
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
5256
<project.source.encoding>UTF-8</project.source.encoding>
53-
<java.version>21</java.version>
54-
<maven.compiler.source>${java.version}</maven.compiler.source>
55-
<maven.compiler.target>${java.version}</maven.compiler.target>
56-
<maven.compiler.release>${java.version}</maven.compiler.release>
57-
58-
<ardoco.version>1.1.0</ardoco.version>
59-
<slf4j.version>2.0.14</slf4j.version>
60-
<spotless.version>2.43.0</spotless.version>
61-
<junit.version>5.11.0</junit.version>
62-
<jackson.version>2.17.2</jackson.version>
6357
</properties>
6458

6559
<dependencyManagement>
@@ -75,11 +69,9 @@
7569
</dependencyManagement>
7670

7771
<dependencies>
78-
7972
<dependency>
8073
<groupId>com.fasterxml.jackson.core</groupId>
8174
<artifactId>jackson-databind</artifactId>
82-
<version>${jackson.version}</version>
8375
</dependency>
8476
<dependency>
8577
<groupId>dev.langchain4j</groupId>
@@ -89,204 +81,57 @@
8981
<groupId>dev.langchain4j</groupId>
9082
<artifactId>langchain4j-open-ai</artifactId>
9183
</dependency>
92-
9384
<dependency>
9485
<groupId>io.github.ardoco</groupId>
9586
<artifactId>metrics</artifactId>
96-
<version>0.1.1</version>
87+
<version>${metrics.version}</version>
9788
</dependency>
98-
9989
<dependency>
10090
<groupId>io.github.ardoco.core</groupId>
10191
<artifactId>common</artifactId>
10292
<version>${ardoco.version}</version>
10393
</dependency>
104-
105-
<dependency>
106-
<groupId>org.apache.commons</groupId>
107-
<artifactId>commons-text</artifactId>
108-
<version>1.13.1</version>
109-
</dependency>
110-
11194
<dependency>
11295
<groupId>io.github.cdimascio</groupId>
11396
<artifactId>dotenv-java</artifactId>
11497
<version>3.2.0</version>
11598
</dependency>
116-
11799
<dependency>
118-
<groupId>org.junit.jupiter</groupId>
119-
<artifactId>junit-jupiter</artifactId>
120-
<version>${junit.version}</version>
121-
<scope>test</scope>
122-
</dependency>
123-
124-
<dependency>
125-
<groupId>org.slf4j</groupId>
126-
<artifactId>slf4j-api</artifactId>
127-
<version>${slf4j.version}</version>
128-
</dependency>
129-
130-
<dependency>
131-
<groupId>org.slf4j</groupId>
132-
<artifactId>slf4j-simple</artifactId>
133-
<version>${slf4j.version}</version>
134-
<scope>test</scope>
100+
<groupId>org.apache.commons</groupId>
101+
<artifactId>commons-text</artifactId>
102+
<version>1.13.1</version>
135103
</dependency>
136104
</dependencies>
105+
<repositories>
106+
<repository>
107+
<id>mavenCentral</id>
108+
<url>https://repo1.maven.org/maven2/</url>
109+
</repository>
110+
<repository>
111+
<releases>
112+
<enabled>false</enabled>
113+
</releases>
114+
<snapshots>
115+
<enabled>true</enabled>
116+
</snapshots>
117+
<id>mavenSnapshot</id>
118+
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
119+
</repository>
120+
</repositories>
137121

138122
<build>
139-
<pluginManagement>
140-
<plugins>
141-
<plugin>
142-
<groupId>org.apache.maven.plugins</groupId>
143-
<artifactId>maven-assembly-plugin</artifactId>
144-
<version>3.7.1</version>
145-
</plugin>
146-
<plugin>
147-
<groupId>org.apache.maven.plugins</groupId>
148-
<artifactId>maven-compiler-plugin</artifactId>
149-
<version>3.13.0</version>
150-
<configuration>
151-
<release>${java.version}</release>
152-
<source>${java.version}</source>
153-
<target>${java.version}</target>
154-
<encoding>UTF-8</encoding>
155-
<fork>true</fork>
156-
<meminitial>128m</meminitial>
157-
<maxmem>512m</maxmem>
158-
</configuration>
159-
</plugin>
160-
<plugin>
161-
<groupId>org.apache.maven.plugins</groupId>
162-
<artifactId>maven-failsafe-plugin</artifactId>
163-
<version>3.2.5</version>
164-
<executions>
165-
<execution>
166-
<goals>
167-
<goal>integration-test</goal>
168-
<goal>verify</goal>
169-
</goals>
170-
<phase>integration-test</phase>
171-
</execution>
172-
</executions>
173-
</plugin>
174-
<plugin>
175-
<groupId>org.apache.maven.plugins</groupId>
176-
<artifactId>maven-gpg-plugin</artifactId>
177-
<version>3.2.4</version>
178-
</plugin>
179-
<plugin>
180-
<groupId>org.apache.maven.plugins</groupId>
181-
<artifactId>maven-install-plugin</artifactId>
182-
<version>3.1.2</version>
183-
</plugin>
184-
<plugin>
185-
<groupId>org.apache.maven.plugins</groupId>
186-
<artifactId>maven-jar-plugin</artifactId>
187-
<version>3.4.2</version>
188-
</plugin>
189-
<plugin>
190-
<groupId>org.apache.maven.plugins</groupId>
191-
<artifactId>maven-surefire-plugin</artifactId>
192-
<version>3.2.5</version>
193-
</plugin>
194-
<plugin>
195-
<groupId>org.sonatype.central</groupId>
196-
<artifactId>central-publishing-maven-plugin</artifactId>
197-
<version>0.7.0</version>
198-
<extensions>true</extensions>
199-
<configuration>
200-
<publishingServerId>central</publishingServerId>
201-
<autoPublish>true</autoPublish>
202-
<waitUntil>published</waitUntil>
203-
<deploymentName>ardoco-naer</deploymentName>
204-
</configuration>
205-
</plugin>
206-
</plugins>
207-
</pluginManagement>
208123
<plugins>
209124
<plugin>
210125
<groupId>com.diffplug.spotless</groupId>
211126
<artifactId>spotless-maven-plugin</artifactId>
212-
<version>${spotless.version}</version>
213-
<configuration>
214-
<formats>
215-
<format>
216-
<includes>
217-
<include>*.md</include>
218-
<include>.gitignore</include>
219-
</includes>
220-
<trimTrailingWhitespace />
221-
<endWithNewline />
222-
<indent>
223-
<tabs>true</tabs>
224-
<spacesPerTab>4</spacesPerTab>
225-
</indent>
226-
</format>
227-
</formats>
228-
<!-- define a language-specific format -->
229-
<java>
230-
<eclipse>
231-
<!--suppress UnresolvedMavenProperty -->
232-
<file>${maven.multiModuleProjectDirectory}/formatter.xml</file>
233-
</eclipse>
234-
<removeUnusedImports />
235-
<licenseHeader>
236-
<!--suppress UnresolvedMavenProperty -->
237-
<file>${maven.multiModuleProjectDirectory}/license-header</file>
238-
</licenseHeader>
239-
<importOrder>
240-
<!--suppress UnresolvedMavenProperty -->
241-
<file>${maven.multiModuleProjectDirectory}/spotless.importorder</file>
242-
</importOrder>
243-
</java>
244-
<pom>
245-
<sortPom>
246-
<encoding>UTF-8</encoding>
247-
<keepBlankLines>true</keepBlankLines>
248-
<indentBlankLines>false</indentBlankLines>
249-
<nrOfIndentSpace>2</nrOfIndentSpace>
250-
<expandEmptyElements>false</expandEmptyElements>
251-
<spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement>
252-
<sortDependencies>groupId,artifactId</sortDependencies>
253-
<sortDependencyExclusions>groupId,artifactId</sortDependencyExclusions>
254-
<sortDependencyManagement>groupId,artifactId</sortDependencyManagement>
255-
<sortPlugins>groupId,artifactId</sortPlugins>
256-
<sortProperties>false</sortProperties>
257-
<sortModules>true</sortModules>
258-
<sortExecutions>true</sortExecutions>
259-
<predefinedSortOrder>recommended_2008_06</predefinedSortOrder>
260-
</sortPom>
261-
</pom>
262-
<ratchetFrom>origin/main</ratchetFrom>
263-
</configuration>
264127
</plugin>
265128
<plugin>
266129
<groupId>org.apache.maven.plugins</groupId>
267130
<artifactId>maven-javadoc-plugin</artifactId>
268-
<version>3.7.0</version>
269-
<executions>
270-
<execution>
271-
<id>attach-javadocs</id>
272-
<goals>
273-
<goal>jar</goal>
274-
</goals>
275-
</execution>
276-
</executions>
277131
</plugin>
278132
<plugin>
279133
<groupId>org.apache.maven.plugins</groupId>
280134
<artifactId>maven-source-plugin</artifactId>
281-
<version>3.3.1</version>
282-
<executions>
283-
<execution>
284-
<id>attach-sources</id>
285-
<goals>
286-
<goal>jar-no-fork</goal>
287-
</goals>
288-
</execution>
289-
</executions>
290135
</plugin>
291136
<plugin>
292137
<groupId>org.sonatype.central</groupId>
@@ -330,5 +175,4 @@
330175
</build>
331176
</profile>
332177
</profiles>
333-
334178
</project>

src/main/java/edu/kit/kastel/mcse/ardoco/naer/model/NamedEntity.java

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
/* Licensed under MIT 2025. */
22
package edu.kit.kastel.mcse.ardoco.naer.model;
33

4-
import java.util.HashSet;
5-
import java.util.List;
6-
import java.util.Objects;
7-
import java.util.Set;
4+
import java.util.*;
85

96
import org.jetbrains.annotations.NotNull;
107
import org.jetbrains.annotations.Nullable;
@@ -20,11 +17,11 @@ public class NamedEntity {
2017
/**
2118
* alternative names of the entity, e.g., if the name is ambiguous
2219
*/
23-
private final Set<String> alternativeNames;
20+
private final SortedSet<String> alternativeNames;
2421
/**
2522
* all occurrences of the entity in the {@link #sourceText}
2623
*/
27-
private final Set<Occurrence> occurrences;
24+
private final SortedSet<Occurrence> occurrences;
2825
private String name;
2926
/**
3027
* the software architecture documentation (text) in which the named entity has been recognized
@@ -46,8 +43,8 @@ private NamedEntity(@JsonProperty("name") String name, @JsonProperty("type") Nam
4643
@JsonProperty("alternativeNames") List<String> alternativeNames, @JsonProperty("occurrences") List<Occurrence> occurrences) {
4744
this.name = name;
4845
this.type = type;
49-
this.alternativeNames = new HashSet<>(alternativeNames);
50-
this.occurrences = new HashSet<>(occurrences);
46+
this.alternativeNames = new TreeSet<>(alternativeNames);
47+
this.occurrences = new TreeSet<>(occurrences);
5148
}
5249

5350
/**
@@ -60,8 +57,8 @@ private NamedEntity(@JsonProperty("name") String name, @JsonProperty("type") Nam
6057
public NamedEntity(String name, NamedEntityType type) {
6158
this.name = name;
6259
this.type = type;
63-
this.alternativeNames = new HashSet<>();
64-
this.occurrences = new HashSet<>();
60+
this.alternativeNames = new TreeSet<>();
61+
this.occurrences = new TreeSet<>();
6562
}
6663

6764
@Nullable
@@ -101,7 +98,7 @@ public NamedEntityType getType() {
10198
*
10299
* @return a set of strings representing alternative names for this entity
103100
*/
104-
public Set<String> getAlternativeNames() {
101+
public SortedSet<String> getAlternativeNames() {
105102
return alternativeNames;
106103
}
107104

@@ -122,7 +119,7 @@ public void makeAllNamesLowerCase() {
122119
this.name = this.name.toLowerCase();
123120
}
124121

125-
Set<String> lowercasedAlternativeNames = new HashSet<>();
122+
SortedSet<String> lowercasedAlternativeNames = new TreeSet<>();
126123
for (String alternativeName : this.alternativeNames) {
127124
if (alternativeName != null) {
128125
lowercasedAlternativeNames.add(alternativeName.toLowerCase());
@@ -138,8 +135,8 @@ public void makeAllNamesLowerCase() {
138135
*
139136
* @return a set of unique integers representing the line/sentence numbers in which the entity is mentioned (line numbers are 1-indexed).
140137
*/
141-
public Set<Integer> getOccurrenceLines() {
142-
Set<Integer> result = new HashSet<>();
138+
public SortedSet<Integer> getOccurrenceLines() {
139+
SortedSet<Integer> result = new TreeSet<>();
143140
for (Occurrence occurrence : occurrences) {
144141
result.add(occurrence.sentenceNumber);
145142
}
@@ -184,7 +181,7 @@ public String toString() {
184181
* @param sentenceNumber starting at {@code 1}
185182
* @param referenceType type of how the entity is referenced
186183
*/
187-
private record Occurrence(int sentenceNumber, NamedEntityReferenceType referenceType) {
184+
private record Occurrence(int sentenceNumber, NamedEntityReferenceType referenceType) implements Comparable<Occurrence> {
188185
@JsonCreator
189186
private Occurrence(@JsonProperty("line") int sentenceNumber, @JsonProperty("referenceType") NamedEntityReferenceType referenceType) {
190187
this.sentenceNumber = sentenceNumber;
@@ -196,5 +193,14 @@ private Occurrence(@JsonProperty("line") int sentenceNumber, @JsonProperty("refe
196193
public String toString() {
197194
return sentenceNumber + ":" + referenceType;
198195
}
196+
197+
@Override
198+
public int compareTo(@NotNull Occurrence o) {
199+
int cmp = Integer.compare(this.sentenceNumber, o.sentenceNumber);
200+
if (cmp != 0) {
201+
return cmp;
202+
}
203+
return this.referenceType.compareTo(o.referenceType);
204+
}
199205
}
200206
}

0 commit comments

Comments
 (0)