Ejemplo n.º 1
0
        internal virtual void benchmark()
        {
            int num = 0;

            [email protected]("benchmarking ...");
            TimerPool.getTimer(this, "hmmPoolBenchmark").start();
            for (int i = 0; i < 1000000; i++)
            {
                int[]         array    = HMMPool.ids;
                int           num2     = i;
                int           num3     = HMMPool.ids.Length;
                int           unitID   = array[(num3 != -1) ? (num2 % num3) : 0];
                HMMPosition[] array2   = HMMPool.pos;
                int           num4     = i;
                int           num5     = HMMPool.pos.Length;
                HMMPosition   position = array2[(num5 != -1) ? (num4 % num5) : 0];
                if (this.getHMM(unitID, position) == null)
                {
                    num++;
                }
            }
            TimerPool.getTimer(this, "hmmPoolBenchmark").stop();
            [email protected](new StringBuilder().append("null count ").append(num).toString());
        }
Ejemplo n.º 2
0
        public virtual HMM getHMM(Unit @base, Unit lc, Unit rc, HMMPosition pos)
        {
            int id  = this.getID(@base);
            int id2 = this.getID(lc);
            int id3 = this.getID(rc);

            if (!this.isValidID(id))
            {
                this.logger.severe(new StringBuilder().append("Bad HMM Unit: ").append(@base.getName()).toString());
                return(null);
            }
            if (!this.isValidID(id2))
            {
                this.logger.severe(new StringBuilder().append("Bad HMM Unit: ").append(lc.getName()).toString());
                return(null);
            }
            if (!this.isValidID(id3))
            {
                this.logger.severe(new StringBuilder().append("Bad HMM Unit: ").append(rc.getName()).toString());
                return(null);
            }
            int num = this.buildID(id, id2, id3);

            if (num < 0)
            {
                this.logger.severe(new StringBuilder().append("Unable to build HMM Unit ID for ").append(@base.getName()).append(" lc=").append(lc.getName()).append(" rc=").append(rc.getName()).toString());
                return(null);
            }
            HMM hmm = this.getHMM(num, pos);

            if (hmm == null)
            {
                this.logger.severe(new StringBuilder().append("Missing HMM Unit for ").append(@base.getName()).append(" lc=").append(lc.getName()).append(" rc=").append(rc.getName()).toString());
            }
            return(hmm);
        }
Ejemplo n.º 3
0
        static HMMPosition()
        {
            int num = 0;

            HMMPosition[] array = HMMPosition.values();
            int           num2  = array.Length;

            for (int i = 0; i < num2; i++)
            {
                HMMPosition hmmposition = array[i];
                if ((int)String.instancehelper_charAt(hmmposition.rep, 0) > num)
                {
                    num = (int)String.instancehelper_charAt(hmmposition.rep, 0);
                }
            }
            HMMPosition.posByRep = new HMMPosition[num + 1];
            array = HMMPosition.values();
            num2  = array.Length;
            for (int i = 0; i < num2; i++)
            {
                HMMPosition hmmposition = array[i];
                HMMPosition.posByRep[(int)String.instancehelper_charAt(hmmposition.rep, 0)] = hmmposition;
            }
        }
Ejemplo n.º 4
0
 public abstract HMM lookupNearestHMM(Unit u, HMMPosition hmmp, bool b);
Ejemplo n.º 5
0
        public HMMPool(AcousticModel model, Logger logger, UnitManager unitManager)
        {
            this.logger = logger;
            int num = 0;

            this.model       = model;
            this.unitManager = unitManager;
            if (model.getLeftContextSize() != 1)
            {
                string text = "LexTreeLinguist: Unsupported left context size";

                throw new Error(text);
            }
            if (model.getRightContextSize() != 1)
            {
                string text2 = "LexTreeLinguist: Unsupported right context size";

                throw new Error(text2);
            }
            Iterator iterator = model.getContextIndependentUnitIterator();

            while (iterator.hasNext())
            {
                Unit unit = (Unit)iterator.next();
                logger.fine(new StringBuilder().append("CI unit ").append(unit).toString());
                if (unit.getBaseID() > num)
                {
                    num = unit.getBaseID();
                }
            }
            this.numCIUnits = num + 1;
            this.unitTable  = new Unit[this.numCIUnits * this.numCIUnits * this.numCIUnits];
            iterator        = model.getHMMIterator();
            while (iterator.hasNext())
            {
                HMM  hmm   = (HMM)iterator.next();
                Unit unit2 = hmm.getUnit();
                int  id    = this.getID(unit2);
                this.unitTable[id] = unit2;
                if (logger.isLoggable(Level.FINER))
                {
                    logger.finer(new StringBuilder().append("Unit ").append(unit2).append(" id ").append(id).toString());
                }
            }
            this.hmmTable = new EnumMap(ClassLiteral <HMMPosition> .Value);
            HMMPosition[] array = HMMPosition.values();
            int           num2  = array.Length;

            for (int i = 0; i < num2; i++)
            {
                HMMPosition hmmposition = array[i];
                HMM[]       array2      = new HMM[this.unitTable.Length];
                this.hmmTable.put(hmmposition, array2);
                for (int j = 1; j < this.unitTable.Length; j++)
                {
                    Unit unit3 = this.unitTable[j];
                    if (unit3 == null)
                    {
                        unit3 = this.synthesizeUnit(j);
                    }
                    if (unit3 != null)
                    {
                        array2[j] = model.lookupNearestHMM(unit3, hmmposition, false);
                        if (!HMMPool.assertionsDisabled && array2[j] == null)
                        {
                            throw new AssertionError();
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
 public virtual HMM getHMM(int unitID, HMMPosition position)
 {
     return(((HMM[])this.hmmTable.get(position))[unitID]);
 }