Esempio n. 1
0
 private void accumulateTransition(int num, int num2, TrainerScore[] array, TrainerScore[] array2)
 {
     if (num == -1)
     {
         Iterator iterator = this.hmmManager.iterator();
         while (iterator.hasNext())
         {
             HMM hmm = (HMM)iterator.next();
             for (int i = 0; i < hmm.getOrder(); i++)
             {
                 this.accumulateStateTransition(i, (SenoneHMM)hmm, array[num2].getScore());
             }
         }
     }
     else if (array2 != null)
     {
         this.accumulateStateTransition(num2, array, array2);
     }
 }
Esempio n. 2
0
        private void saveHMMPool(bool flag, OutputStream outputStream, string text)
        {
            this.logger.info("Saving HMM file to: ");
            this.logger.info(text);
            if (outputStream == null)
            {
                string text2 = new StringBuilder().append("Error trying to write file ").append(this.location).append(text).toString();

                throw new IOException(text2);
            }
            PrintWriter printWriter = new PrintWriter(outputStream, true);
            int         num         = 0;
            int         num2        = 0;
            int         num3        = 0;
            int         num4        = 0;
            Iterator    iterator    = this.hmmManager.iterator();

            while (iterator.hasNext())
            {
                HMM hmm = (HMM)iterator.next();
                num4 += hmm.getOrder() + 1;
                if (((SenoneHMM)hmm).isContextDependent())
                {
                    num2++;
                }
                else
                {
                    num++;
                    num3 += hmm.getOrder();
                }
            }
            printWriter.println("0.3");
            printWriter.println(new StringBuilder().append(num).append(" n_base").toString());
            printWriter.println(new StringBuilder().append(num2).append(" n_tri").toString());
            printWriter.println(new StringBuilder().append(num4).append(" n_state_map").toString());
            int statesNum = this.mixtureWeights.getStatesNum();

            printWriter.println(new StringBuilder().append(statesNum).append(" n_tied_state").toString());
            printWriter.println(new StringBuilder().append(num3).append(" n_tied_ci_state").toString());
            int num5 = num;

            if (!Sphinx3Saver.assertionsDisabled && num5 != this.matrixPool.size())
            {
                throw new AssertionError();
            }
            printWriter.println(new StringBuilder().append(num5).append(" n_tied_tmat").toString());
            printWriter.println("#");
            printWriter.println("# Columns definitions");
            printWriter.println("#base lft  rt p attrib tmat      ... state id's ...");
            Iterator iterator2 = this.hmmManager.iterator();

            while (iterator2.hasNext())
            {
                HMM       hmm2      = (HMM)iterator2.next();
                SenoneHMM senoneHMM = (SenoneHMM)hmm2;
                if (!senoneHMM.isContextDependent())
                {
                    Unit   unit = senoneHMM.getUnit();
                    string name = unit.getName();
                    printWriter.print(new StringBuilder().append(name).append('\t').toString());
                    string text3 = "-";
                    printWriter.print(new StringBuilder().append(text3).append("   ").toString());
                    string text4 = "-";
                    printWriter.print(new StringBuilder().append(text4).append(' ').toString());
                    string text5 = senoneHMM.getPosition().toString();
                    printWriter.print(new StringBuilder().append(text5).append('\t').toString());
                    string text6 = (!unit.isFiller()) ? "n/a" : "filler";
                    printWriter.print(new StringBuilder().append(text6).append('\t').toString());
                    int num6 = this.matrixPool.indexOf(senoneHMM.getTransitionMatrix());
                    if (!Sphinx3Saver.assertionsDisabled && num6 >= num5)
                    {
                        throw new AssertionError();
                    }
                    printWriter.print(new StringBuilder().append(num6).append("\t").toString());
                    SenoneSequence senoneSequence = senoneHMM.getSenoneSequence();
                    Senone[]       senones        = senoneSequence.getSenones();
                    Senone[]       array          = senones;
                    int            num7           = array.Length;
                    for (int i = 0; i < num7; i++)
                    {
                        Senone @object = array[i];
                        int    num8    = this.senonePool.indexOf(@object);
                        if (!Sphinx3Saver.assertionsDisabled && (num8 < 0 || num8 >= num3))
                        {
                            throw new AssertionError();
                        }
                        printWriter.print(new StringBuilder().append(num8).append("\t").toString());
                    }
                    printWriter.println("N");
                    if (this.logger.isLoggable(Level.FINE))
                    {
                        this.logger.fine(new StringBuilder().append("Saved ").append(unit).toString());
                    }
                }
            }
            iterator2 = this.hmmManager.iterator();
            while (iterator2.hasNext())
            {
                HMM       hmm2      = (HMM)iterator2.next();
                SenoneHMM senoneHMM = (SenoneHMM)hmm2;
                if (senoneHMM.isContextDependent())
                {
                    Unit             unit             = senoneHMM.getUnit();
                    LeftRightContext leftRightContext = (LeftRightContext)unit.getContext();
                    Unit[]           leftContext      = leftRightContext.getLeftContext();
                    Unit[]           rightContext     = leftRightContext.getRightContext();
                    if (!Sphinx3Saver.assertionsDisabled && (leftContext.Length != 1 || rightContext.Length != 1))
                    {
                        throw new AssertionError();
                    }
                    string text5 = unit.getName();
                    printWriter.print(new StringBuilder().append(text5).append('\t').toString());
                    string text6 = leftContext[0].getName();
                    printWriter.print(new StringBuilder().append(text6).append("   ").toString());
                    string name2 = rightContext[0].getName();
                    printWriter.print(new StringBuilder().append(name2).append(' ').toString());
                    string text7 = senoneHMM.getPosition().toString();
                    printWriter.print(new StringBuilder().append(text7).append('\t').toString());
                    string text8 = (!unit.isFiller()) ? "n/a" : "filler";
                    if (!Sphinx3Saver.assertionsDisabled && !String.instancehelper_equals(text8, "n/a"))
                    {
                        throw new AssertionError();
                    }
                    printWriter.print(new StringBuilder().append(text8).append('\t').toString());
                    int num9 = this.matrixPool.indexOf(senoneHMM.getTransitionMatrix());
                    if (!Sphinx3Saver.assertionsDisabled && num9 >= num5)
                    {
                        throw new AssertionError();
                    }
                    printWriter.print(new StringBuilder().append(num9).append("\t").toString());
                    SenoneSequence senoneSequence2 = senoneHMM.getSenoneSequence();
                    Senone[]       senones2        = senoneSequence2.getSenones();
                    Senone[]       array2          = senones2;
                    int            num8            = array2.Length;
                    for (int j = 0; j < num8; j++)
                    {
                        Senone object2 = array2[j];
                        int    num10   = this.senonePool.indexOf(object2);
                        if (!Sphinx3Saver.assertionsDisabled && (num10 < 0 || num10 >= statesNum))
                        {
                            throw new AssertionError();
                        }
                        printWriter.print(new StringBuilder().append(num10).append("\t").toString());
                    }
                    printWriter.println("N");
                    if (this.logger.isLoggable(Level.FINE))
                    {
                        this.logger.fine(new StringBuilder().append("Saved ").append(unit).toString());
                    }
                }
            }
            outputStream.close();
        }