/** * Write as eger. * * @param dos the dos * @param type the type * @throws IOException Signals that an I/O exception has occurred. */ public void writeAsEGER(OutputStreamWriter dos, String type) throws IOException { String line; String nameEN; for (Segment segment : segmentSet) { if (type.equals("writing")) { EntitySet entitySet = segment.getTranscription().getEntitySet(); for (Entity entity : entitySet) { // logger.info("WRITING entity : "+entity.getListOfWords()); if (entity.isPerson()) { nameEN = SpeakerNameUtils.normalizeSpeakerName(entity.getListOfWords()); line = segment.getShowName(); line += " " + segment.getStartInSecond(); line += " " + segment.getLastInSecond(); line += " written"; line += " " + nameEN + "\n"; if (segment.getLength() > 0) { dos.write(line); } } } } else { line = segment.getShowName(); line += " " + segment.getStartInSecond(); line += " " + segment.getLastInSecond(); line += " " + type; line += " " + name + "\n"; if (segment.getLength() > 0) { dos.write(line); } } } }
/** * Write the cluster and the segments to a CTL \e *FILE. * * @param dos the DataOutPutstream to write to * @throws IOException Signals that an I/O exception has occurred. */ public void writeAsCTL(OutputStreamWriter dos) throws IOException { DecimalFormatSymbols dfs = new DecimalFormatSymbols(); dfs.setDecimalSeparator('.'); DecimalFormat df = new DecimalFormat(); df.setDecimalFormatSymbols(dfs); df.setMaximumFractionDigits(2); df.setMinimumFractionDigits(2); df.setGroupingUsed(false); for (Segment seg : segmentSet) { float start = seg.getStartInSecond(); float end = seg.getEndInSecond(); String band = Segment.bandwidthNistStrings[0]; if (seg.getBandwidth() == Segment.bandwidthStrings[1]) { band = Segment.bandwidthNistStrings[1]; } else if (seg.getBandwidth() == Segment.bandwidthStrings[2]) { band = Segment.bandwidthNistStrings[2]; } String line = seg.getShowName() + " " + seg.getStart() + " " + (seg.getStart() + seg.getLength()); line += " " + seg.getShowName() + "-" + df.format(start) + "-" + df.format(end) + "-" + band; line += "-" + this.gender + "-" + name + "\n"; dos.write(line); } }
/** * Collapse the near segments. * * @param delay the possible delay between segment * @return the array list */ public ArrayList<Integer> collapse(int delay) { Iterator<Segment> segmentIterator = iterator(); ArrayList<Integer> list = new ArrayList<Integer>(); Segment previous, current; if (segmentIterator.hasNext()) { previous = segmentIterator.next(); while (segmentIterator.hasNext()) { current = segmentIterator.next(); if (current.getShowName().compareTo(previous.getShowName()) == 0) { int previousStart = previous.getStart(); int previousEnd = previousStart + previous.getLength(); int currentStart = current.getStart(); int currentLength = current.getLength(); list.add(currentLength); if ((previousEnd + delay) >= currentStart) { previous.setLength((currentStart - previousStart) + currentLength); LinkSet linkSetSave = previous.getLinkSet(); EntitySet entitiesSave = previous.getEntities(); previous.getInformation().putAll(current.getInformation()); previous.setLinkSet(linkSetSave); previous.setEntities(entitiesSave); int sizeLink = previous.getLinkSet().size(); for (Link link : current.getLinkSet()) { link.setId(sizeLink++); previous.getLinkSet().add(link); } for (Entity entity : current.getEntities()) { previous.getEntities().add(entity); } segmentIterator.remove(); } else { previous = current; } } else { previous = current; } } } return list; }
/** * Write the cluster and the segments to a \e *FILE. * * @param dos the DataOutPutstream to write to * @throws IOException Signals that an I/O exception has occurred. */ public void writeAsXSeg(OutputStreamWriter dos) throws IOException { String line = getInformations(); if (line != "") { line = "audio cluster " + name + " " + getInformations() + "\n"; dos.write(line); } for (Segment segment : segmentSet) { line = "audio segment " + segment.getShowName() + " " + segment.getChannel() + " " + segment.getStart(); line += " " + segment.getLength() + " " + gender + " " + segment.getBandwidth(); line += " " + segment.getEnvironement() + " " + name + segment.getInformations() + "\n"; dos.write(line); } }
/** * Write the cluster and the segments to a \e *FILE. * * @param dos the DataOutPutstream to write to * @throws IOException Signals that an I/O exception has occurred. */ public void writeAsSeg(OutputStreamWriter dos) throws IOException { Set<Entry<String, Object>> set = getInformation().entrySet(); String info = ""; for (Entry<String, Object> entry : set) { info += "[ " + entry.getKey() + " = " + entry.getValue().toString() + " ] "; } dos.write(";; cluster " + name + " " + info + "\n"); String line; /* * String line = getInformations(); if (line != "") { line = ";; cluster:" + name + getInformations() + "\n"; dos.write(line); } */ for (Segment segment : segmentSet) { line = segment.getShowName() + " " + segment.getChannel() + " " + segment.getStart(); line += " " + segment.getLength() + " " + gender + " " + segment.getBandwidth(); line += " " + segment.getEnvironement() + " " + name + segment.getInformations() + "\n"; if (segment.getLength() > 0) { dos.write(line); } } }