Skip to content

Commit

Permalink
Merge pull request #46 from WSE-research/bugfixes
Browse files Browse the repository at this point in the history
[Bugfix]: wrong enumateration of explanations
  • Loading branch information
dschiese authored Jul 12, 2024
2 parents 684903c + fb00f4f commit 0c3ad17
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.wse</groupId>
<artifactId>qanary-explanation-service</artifactId>
<version>3.5.2</version>
<version>3.5.3</version>
<name>Qanary explanation service</name>
<description>Webservice for rule-based explanation of QA-Systems as well as specific components</description>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,13 @@ public String composeExplanations(QanaryComponent component, String lang, List<S
AtomicInteger i = new AtomicInteger(0);
if (Objects.equals(lang, "en")) {
result = "The component " + componentURI + " has added " + (explanations.size() == 5 ? "at least " : "") + explanations.size() + " annotation(s) to the graph"
+ prefix + ": " + (i.getAndAdd(1)+1) + ". " + StringUtils.join(explanations, " " + (i.getAndAdd(1)+1) + ". ");
+ prefix + ":";
} else if (Objects.equals(lang, "de")) {
result = "Die Komponente " + componentURI + " hat " + (explanations.size() == 5 ? "mindestens " : "") + explanations.size() + " Annotation(en) zum Graph hinzugefügt"
+ prefix + ": " + (i.getAndAdd(1)+1) + ". " + StringUtils.join(explanations, " " + (i.getAndAdd(1)+1) + ". ");
+ prefix + ":";
}
for(int counter = 0; counter < explanations.size(); counter++) {
result += (" " + String.valueOf(counter+1) + ". " + explanations.get(counter));
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,18 +297,19 @@ public void setup() {
explanations.add("prefix");
explanations.add("explanation1");
explanations.add("explanation2");
explanations.add("explanation3");
}

@Test
public void composeExplanationsTestGerman() {
String expectedDe = "Die Komponente component hat 2 Annotation(en) zum Graph hinzugefügt: 1. explanation1 2. explanation2";
String expectedDe = "Die Komponente component hat 3 Annotation(en) zum Graph hinzugefügt: 1. explanation1 2. explanation2 3. explanation3";
String computedDe = templateExplanationsService.composeExplanations(qanaryComponent,"de",explanations,"");
Assertions.assertEquals(expectedDe,computedDe);

}
@Test
public void composeExplanationsTestEnglish() {
String expectedEn = "The component component has added 2 annotation(s) to the graph: 1. explanation1 2. explanation2";
String expectedEn = "The component component has added 3 annotation(s) to the graph: 1. explanation1 2. explanation2 3. explanation3";
String computedEn = templateExplanationsService.composeExplanations(qanaryComponent, "en", explanations, "");
Assertions.assertEquals(expectedEn,computedEn);
}
Expand Down

0 comments on commit 0c3ad17

Please sign in to comment.