token.java
来自「It is the Speech recognition software. 」· Java 代码 · 共 594 行 · 第 1/2 页
JAVA
594 行
*/ public void setWorkingScore(float logScore) { logWorkingScore = logScore; } /** * Sets the score for this token * * @param logScore the new score for the token (in logMath log * base) */ public void setScore(float logScore) { this.logTotalScore = logScore; } /** * Returns the language score associated with this token * * @return the language score (in logMath log base) */ public float getLanguageScore() { return logLanguageScore; } /** * Returns the insertionPenalty associated with this token * * @return the insertion probability (in logMath log base) */ public float getInsertionProbability() { return logInsertionProbability; } /** * Returns the acoustic score for this token (in logMath log base) */ public float getAcousticScore() { return logAcousticScore; } /** * Returns the SearchState associated with this token * * @return the searchState */ public SearchState getSearchState() { return searchState; } /** * Determines if this token is associated with an emitting state. * An emitting state is a state that can be scored acoustically. * * @return <code>true</code> if this token is associated with an * emitting state */ public boolean isEmitting() { return searchState.isEmitting(); } /** * Determines if this token is associated with a final SentenceHMM state. * * @return <code>true</code> if this token is associated with a * final state */ public boolean isFinal() { return searchState.isFinal(); } /** * Determines if this token marks the end of a word * * @return <code>true</code> if this token marks the end of a word */ public boolean isWord() { return searchState instanceof WordSearchState; } /** * Retrieves the string representation of this object * * @return the string representation of this object */ public String toString() { String appString = ""; if (appObject != null) { appString = " " + appObject.toString(); } return numFmt.format(getFrameNumber()) + " " + scoreFmt.format(getScore()) + " " + scoreFmt.format(getAcousticScore()) + " " + scoreFmt.format(getLanguageScore()) + " " + scoreFmt.format(getInsertionProbability()) + " " + getSearchState() + appString; } /** * dumps a branch of tokens */ public void dumpTokenPath() { dumpTokenPath(true); } /** * dumps a branch of tokens * * @param includeHMMStates if true include all sentence hmm states */ public void dumpTokenPath(boolean includeHMMStates) { Token token = this; List list = new ArrayList(); while (token != null) { list.add(token); token = token.getPredecessor(); } for (int i = list.size() - 1; i >= 0; i--) { token = (Token) list.get(i); if (includeHMMStates || (!(token.getSearchState() instanceof HMMSearchState))) { System.out.println(" " + token); } } System.out.println(); } /** * Returns the string of words leading up to this token. * * @param wantFiller if true, filler words are added * * @return the word path */ public String getWordPath(boolean wantFiller) { StringBuffer sb = new StringBuffer(); Token token = this; while (token != null) { if (token.isWord()) { WordSearchState wordState = (WordSearchState) token.getSearchState(); Word word = wordState.getPronunciation().getWord(); if (wantFiller || !word.isFiller()) { sb.insert(0, word.getSpelling()); sb.insert(0, " "); } } token = token.getPredecessor(); } return sb.toString().trim(); } /** * Returns the string of words for this token, with no embedded * filler words * * @return the string of words */ public String getWordPathNoFiller() { return getWordPath(false); } /** * Returns the string of words for this token, with embedded * silences * * @return the string of words */ public String getWordPath() { return getWordPath(true); } /** * Returns the string of words and units for this token, with * embedded silences. * * @return the string of words and units */ public String getWordUnitPath() { StringBuffer sb = new StringBuffer(); Token token = this; while (token != null) { SearchState searchState = token.getSearchState(); if (searchState instanceof WordSearchState) { WordSearchState wordState = (WordSearchState) searchState; Word word = wordState.getPronunciation().getWord(); sb.insert(0, " " + word.getSpelling()); } else if (searchState instanceof UnitSearchState) { UnitSearchState unitState = (UnitSearchState) searchState; Unit unit = unitState.getUnit(); sb.insert(0, " " + unit.getName()); } token = token.getPredecessor(); } return sb.toString().trim(); } /** * Returns the word of this Token, the search state is a WordSearchState. * If the search state is not a WordSearchState, return null. * * @return the word of this Token, or null if this is not a word token */ public Word getWord() { if (isWord()) { WordSearchState wordState = (WordSearchState) searchState; return wordState.getPronunciation().getWord(); } else { return null; } } /** * Shows the token count */ public static void showCount() { System.out.println("Cur count: " + curCount + " new " + (curCount - lastCount)); lastCount = curCount; } /** * Returns the location of this Token in the ActiveList. * In the HeapActiveList implementation, it is the index of the * Token in the array backing the heap. * * @return the location of this Token in the ActiveList */ public final int getLocation() { return location; } /** * Sets the location of this Token in the ActiveList. * * @param location the location of this Token */ public final void setLocation(int location) { this.location = location; } /** * Determines if this branch is valid * * @return true if the token and its predecessors are valid */ public boolean validate() { return true; } /** * Return the DecimalFormat object for formatting the print out * of scores. * * @return the DecimalFormat object for formatting score print outs */ protected static DecimalFormat getScoreFormat() { return scoreFmt; } /** * Return the DecimalFormat object for formatting the print out * of numbers * * @return the DecimalFormat object for formatting number print outs */ protected static DecimalFormat getNumberFormat() { return numFmt; } /** * Returns the application object * * @return the application object */ public Object getAppObject() { return appObject; } /** * Sets the application object * * @param obj the application object */ public void setAppObject(Object obj) { appObject = obj; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?