/** * Adds the given word into the given string builder with the start and end times from the given * features. * * @param sb the StringBuilder into which the word is added * @param word the word to add * @param startFeature the starting feature * @param endFeature tne ending feature */ private void addWord(StringBuilder sb, Word word, FloatData startFeature, FloatData endFeature) { float startTime = startFeature == null ? -1 : ((float) startFeature.getFirstSampleNumber() / startFeature.getSampleRate()); float endTime = endFeature == null ? -1 : ((float) endFeature.getFirstSampleNumber() / endFeature.getSampleRate()); if (sb.length() > 0) { sb.insert(0, ' '); } sb.insert(0, (word.getSpelling() + '(' + startTime + ',' + endTime + ')')); }
/** * Internal routine used when dumping Lattices as .LAT files * * @param f print writer to store * @throws IOException if error occurred */ void dump(PrintWriter f) throws IOException { f.println( "node: " + id + ' ' + word.getSpelling() + // " a:" + getForwardProb() + " b:" + getBackwardProb() // " p:" + getPosterior()); ' ' + getBeginTime() + ' ' + getEndTime()); }
/** * Returns true if the given node is equivalent to this node. Two nodes are equivalent only if * they have the same word, the same number of entering and leaving edges, and that their begin * and end times are the same. * * @param other the Node we're comparing to * @return true if the Node is equivalent; false otherwise */ public boolean isEquivalent(Node other) { return ((word.getSpelling().equals(other.getWord().getSpelling()) && (getEnteringEdges().size() == other.getEnteringEdges().size() && getLeavingEdges().size() == other.getLeavingEdges().size())) && (getBeginTime() == other.getBeginTime() && endTime == other.getEndTime())); }
/** * Returns a description of this Node that contains the word, the start time, and the end time. * * @return a description of this Node */ @Override public String toString() { return ("Node(" + word.getSpelling() + ',' + getBeginTime() + '|' + getEndTime() + ')'); }