Fix for testing on return of warnings for the synthetic FAIR guidelines.

This commit is contained in:
pispis 2023-03-07 11:54:15 +01:00
parent b19f782cfa
commit 4c86b4dffb
1 changed files with 27 additions and 15 deletions

View File

@ -11,22 +11,23 @@ import org.w3c.dom.Document;
import java.io.FileReader;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.OptionalDouble;
import java.util.StringJoiner;
import java.util.function.ToDoubleFunction;
import java.util.stream.Collectors;
import java.util.stream.DoubleStream;
public class Test_FAIR {
private static final String[] FILES = new String[]{
// "/Users/lpisp/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV3/dia.library.tuc.gr/Record_21811.xml",
// "/Users/lpisp/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV3/cris.vtt.fi/03.xml",
// "/Users/lpisp/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV3/cris.vtt.fi/01_data.xml",
// "/Users/lpisp/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV3/cris.vtt.fi/02_data.xml",
// "/Users/lpisp/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV3/cris.vtt.fi/04_data.xml",
// "/Users/lpisp/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV3/cris.vtt.fi/03_data.xml",
// "/Users/leonidas/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV3/cris.vtt.fi/03.xml",
// "/Users/leonidas/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV3/cris.vtt.fi/01_data.xml",
// "/Users/leonidas/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV3/cris.vtt.fi/02_data.xml",
// "/Users/leonidas/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV3/cris.vtt.fi/04_data.xml",
"/Users/leonidas/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV3/cris.vtt.fi/03_data.xml",
"/Users/lpisp/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV3/dia.library.tuc.gr/Record_21811.xml",
"/Users/lpisp/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV3/cris.vtt.fi/03.xml",
"/Users/lpisp/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV3/cris.vtt.fi/01_data.xml",
"/Users/lpisp/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV3/cris.vtt.fi/02_data.xml",
"/Users/lpisp/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV3/cris.vtt.fi/04_data.xml",
"/Users/lpisp/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV3/cris.vtt.fi/03_data.xml",
"/Users/lpisp/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV4/01_gv4.xml"
};
public static void main(String[] args) {
@ -34,6 +35,7 @@ public class Test_FAIR {
FAIR_Data_GuidelinesProfile profile = new FAIR_Data_GuidelinesProfile();
System.out.println("Max score: " + profile.maxScore());
Map<String, Double> scorePerDoc = new LinkedHashMap<>();
int i = 1;
for (String file : FILES) {
try {
System.out.println("Processing " + file);
@ -41,9 +43,9 @@ public class Test_FAIR {
XMLApplicationProfile.ValidationResult result = profile.validate(file, doc);
scorePerDoc.put(file, result.score());
Map<String, Guideline.Result> results = result.results();
for (Map.Entry entry : results.entrySet()) {
System.out.println(entry.getKey() + " = " + entry.getValue());
}
// for (Map.Entry entry : results.entrySet()) {
// System.out.println(entry.getKey() + " = " + entry.getValue());
// }
} catch (Exception e) {
@ -53,10 +55,20 @@ public class Test_FAIR {
}
// System.out.println("\n\n\n\n");
}
// System.out.println("\n\n\n\n");
// Individual scores
String printout = scorePerDoc.entrySet().stream().
map(entry -> entry.getValue() + ": " + entry.getKey()).collect(Collectors.joining("\n"));
// Average Score
double FinalScore = scorePerDoc.entrySet().stream().
mapToDouble(entry -> entry.getValue()).average().getAsDouble();
System.out.println(printout);
System.out.println("\nValidation Score: "+FinalScore);
// TotalScore.forEach(System.out::println);
}
}