00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef FST_SCRIPT_RANDEQUIVALENT_H_
00018 #define FST_SCRIPT_RANDEQUIVALENT_H_
00019
00020 #include <fst/script/arg-packs.h>
00021 #include <fst/script/fst-class.h>
00022 #include <fst/script/randgen.h>
00023 #include <fst/randequivalent.h>
00024
00025 namespace fst {
00026 namespace script {
00027
00028
00029 typedef args::Package<const FstClass&, const FstClass&,
00030 int32, float, int, int> RandEquivalentInnerArgs1;
00031 typedef args::WithReturnValue<bool,
00032 RandEquivalentInnerArgs1> RandEquivalentArgs1;
00033
00034 template<class Arc>
00035 void RandEquivalent(RandEquivalentArgs1 *args) {
00036 const Fst<Arc> &fst1 = *(args->args.arg1.GetFst<Arc>());
00037 const Fst<Arc> &fst2 = *(args->args.arg2.GetFst<Arc>());
00038
00039 args->retval = RandEquivalent(fst1, fst2, args->args.arg3, args->args.arg4,
00040 args->args.arg5, args->args.arg6);
00041 }
00042
00043
00044 typedef args::Package<const FstClass &, const FstClass &, int32,
00045 ssize_t, float,
00046 const RandGenOptions<RandArcSelection> &>
00047 RandEquivalentInnerArgs2;
00048
00049 typedef args::WithReturnValue<bool,
00050 RandEquivalentInnerArgs2> RandEquivalentArgs2;
00051
00052 template<class Arc>
00053 void RandEquivalent(RandEquivalentArgs2 *args) {
00054 const Fst<Arc> &fst1 = *(args->args.arg1.GetFst<Arc>());
00055 const Fst<Arc> &fst2 = *(args->args.arg2.GetFst<Arc>());
00056 const RandGenOptions<RandArcSelection> &opts = args->args.arg6;
00057 int32 seed = args->args.arg3;
00058
00059 if (opts.arc_selector == UNIFORM_ARC_SELECTOR) {
00060 UniformArcSelector<Arc> arc_selector(seed);
00061 RandGenOptions< UniformArcSelector<Arc> >
00062 ropts(arc_selector, opts.max_length, opts.npath);
00063
00064 args->retval = RandEquivalent(fst1, fst2, args->args.arg4,
00065 args->args.arg5, ropts);
00066 } else if (opts.arc_selector == FAST_LOG_PROB_ARC_SELECTOR) {
00067 FastLogProbArcSelectorGuard<Arc> arc_selector(seed);
00068 RandGenOptions< FastLogProbArcSelectorGuard<Arc> >
00069 ropts(arc_selector, opts.max_length, opts.npath);
00070
00071 args->retval = RandEquivalent(fst1, fst2, args->args.arg4,
00072 args->args.arg5, ropts);
00073 } else {
00074 LogProbArcSelectorGuard<Arc> arc_selector(seed);
00075 RandGenOptions< LogProbArcSelectorGuard<Arc> >
00076 ropts(arc_selector, opts.max_length, opts.npath);
00077 args->retval = RandEquivalent(fst1, fst2, args->args.arg4,
00078 args->args.arg5, ropts);
00079 }
00080 }
00081
00082
00083
00084 bool RandEquivalent(const FstClass &fst1,
00085 const FstClass &fst2,
00086 int32 seed = time(0),
00087 ssize_t num_paths = 1,
00088 float delta = fst::kDelta,
00089 int path_length = INT_MAX);
00090
00091
00092 bool RandEquivalent(const FstClass &fst1,
00093 const FstClass &fst2,
00094 int32 seed,
00095 ssize_t num_paths,
00096 float delta,
00097 const fst::RandGenOptions<
00098 fst::script::RandArcSelection> &opts);
00099
00100 }
00101 }
00102
00103
00104
00105 #endif /// FST_SCRIPT_RANDEQUIVALENT_H_
00106