Fix for testing on return of warnings for the synthetic FAIR guidelines.
This commit is contained in:
parent
b19f782cfa
commit
4c86b4dffb
|
@ -11,22 +11,23 @@ import org.w3c.dom.Document;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
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.Collectors;
|
||||||
|
import java.util.stream.DoubleStream;
|
||||||
|
|
||||||
public class Test_FAIR {
|
public class Test_FAIR {
|
||||||
|
|
||||||
private static final String[] FILES = new String[]{
|
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/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/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/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/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/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/openaireguidelinesV3/cris.vtt.fi/03_data.xml",
|
||||||
// "/Users/leonidas/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV3/cris.vtt.fi/03.xml",
|
"/Users/lpisp/Documents/OpenAIRE/MaDgIK/validator-engine/src/test/resources/openaireguidelinesV4/01_gv4.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",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -34,6 +35,7 @@ public class Test_FAIR {
|
||||||
FAIR_Data_GuidelinesProfile profile = new FAIR_Data_GuidelinesProfile();
|
FAIR_Data_GuidelinesProfile profile = new FAIR_Data_GuidelinesProfile();
|
||||||
System.out.println("Max score: " + profile.maxScore());
|
System.out.println("Max score: " + profile.maxScore());
|
||||||
Map<String, Double> scorePerDoc = new LinkedHashMap<>();
|
Map<String, Double> scorePerDoc = new LinkedHashMap<>();
|
||||||
|
int i = 1;
|
||||||
for (String file : FILES) {
|
for (String file : FILES) {
|
||||||
try {
|
try {
|
||||||
System.out.println("Processing " + file);
|
System.out.println("Processing " + file);
|
||||||
|
@ -41,9 +43,9 @@ public class Test_FAIR {
|
||||||
XMLApplicationProfile.ValidationResult result = profile.validate(file, doc);
|
XMLApplicationProfile.ValidationResult result = profile.validate(file, doc);
|
||||||
scorePerDoc.put(file, result.score());
|
scorePerDoc.put(file, result.score());
|
||||||
Map<String, Guideline.Result> results = result.results();
|
Map<String, Guideline.Result> results = result.results();
|
||||||
for (Map.Entry entry : results.entrySet()) {
|
// for (Map.Entry entry : results.entrySet()) {
|
||||||
System.out.println(entry.getKey() + " = " + entry.getValue());
|
// System.out.println(entry.getKey() + " = " + entry.getValue());
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} 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");
|
||||||
}
|
}
|
||||||
// System.out.println("\n\n\n\n");
|
|
||||||
|
// Individual scores
|
||||||
String printout = scorePerDoc.entrySet().stream().
|
String printout = scorePerDoc.entrySet().stream().
|
||||||
map(entry -> entry.getValue() + ": " + entry.getKey()).collect(Collectors.joining("\n"));
|
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(printout);
|
||||||
|
System.out.println("\nValidation Score: "+FinalScore);
|
||||||
|
// TotalScore.forEach(System.out::println);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue