Skip to content

Commit

Permalink
#470: Segmentation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
berndmoos committed May 6, 2024
1 parent 3e3f99a commit 4499bd3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private void setupPattern() {

@Override
public Vector getSegmentationErrors(BasicTranscription bt) throws SAXException {
Vector<FSMException> result = new Vector<FSMException>();
Vector<FSMException> result = new Vector<>();
SegmentedTranscription st = bt.toSegmentedTranscription();
for (String tierID : st.getBody().getAllTierIDs()){
SegmentedTier tier = st.getBody().getSegmentedTierWithID(tierID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.util.List;
import java.util.Set;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.tree.DefaultMutableTreeNode;
Expand All @@ -19,12 +21,15 @@
import org.exmaralda.partitureditor.jexmaralda.Annotation;
import org.exmaralda.partitureditor.jexmaralda.AtomicTimedSegment;
import org.exmaralda.partitureditor.jexmaralda.BasicTranscription;
import org.exmaralda.partitureditor.jexmaralda.Event;
import org.exmaralda.partitureditor.jexmaralda.Identifiable;
import org.exmaralda.partitureditor.jexmaralda.JexmaraldaException;
import org.exmaralda.partitureditor.jexmaralda.NonTimedSegment;
import org.exmaralda.partitureditor.jexmaralda.SegmentList;
import org.exmaralda.partitureditor.jexmaralda.Segmentation;
import org.exmaralda.partitureditor.jexmaralda.SegmentedTier;
import org.exmaralda.partitureditor.jexmaralda.SegmentedTranscription;
import org.exmaralda.partitureditor.jexmaralda.Tier;
import org.exmaralda.partitureditor.jexmaralda.TimedAnnotation;
import org.exmaralda.partitureditor.jexmaralda.TimedSegment;
import org.xml.sax.SAXException;
Expand Down Expand Up @@ -66,7 +71,24 @@ public class InelEventBasedSegmentation extends AbstractSegmentation {
@Override
public Vector getSegmentationErrors(BasicTranscription bt) throws SAXException {
// just return empty for now
return new Vector();
Vector<FSMException> result = new Vector<>();
String[] tTierIDs = bt.getBody().getTiersOfType("t");
for (String tierID : tTierIDs){
try {
Tier tier = bt.getBody().getTierWithID(tierID);
for (int pos=0; pos<tier.getNumberOfEvents(); pos++){
Event event = tier.getEventAt(pos);
if (event.getDescription().startsWith("((") && (!event.getDescription().trim().endsWith("))"))){
FSMException ex = new FSMException("Unclosed double round brackets", event.getDescription(), event.getStart(), tierID);
result.add(ex);
}
}
} catch (JexmaraldaException ex) {
Logger.getLogger(InelEventBasedSegmentation.class.getName()).log(Level.SEVERE, null, ex);
throw new SAXException(ex);
}
}
return result;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public void setupDialog(BasicTranscription bt, int seg, String ptef){
case AbstractSegmentation.CHAT_MINIMAL_SEGMENTATION :
segmentationAlgorithm = new CHATMinimalSegmentation();
break;
case AbstractSegmentation.INEL_EVENT_BASED :
segmentationAlgorithm = new InelEventBasedSegmentation();
break;
}
transcription = bt;
updateErrors();
Expand Down

0 comments on commit 4499bd3

Please sign in to comment.