Beispiel #1
0
        public static void a_star_backwards(Floatarray costs_for_all_nodes, IGenericFst fst)
        {
            IGenericFst reverse = FstFactory.MakeOcroFST();

            FstUtil.fst_copy_reverse(reverse, fst, true); // creates an extra vertex
            AStarSearch a = new AStarSearch(reverse);

            a.Loop();
            costs_for_all_nodes.Copy(a.g);
            costs_for_all_nodes.Pop(); // remove the extra vertex
        }
Beispiel #2
0
        public static double beam_search(out string result, Intarray inputs, Floatarray costs, OcroFST fst1, OcroFST fst2,
                                         int beam_width)
        {
            Intarray v1 = new Intarray();
            Intarray v2 = new Intarray();
            Intarray o  = new Intarray();

            //fprintf(stderr,"starting beam search\n");
            beam_search(v1, v2, inputs, o, costs, fst1, fst2, beam_width);
            //fprintf(stderr,"finished beam search\n");
            FstUtil.remove_epsilons(out result, o);
            return(NarrayUtil.Sum(costs));
        }
Beispiel #3
0
        public static double a_star(out string result, OcroFST fst)
        {
            result = "";
            Intarray   inputs   = new Intarray();
            Intarray   vertices = new Intarray();
            Intarray   outputs  = new Intarray();
            Floatarray costs    = new Floatarray();

            if (!a_star(inputs, vertices, outputs, costs, fst))
            {
                return(1e38);
            }
            FstUtil.remove_epsilons(out result, outputs);
            return(NarrayUtil.Sum(costs));
        }
Beispiel #4
0
        public static double a_star(out string result, OcroFST fst1, OcroFST fst2)
        {
            result = "";
            Intarray   inputs  = new Intarray();
            Intarray   v1      = new Intarray();
            Intarray   v2      = new Intarray();
            Intarray   outputs = new Intarray();
            Floatarray costs   = new Floatarray();

            if (!a_star_in_composition(inputs, v1, v2, outputs, costs, fst1, fst2))
            {
                return(1e38);
            }
            FstUtil.remove_epsilons(out result, outputs);
            return(NarrayUtil.Sum(costs));
        }