10 package de.uni_hamburg.corpora.validation;
17 import java.io.IOException;
19 import java.util.Hashtable;
20 import java.util.Collection;
21 import org.xml.sax.SAXException;
23 import java.net.URISyntaxException;
24 import javax.xml.parsers.ParserConfigurationException;
25 import javax.xml.transform.TransformerException;
26 import javax.xml.xpath.XPathExpressionException;
27 import org.exmaralda.partitureditor.jexmaralda.BasicTranscription;
28 import org.exmaralda.partitureditor.jexmaralda.JexmaraldaException;
29 import org.jdom.JDOMException;
37 BasicTranscription bt;
53 throws SAXException, JDOMException, IOException, JexmaraldaException {
59 String[] duplicateTranscriptionTiers
60 = bt.getDuplicateTranscriptionTiers();
61 String[] orphanedTranscriptionTiers
62 = bt.getOrphanedTranscriptionTiers();
63 String[] orphanedAnnotationTiers = bt.getOrphanedAnnotationTiers();
64 String[] temporalAnomalies
65 = bt.getBody().getCommonTimeline().getInconsistencies();
66 Hashtable<String, String[]> annotationMismatches
67 = bt.getAnnotationMismatches();
68 if (duplicateTranscriptionTiers.length == 0 && orphanedTranscriptionTiers.length == 0 && orphanedAnnotationTiers.length == 0 && temporalAnomalies.length == 0) {
69 stats.
addCorrect(
function, cd,
"No structure errors found.");
71 for (String tierID : duplicateTranscriptionTiers) {
73 "More than one transcription tier for one " 74 +
"speaker. Tier: " + tierID +
"Open in PartiturEditor, " 75 +
"change tier type or merge tiers.");
76 exmaError.addError(
function, filename, tierID,
"",
false,
77 "More than one transcription tier for one speaker. Tier: " 78 + tierID +
". Change tier type or merge tiers.");
80 for (String tliID : temporalAnomalies) {
82 "Temporal anomaly at timeline item: " + tliID);
83 exmaError.addError(
function, filename,
"",
"",
false,
84 "Temporal anomaly at timeline item: " + tliID);
86 for (String tierID : orphanedTranscriptionTiers) {
88 "Orphaned transcription tier:" + tierID);
89 exmaError.addError(
function, filename, tierID,
"",
false,
90 "Orphaned transcription tier:" + tierID);
92 for (String tierID : orphanedAnnotationTiers) {
94 "Orphaned annotation tier:" + tierID);
95 exmaError.addError(
function, filename, tierID,
"",
false,
96 "Orphaned annotation tier:" + tierID);
98 for (String tierID : annotationMismatches.keySet()) {
99 String[] eventIDs = annotationMismatches.get(tierID);
100 for (String eventID : eventIDs) {
102 "Annotation mismatch: tier " + tierID
103 +
" event " + eventID);
104 exmaError.addError(
function, filename, tierID, eventID,
false,
105 "Annotation mismatch: tier " + tierID
106 +
" event " + eventID);
122 Class cl = Class.forName(
"de.uni_hamburg.corpora.BasicTranscriptionData");
124 }
catch (ClassNotFoundException ex) {
136 String description =
"This class checks basic transcription files for structural anomalies. ";
141 public Report function(
Corpus c, Boolean fix)
throws SAXException, IOException, ParserConfigurationException, URISyntaxException, JDOMException, TransformerException, XPathExpressionException, JexmaraldaException {
143 for (
CorpusData cdata : c.getBasicTranscriptionData()) {
144 stats.
merge(
function(cdata, fix));
BasicTranscription getEXMARaLDAbt()
static ExmaErrorList exmaError
void addCritical(String description)
void addCorrect(String statId, String description)
Collection< Class<?extends CorpusData > > getIsUsableFor()
void addException(Throwable e, String description)