Package edu.cmu.sphinx.linguist.dictionary

Examples of edu.cmu.sphinx.linguist.dictionary.Word


        if (token.isWord()) {

            int endFrame = token.getFrameNumber();

            WordSearchState wordState = (WordSearchState) token.getSearchState();
            Word word = wordState.getPronunciation().getWord();
            String spelling = word.getSpelling();
            if (!spelling.startsWith("<")) {
                String[] names = utt.name.split("_");
                out.write((names[0] + '_' + names[1] + '_' + names[2]
                        + " 1 " + (utt.startOffset + startFrame) / 100.0 + ' ' + (endFrame - startFrame) / 100.0 + ' ').getBytes());
                out.write(hex2Binary(spelling));
View Full Code Here


    public String getRandomSentence() {
        StringBuilder sb = new StringBuilder();
        GrammarNode node = getInitialNode();
        while (!node.isFinalNode()) {
            if (!node.isEmpty()) {
                Word word = node.getWord();
                if (!word.isFiller())
                    sb.append(word.getSpelling()).append(' ');
            }
            node = selectRandomSuccessor(node);
        }
        return sb.toString().trim();
    }
View Full Code Here

        GrammarNode node;
        Word[][] alternatives = new Word[alts.length][];
        for (int i = 0; i < alternatives.length; i++) {
            alternatives[i] = new Word[alts[i].length];
            for (int j = 0; j < alts[i].length; j++) {
                Word word = getDictionary().getWord(alts[i][j]);
                // Pronunciation[] pronunciation =
                // word.getPronunciations(null);
                if (word == null) {
                    alternatives = EMPTY_ALTERNATIVE;
                    break;
View Full Code Here

    vistedNodes.add(thisNode);
    if (thisNode.isFinalNode()) {
      unitSet.add(UnitManager.SILENCE);
    } else if (!thisNode.isEmpty()) {
      Word word = thisNode.getWord();
      Pronunciation[] pronunciations = word.getPronunciations();
      for (Pronunciation pronunciation : pronunciations) {
        unitSet.add(pronunciation.getUnits()[0]);
      }
    } else {
      GrammarArc[] arcs = thisNode.getSuccessors();
View Full Code Here

     * @param word     the word for this grammar node
     */
    protected GrammarNode createGrammarNode(int identity, String word) {
        GrammarNode node;
        Word[][] alternatives = EMPTY_ALTERNATIVE;
        Word wordObject = getDictionary().getWord(word);
        // Pronunciation[] pronunciation = wordObject.getPronunciations(null);
        if (wordObject != null) {
            alternatives = new Word[1][];
            alternatives[0] = new Word[1];
            alternatives[0][0] = wordObject;
View Full Code Here

    /**
     * This method disguises all classes as words.
     */
    public Word getWord(String text) {
        Word word = classMap.getClassAsWord(text);
        return (word != null) ? word : wordDictionary.getWord(text);
    }
View Full Code Here

        vocabulary.addAll(textWords);
        List<Word> words = new ArrayList<Word>();
       
        for (String stringWord : textWords) {
            Word word = dictionary.getWord(stringWord);
            if (word == null) {
                words.add(Word.UNKNOWN);
            } else {
                words.add(word);
            }
View Full Code Here

                        GState gstate = getGState(arc.getGrammarNode());
                        startingContexts.addAll(gstate.getStartingContexts());
                    }
                } else {
//                    int maxSize = getRightContextSize();
                    Word word = node.getWord();
                    Pronunciation[] prons = word.getPronunciations(null);
                    for (Pronunciation pron : prons) {
                        UnitContext startingContext = getStartingContext(pron);
                        startingContexts.add(startingContext);
                    }
                }
View Full Code Here

         */
        Collection<UnitContext> getEndingContexts() {
            Collection<UnitContext> endingContexts = new ArrayList<UnitContext>();
            if (!node.isEmpty()) {
                int maxSize = getLeftContextSize();
                Word word = node.getWord();
                Pronunciation[] prons = word.getPronunciations(null);
                for (Pronunciation pron : prons) {
                    Unit[] units = pron.getUnits();
                    int size = units.length;
                    Unit[] context = size > maxSize ? Arrays.copyOfRange(units, size - maxSize, size) : units;
                    endingContexts.add(UnitContext.get(context));
View Full Code Here

         * Expand the the word given the left context
         *
         * @param leftContext the left context
         */
        private void expandWord(UnitContext leftContext) {
            Word word = node.getWord();
            T("  Expanding word " + word + " for lc " + leftContext);
            Pronunciation[] pronunciations = word.getPronunciations(null);
            for (int i = 0; i < pronunciations.length; i++) {
                expandPronunciation(leftContext, pronunciations[i], i);
            }
        }
View Full Code Here

TOP

Related Classes of edu.cmu.sphinx.linguist.dictionary.Word

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.