Skip to content
Snippets Groups Projects
Commit 317f3ca6 authored by Lange, Dr. Herbert's avatar Lange, Dr. Herbert
Browse files

better check for problems

parent 743ea00e
No related branches found
No related tags found
1 merge request!6add feature to load criteria file from resource and place all criteria files...
...@@ -21,6 +21,7 @@ import java.nio.file.Paths; ...@@ -21,6 +21,7 @@ import java.nio.file.Paths;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.*; import java.util.*;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.stream.Collectors;
/** /**
...@@ -46,6 +47,7 @@ public class EXMARaLDAValidatorChecker extends Checker implements CorpusFunction ...@@ -46,6 +47,7 @@ public class EXMARaLDAValidatorChecker extends Checker implements CorpusFunction
@Override @Override
public Report function(CorpusData cd, Boolean fix) throws NoSuchAlgorithmException, ClassNotFoundException, FSMException, URISyntaxException, SAXException, IOException, ParserConfigurationException, JexmaraldaException, TransformerException, XPathExpressionException, JDOMException { public Report function(CorpusData cd, Boolean fix) throws NoSuchAlgorithmException, ClassNotFoundException, FSMException, URISyntaxException, SAXException, IOException, ParserConfigurationException, JexmaraldaException, TransformerException, XPathExpressionException, JDOMException {
logger.info("Running function"); logger.info("Running function");
boolean problem = false;
Report report = new Report(); Report report = new Report();
URL fileUri = Paths.get(cd.getURL().toURI()).toAbsolutePath().toUri().toURL(); URL fileUri = Paths.get(cd.getURL().toURI()).toAbsolutePath().toUri().toURL();
BasicTranscription bt = new BasicTranscription(); BasicTranscription bt = new BasicTranscription();
...@@ -53,6 +55,7 @@ public class EXMARaLDAValidatorChecker extends Checker implements CorpusFunction ...@@ -53,6 +55,7 @@ public class EXMARaLDAValidatorChecker extends Checker implements CorpusFunction
bt.BasicTranscriptionFromJDOMDocument(((EXMARaLDATranscriptionData) cio.readFileURL(fileUri)).getJdom()); bt.BasicTranscriptionFromJDOMDocument(((EXMARaLDATranscriptionData) cio.readFileURL(fileUri)).getJdom());
String[] duplicateTranscriptionTiers = bt.getDuplicateTranscriptionTiers(); String[] duplicateTranscriptionTiers = bt.getDuplicateTranscriptionTiers();
if (duplicateTranscriptionTiers.length > 0) { if (duplicateTranscriptionTiers.length > 0) {
problem = true;
report.addCritical(getFunction(), report.addCritical(getFunction(),
ReportItem.newParamMap(new String[]{"function", "filename", "description"}, ReportItem.newParamMap(new String[]{"function", "filename", "description"},
new String[]{getFunction(), cd.getFilename(), "Duplicate transcription tiers: " + String.join( new String[]{getFunction(), cd.getFilename(), "Duplicate transcription tiers: " + String.join(
...@@ -60,6 +63,7 @@ public class EXMARaLDAValidatorChecker extends Checker implements CorpusFunction ...@@ -60,6 +63,7 @@ public class EXMARaLDAValidatorChecker extends Checker implements CorpusFunction
} }
String[] orphanedTranscriptionTiers = bt.getOrphanedTranscriptionTiers(); String[] orphanedTranscriptionTiers = bt.getOrphanedTranscriptionTiers();
if (orphanedTranscriptionTiers.length > 0) { if (orphanedTranscriptionTiers.length > 0) {
problem = true;
report.addWarning(getFunction(), report.addWarning(getFunction(),
ReportItem.newParamMap(new String[]{"function", "filename", "description"}, ReportItem.newParamMap(new String[]{"function", "filename", "description"},
new String[]{getFunction(), cd.getFilename(), "Orphaned transcription tiers: " + String.join( new String[]{getFunction(), cd.getFilename(), "Orphaned transcription tiers: " + String.join(
...@@ -67,6 +71,7 @@ public class EXMARaLDAValidatorChecker extends Checker implements CorpusFunction ...@@ -67,6 +71,7 @@ public class EXMARaLDAValidatorChecker extends Checker implements CorpusFunction
} }
String[] orphanedAnnotationTiers = bt.getOrphanedAnnotationTiers(); String[] orphanedAnnotationTiers = bt.getOrphanedAnnotationTiers();
if (orphanedAnnotationTiers.length > 0) { if (orphanedAnnotationTiers.length > 0) {
problem = true;
report.addWarning(getFunction(), report.addWarning(getFunction(),
ReportItem.newParamMap(new String[]{"function", "filename", "description"}, ReportItem.newParamMap(new String[]{"function", "filename", "description"},
new String[]{getFunction(), cd.getFilename(), "Orphaned annotation tiers: " + String.join( new String[]{getFunction(), cd.getFilename(), "Orphaned annotation tiers: " + String.join(
...@@ -74,6 +79,7 @@ public class EXMARaLDAValidatorChecker extends Checker implements CorpusFunction ...@@ -74,6 +79,7 @@ public class EXMARaLDAValidatorChecker extends Checker implements CorpusFunction
} }
String[] inconsistencies = bt.getBody().getCommonTimeline().getInconsistencies(); String[] inconsistencies = bt.getBody().getCommonTimeline().getInconsistencies();
if (inconsistencies.length > 0) { if (inconsistencies.length > 0) {
problem = true;
report.addCritical(getFunction(), report.addCritical(getFunction(),
ReportItem.newParamMap(new String[]{"function", "filename", "description"}, ReportItem.newParamMap(new String[]{"function", "filename", "description"},
new String[]{getFunction(), cd.getFilename(), new String[]{getFunction(), cd.getFilename(),
...@@ -81,18 +87,30 @@ public class EXMARaLDAValidatorChecker extends Checker implements CorpusFunction ...@@ -81,18 +87,30 @@ public class EXMARaLDAValidatorChecker extends Checker implements CorpusFunction
",", inconsistencies)})); ",", inconsistencies)}));
} }
Hashtable<String, String[]> annotationMismatches = bt.getAnnotationMismatches(); Hashtable<String, String[]> annotationMismatches = bt.getAnnotationMismatches();
if (!annotationMismatches.isEmpty()) // Only check tiers where we have a non-empty list in the map
Set<String> missmatchTiers = annotationMismatches.keySet().stream().filter((k) ->
annotationMismatches.get(k).length != 0).collect(Collectors.toSet());
if (!missmatchTiers.isEmpty()) {
problem = true;
report.addCritical(getFunction(), ReportItem.newParamMap(new String[]{"function", "filename", "description"}, report.addCritical(getFunction(), ReportItem.newParamMap(new String[]{"function", "filename", "description"},
new String[]{getFunction(), cd.getFilename(), "Annotation mismatch in tiers: " + String.join(",", new String[]{getFunction(), cd.getFilename(), "Annotation mismatch in tiers: " + String.join(",",
annotationMismatches.keySet())})); missmatchTiers)}));
}
Vector segmentationErrors = new HIATSegmentation().getSegmentationErrors(bt); Vector segmentationErrors = new HIATSegmentation().getSegmentationErrors(bt);
// TODO the exact reason and form of segmentation errors is not clear // TODO the exact reason and form of segmentation errors is not clear
if (!segmentationErrors.isEmpty()) { if (!segmentationErrors.isEmpty()) {
problem = true;
for (Object o : segmentationErrors) { for (Object o : segmentationErrors) {
report.addCritical(getFunction(),ReportItem.newParamMap(new String[]{"function", "filename", "description"}, report.addCritical(getFunction(),ReportItem.newParamMap(new String[]{"function", "filename", "description"},
new String[]{getFunction(), cd.getFilename(),"HIAT Segmentation error: " + o.toString()})); new String[]{getFunction(), cd.getFilename(),"HIAT Segmentation error: " + o.toString()}));
} }
} }
if (!problem) {
report.addCorrect(getFunction(),ReportItem.newParamMap(
new String[]{"function","filename","description"},
new Object[]{getFunction(),cd.getFilename(),"No problems found in file"}
));
}
return report; return report;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment