diff options
author | Ian Hodson <idh@google.com> | 2012-05-30 21:27:06 +0100 |
---|---|---|
committer | Ian Hodson <idh@google.com> | 2012-05-30 22:47:36 +0100 |
commit | f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2 (patch) | |
tree | b131ed907f9b2d5af09c0983b651e9e69bc6aab9 /src/script | |
parent | a92766f0a6ba4fac46cd6fd3856ef20c3b204f0d (diff) | |
download | openfst-f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2.tar.gz |
Add openfst to external, as used by GoogleTTSandroid-sdk-support_r11android-cts-4.2_r2android-cts-4.2_r1android-cts-4.1_r4android-cts-4.1_r2android-cts-4.1_r1android-4.2_r1android-4.2.2_r1.2android-4.2.2_r1.1android-4.2.2_r1android-4.2.1_r1.2android-4.2.1_r1.1android-4.2.1_r1android-4.1.2_r2.1android-4.1.2_r2android-4.1.2_r1android-4.1.1_r6.1android-4.1.1_r6android-4.1.1_r5android-4.1.1_r4android-4.1.1_r3android-4.1.1_r2android-4.1.1_r1.1android-4.1.1_r1tools_r22tools_r21jb-releasejb-mr1.1-releasejb-mr1.1-dev-plus-aospjb-mr1.1-devjb-mr1-releasejb-mr1-dev-plus-aospjb-mr1-devjb-mr0-releasejb-dev
Moved from GoogleTTS
Change-Id: I6bc6bdadaa53bd0f810b88443339f6d899502cc8
Diffstat (limited to 'src/script')
43 files changed, 2565 insertions, 0 deletions
diff --git a/src/script/Makefile.am b/src/script/Makefile.am new file mode 100644 index 0000000..00d52a5 --- /dev/null +++ b/src/script/Makefile.am @@ -0,0 +1,15 @@ +AM_CPPFLAGS = -I$(srcdir)/../include $(ICU_CPPFLAGS) + +if HAVE_SCRIPT +lib_LTLIBRARIES = libfstscript.la +libfstscript_la_SOURCES = arcsort.cc closure.cc compile.cc compose.cc \ +concat.cc connect.cc convert.cc decode.cc determinize.cc difference.cc \ +draw.cc encode.cc epsnormalize.cc equal.cc equivalent.cc fst-class.cc \ +info.cc intersect.cc invert.cc map.cc minimize.cc print.cc project.cc \ +prune.cc push.cc randequivalent.cc randgen.cc relabel.cc replace.cc \ +reverse.cc reweight.cc rmepsilon.cc script-impl.cc shortest-distance.cc \ +shortest-path.cc synchronize.cc text-io.cc topsort.cc union.cc \ +weight-class.cc verify.cc + +libfstscript_la_LDFLAGS = -version-info 0:0:0 +endif diff --git a/src/script/Makefile.in b/src/script/Makefile.in new file mode 100644 index 0000000..bab82dc --- /dev/null +++ b/src/script/Makefile.in @@ -0,0 +1,601 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = src/script +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_icu.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/src/include/fst/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__installdirs = "$(DESTDIR)$(libdir)" +LTLIBRARIES = $(lib_LTLIBRARIES) +libfstscript_la_LIBADD = +am__libfstscript_la_SOURCES_DIST = arcsort.cc closure.cc compile.cc \ + compose.cc concat.cc connect.cc convert.cc decode.cc \ + determinize.cc difference.cc draw.cc encode.cc epsnormalize.cc \ + equal.cc equivalent.cc fst-class.cc info.cc intersect.cc \ + invert.cc map.cc minimize.cc print.cc project.cc prune.cc \ + push.cc randequivalent.cc randgen.cc relabel.cc replace.cc \ + reverse.cc reweight.cc rmepsilon.cc script-impl.cc \ + shortest-distance.cc shortest-path.cc synchronize.cc \ + text-io.cc topsort.cc union.cc weight-class.cc verify.cc +@HAVE_SCRIPT_TRUE@am_libfstscript_la_OBJECTS = arcsort.lo closure.lo \ +@HAVE_SCRIPT_TRUE@ compile.lo compose.lo concat.lo connect.lo \ +@HAVE_SCRIPT_TRUE@ convert.lo decode.lo determinize.lo \ +@HAVE_SCRIPT_TRUE@ difference.lo draw.lo encode.lo \ +@HAVE_SCRIPT_TRUE@ epsnormalize.lo equal.lo equivalent.lo \ +@HAVE_SCRIPT_TRUE@ fst-class.lo info.lo intersect.lo invert.lo \ +@HAVE_SCRIPT_TRUE@ map.lo minimize.lo print.lo project.lo \ +@HAVE_SCRIPT_TRUE@ prune.lo push.lo randequivalent.lo \ +@HAVE_SCRIPT_TRUE@ randgen.lo relabel.lo replace.lo reverse.lo \ +@HAVE_SCRIPT_TRUE@ reweight.lo rmepsilon.lo script-impl.lo \ +@HAVE_SCRIPT_TRUE@ shortest-distance.lo shortest-path.lo \ +@HAVE_SCRIPT_TRUE@ synchronize.lo text-io.lo topsort.lo \ +@HAVE_SCRIPT_TRUE@ union.lo weight-class.lo verify.lo +libfstscript_la_OBJECTS = $(am_libfstscript_la_OBJECTS) +libfstscript_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(libfstscript_la_LDFLAGS) $(LDFLAGS) -o $@ +@HAVE_SCRIPT_TRUE@am_libfstscript_la_rpath = -rpath $(libdir) +DEFAULT_INCLUDES = +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libfstscript_la_SOURCES) +DIST_SOURCES = $(am__libfstscript_la_SOURCES_DIST) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +ICU_CFLAGS = @ICU_CFLAGS@ +ICU_CONFIG = @ICU_CONFIG@ +ICU_CPPFLAGS = @ICU_CPPFLAGS@ +ICU_CXXFLAGS = @ICU_CXXFLAGS@ +ICU_LIBS = @ICU_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +libfstdir = @libfstdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AM_CPPFLAGS = -I$(srcdir)/../include $(ICU_CPPFLAGS) +@HAVE_SCRIPT_TRUE@lib_LTLIBRARIES = libfstscript.la +@HAVE_SCRIPT_TRUE@libfstscript_la_SOURCES = arcsort.cc closure.cc compile.cc compose.cc \ +@HAVE_SCRIPT_TRUE@concat.cc connect.cc convert.cc decode.cc determinize.cc difference.cc \ +@HAVE_SCRIPT_TRUE@draw.cc encode.cc epsnormalize.cc equal.cc equivalent.cc fst-class.cc \ +@HAVE_SCRIPT_TRUE@info.cc intersect.cc invert.cc map.cc minimize.cc print.cc project.cc \ +@HAVE_SCRIPT_TRUE@prune.cc push.cc randequivalent.cc randgen.cc relabel.cc replace.cc \ +@HAVE_SCRIPT_TRUE@reverse.cc reweight.cc rmepsilon.cc script-impl.cc shortest-distance.cc \ +@HAVE_SCRIPT_TRUE@shortest-path.cc synchronize.cc text-io.cc topsort.cc union.cc \ +@HAVE_SCRIPT_TRUE@weight-class.cc verify.cc + +@HAVE_SCRIPT_TRUE@libfstscript_la_LDFLAGS = -version-info 0:0:0 +all: all-am + +.SUFFIXES: +.SUFFIXES: .cc .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/script/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/script/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libfstscript.la: $(libfstscript_la_OBJECTS) $(libfstscript_la_DEPENDENCIES) + $(libfstscript_la_LINK) $(am_libfstscript_la_rpath) $(libfstscript_la_OBJECTS) $(libfstscript_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arcsort.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/closure.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compile.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compose.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/concat.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connect.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/convert.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/decode.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/determinize.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/difference.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/draw.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encode.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epsnormalize.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/equal.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/equivalent.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fst-class.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/info.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/intersect.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/invert.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/map.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/minimize.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/project.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prune.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/push.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/randequivalent.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/randgen.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/relabel.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/replace.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reverse.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reweight.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rmepsilon.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/script-impl.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shortest-distance.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shortest-path.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/synchronize.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/text-io.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/topsort.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/union.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verify.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/weight-class.Plo@am__quote@ + +.cc.o: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cc.obj: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cc.lo: +@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: + for dir in "$(DESTDIR)$(libdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libLTLIBRARIES + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-libLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libLTLIBRARIES clean-libtool ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am \ + install-libLTLIBRARIES install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-libLTLIBRARIES + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/script/arcsort.cc b/src/script/arcsort.cc new file mode 100644 index 0000000..42c13a0 --- /dev/null +++ b/src/script/arcsort.cc @@ -0,0 +1,35 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/arcsort.h> +#include <fst/script/script-impl.h> + +namespace fst { +namespace script { + +void ArcSort(MutableFstClass *fst, ArcSortType sort_type) { + ArcSortArgs args(fst, sort_type); + + Apply<Operation<ArcSortArgs> >("ArcSort", fst->ArcType(), &args); +} + +REGISTER_FST_OPERATION(ArcSort, StdArc, ArcSortArgs); +REGISTER_FST_OPERATION(ArcSort, LogArc, ArcSortArgs); +REGISTER_FST_OPERATION(ArcSort, Log64Arc, ArcSortArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/closure.cc b/src/script/closure.cc new file mode 100644 index 0000000..85ad1fc --- /dev/null +++ b/src/script/closure.cc @@ -0,0 +1,35 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/closure.h> + +namespace fst { +namespace script { + +void Closure(MutableFstClass *fst, ClosureType closure_type) { + ClosureArgs args(fst, closure_type); + + Apply<Operation<ClosureArgs> >("Closure", fst->ArcType(), &args); +} + +REGISTER_FST_OPERATION(Closure, StdArc, ClosureArgs); +REGISTER_FST_OPERATION(Closure, LogArc, ClosureArgs); +REGISTER_FST_OPERATION(Closure, Log64Arc, ClosureArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/compile.cc b/src/script/compile.cc new file mode 100644 index 0000000..57a84b3 --- /dev/null +++ b/src/script/compile.cc @@ -0,0 +1,43 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <string> + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/compile.h> + +namespace fst { +namespace script { + +void CompileFst(istream &istrm, const string &source, const string &dest, + const string &fst_type, const string &arc_type, + const SymbolTable *isyms, + const SymbolTable *osyms, const SymbolTable *ssyms, + bool accep, bool ikeep, bool okeep, bool nkeep, + bool allow_negative_labels) { + FstCompileArgs args(istrm, source, dest, fst_type, isyms, osyms, ssyms, + accep, ikeep, okeep, nkeep, allow_negative_labels); + + Apply<Operation<FstCompileArgs> >("CompileFst", arc_type, &args); +} + +REGISTER_FST_OPERATION(CompileFst, StdArc, FstCompileArgs); +REGISTER_FST_OPERATION(CompileFst, LogArc, FstCompileArgs); +REGISTER_FST_OPERATION(CompileFst, Log64Arc, FstCompileArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/compose.cc b/src/script/compose.cc new file mode 100644 index 0000000..2a363c1 --- /dev/null +++ b/src/script/compose.cc @@ -0,0 +1,51 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/compose.h> + +namespace fst { +namespace script { + + +void Compose(const FstClass &ifst1, const FstClass &ifst2, + MutableFstClass *ofst, ComposeFilter compose_filter) { + if (!ArcTypesMatch(ifst1, ifst2, "Compose") || + !ArcTypesMatch(*ofst, ifst1, "Compose")) return; + + ComposeArgs1 args(ifst1, ifst2, ofst, compose_filter); + Apply<Operation<ComposeArgs1> >("Compose", ifst1.ArcType(), &args); +} + +void Compose(const FstClass &ifst1, const FstClass &ifst2, + MutableFstClass *ofst, const ComposeOptions &copts) { + if (!ArcTypesMatch(ifst1, ifst2, "Compose") || + !ArcTypesMatch(*ofst, ifst1, "Compose")) return; + + ComposeArgs2 args(ifst1, ifst2, ofst, copts); + Apply<Operation<ComposeArgs2> >("Compose", ifst1.ArcType(), &args); +} + +REGISTER_FST_OPERATION(Compose, StdArc, ComposeArgs1); +REGISTER_FST_OPERATION(Compose, LogArc, ComposeArgs1); +REGISTER_FST_OPERATION(Compose, Log64Arc, ComposeArgs1); +REGISTER_FST_OPERATION(Compose, StdArc, ComposeArgs2); +REGISTER_FST_OPERATION(Compose, LogArc, ComposeArgs2); +REGISTER_FST_OPERATION(Compose, Log64Arc, ComposeArgs2); + +} // namespace script +} // namespace fst diff --git a/src/script/concat.cc b/src/script/concat.cc new file mode 100644 index 0000000..7df4091 --- /dev/null +++ b/src/script/concat.cc @@ -0,0 +1,48 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/concat.h> + +namespace fst { +namespace script { + +void Concat(MutableFstClass *ofst, const FstClass &ifst) { + if (!ArcTypesMatch(*ofst, ifst, "Concat")) return; + + ConcatArgs1 args(ofst, ifst); + + Apply<Operation<ConcatArgs1> >("Concat", ofst->ArcType(), &args); +} + +void Concat(const FstClass &ifst, MutableFstClass *ofst) { + if (!ArcTypesMatch(ifst, *ofst, "Concat")) return; + + ConcatArgs2 args(ifst, ofst); + + Apply<Operation<ConcatArgs2> >("Concat", ofst->ArcType(), &args); +} + +REGISTER_FST_OPERATION(Concat, StdArc, ConcatArgs1); +REGISTER_FST_OPERATION(Concat, LogArc, ConcatArgs1); +REGISTER_FST_OPERATION(Concat, Log64Arc, ConcatArgs1); +REGISTER_FST_OPERATION(Concat, StdArc, ConcatArgs2); +REGISTER_FST_OPERATION(Concat, LogArc, ConcatArgs2); +REGISTER_FST_OPERATION(Concat, Log64Arc, ConcatArgs2); + +} // namespace script +} // namespace fst diff --git a/src/script/connect.cc b/src/script/connect.cc new file mode 100644 index 0000000..177592a --- /dev/null +++ b/src/script/connect.cc @@ -0,0 +1,33 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/connect.h> + +namespace fst { +namespace script { + +void Connect(MutableFstClass *fst) { + Apply<Operation<MutableFstClass> >("Connect", fst->ArcType(), fst); +} + +REGISTER_FST_OPERATION(Connect, StdArc, MutableFstClass); +REGISTER_FST_OPERATION(Connect, LogArc, MutableFstClass); +REGISTER_FST_OPERATION(Connect, Log64Arc, MutableFstClass); + +} // namespace script +} // namespace fst diff --git a/src/script/convert.cc b/src/script/convert.cc new file mode 100644 index 0000000..c651063 --- /dev/null +++ b/src/script/convert.cc @@ -0,0 +1,40 @@ + + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/convert.h> + +namespace fst { +namespace script { + +FstClass *Convert(const FstClass &ifst, const string &new_type) { + ConvertInnerArgs args(ifst, new_type); + ConvertArgs args_with_retval(args); + + Apply<Operation<ConvertArgs> >("Convert", ifst.ArcType(), + &args_with_retval); + + return args_with_retval.retval; +} + +REGISTER_FST_OPERATION(Convert, StdArc, ConvertArgs); +REGISTER_FST_OPERATION(Convert, LogArc, ConvertArgs); +REGISTER_FST_OPERATION(Convert, Log64Arc, ConvertArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/decode.cc b/src/script/decode.cc new file mode 100644 index 0000000..2e38f7f --- /dev/null +++ b/src/script/decode.cc @@ -0,0 +1,36 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/decode.h> +#include <fst/encode.h> + +namespace fst { +namespace script { + +void Decode(MutableFstClass *ofst, const string &coder_fname) { + DecodeArgs args(ofst, coder_fname); + + Apply<Operation<DecodeArgs> >("Decode", ofst->ArcType(), &args); +} + +REGISTER_FST_OPERATION(Decode, StdArc, DecodeArgs); +REGISTER_FST_OPERATION(Decode, LogArc, DecodeArgs); +REGISTER_FST_OPERATION(Decode, Log64Arc, DecodeArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/determinize.cc b/src/script/determinize.cc new file mode 100644 index 0000000..e1c6759 --- /dev/null +++ b/src/script/determinize.cc @@ -0,0 +1,38 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/determinize.h> + +namespace fst { +namespace script { + +void Determinize(const FstClass &ifst, + MutableFstClass *ofst, + const DeterminizeOptions& opts) { + if (!ArcTypesMatch(ifst, *ofst, "Determinize")) return; + + DeterminizeArgs args(ifst, ofst, opts); + Apply<Operation<DeterminizeArgs> >("Determinize", ifst.ArcType(), &args); +} + +REGISTER_FST_OPERATION(Determinize, StdArc, DeterminizeArgs); +REGISTER_FST_OPERATION(Determinize, LogArc, DeterminizeArgs); +REGISTER_FST_OPERATION(Determinize, Log64Arc, DeterminizeArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/difference.cc b/src/script/difference.cc new file mode 100644 index 0000000..1fcfa3e --- /dev/null +++ b/src/script/difference.cc @@ -0,0 +1,50 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/difference.h> + +namespace fst { +namespace script { + +void Difference(const FstClass &ifst1, const FstClass &ifst2, + MutableFstClass *ofst, ComposeFilter compose_filter) { + if (!ArcTypesMatch(ifst1, ifst2, "Difference") || + !ArcTypesMatch(*ofst, ifst1, "Difference")) return; + + DifferenceArgs1 args(ifst1, ifst2, ofst, compose_filter); + Apply<Operation<DifferenceArgs1> >("Difference", ifst1.ArcType(), &args); +} + +void Difference(const FstClass &ifst1, const FstClass &ifst2, + MutableFstClass *ofst, const ComposeOptions &copts) { + if (!ArcTypesMatch(ifst1, ifst2, "Difference") || + !ArcTypesMatch(*ofst, ifst1, "Difference")) return; + + DifferenceArgs2 args(ifst1, ifst2, ofst, copts); + Apply<Operation<DifferenceArgs2> >("Difference", ifst1.ArcType(), &args); +} + +REGISTER_FST_OPERATION(Difference, StdArc, DifferenceArgs1); +REGISTER_FST_OPERATION(Difference, LogArc, DifferenceArgs1); +REGISTER_FST_OPERATION(Difference, Log64Arc, DifferenceArgs1); +REGISTER_FST_OPERATION(Difference, StdArc, DifferenceArgs2); +REGISTER_FST_OPERATION(Difference, LogArc, DifferenceArgs2); +REGISTER_FST_OPERATION(Difference, Log64Arc, DifferenceArgs2); + +} // namespace script +} // namespace fst diff --git a/src/script/draw.cc b/src/script/draw.cc new file mode 100644 index 0000000..b51c8b7 --- /dev/null +++ b/src/script/draw.cc @@ -0,0 +1,55 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <string> + +#include <fst/script/fst-class.h> +#include <fst/script/draw.h> +#include <fst/script/script-impl.h> + +namespace fst { +namespace script { + +void DrawFst(const FstClass &fst, + const SymbolTable *isyms, + const SymbolTable *osyms, + const SymbolTable *ssyms, + bool accep, + const string &title, + float width, + float height, + bool portrait, + bool vertical, + float ranksep, + float nodesep, + int fontsize, + int precision, + bool show_weight_one, + ostream *ostrm, + const string &dest) { + FstDrawerArgs args(fst, isyms, osyms, ssyms, accep, title, width, + height, portrait, vertical, ranksep, nodesep, + fontsize, precision, show_weight_one, ostrm, dest); + + Apply<Operation<FstDrawerArgs> >("DrawFst", fst.ArcType(), &args); +} + +REGISTER_FST_OPERATION(DrawFst, StdArc, FstDrawerArgs); +REGISTER_FST_OPERATION(DrawFst, LogArc, FstDrawerArgs); +REGISTER_FST_OPERATION(DrawFst, Log64Arc, FstDrawerArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/encode.cc b/src/script/encode.cc new file mode 100644 index 0000000..1464b34 --- /dev/null +++ b/src/script/encode.cc @@ -0,0 +1,37 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/encode.h> +#include <fst/script/encode.h> + +namespace fst { +namespace script { + +void Encode(MutableFstClass *ofst, uint32 flags, bool reuse_encoder, + const string &coder_fname) { + EncodeArgs args(ofst, flags, reuse_encoder, coder_fname); + + Apply<Operation<EncodeArgs> >("Encode", ofst->ArcType(), &args); +} + +REGISTER_FST_OPERATION(Encode, StdArc, EncodeArgs); +REGISTER_FST_OPERATION(Encode, LogArc, EncodeArgs); +REGISTER_FST_OPERATION(Encode, Log64Arc, EncodeArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/epsnormalize.cc b/src/script/epsnormalize.cc new file mode 100644 index 0000000..ee9bbdf --- /dev/null +++ b/src/script/epsnormalize.cc @@ -0,0 +1,37 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/epsnormalize.h> + +namespace fst { +namespace script { + +void EpsNormalize(const FstClass &ifst, MutableFstClass *ofst, + EpsNormalizeType norm_type) { + if (!ArcTypesMatch(ifst, *ofst, "EpsNormalize")) return; + + EpsNormalizeArgs args(ifst, ofst, norm_type); + Apply<Operation<EpsNormalizeArgs> >("EpsNormalize", ifst.ArcType(), &args); +} + +REGISTER_FST_OPERATION(EpsNormalize, StdArc, EpsNormalizeArgs); +REGISTER_FST_OPERATION(EpsNormalize, LogArc, EpsNormalizeArgs); +REGISTER_FST_OPERATION(EpsNormalize, Log64Arc, EpsNormalizeArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/equal.cc b/src/script/equal.cc new file mode 100644 index 0000000..da481a5 --- /dev/null +++ b/src/script/equal.cc @@ -0,0 +1,40 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/equal.h> + +namespace fst { +namespace script { + +bool Equal(const FstClass &fst1, const FstClass &fst2, float kDelta) { + if (!ArcTypesMatch(fst1, fst2, "Equal")) return false; + + EqualInnerArgs args(fst1, fst2, kDelta); + EqualArgs args_with_retval(args); + + Apply<Operation<EqualArgs> >("Equal", fst1.ArcType(), &args_with_retval); + + return args_with_retval.retval; +} + +REGISTER_FST_OPERATION(Equal, StdArc, EqualArgs); +REGISTER_FST_OPERATION(Equal, LogArc, EqualArgs); +REGISTER_FST_OPERATION(Equal, Log64Arc, EqualArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/equivalent.cc b/src/script/equivalent.cc new file mode 100644 index 0000000..bc0f785 --- /dev/null +++ b/src/script/equivalent.cc @@ -0,0 +1,42 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/equivalent.h> + +namespace fst { +namespace script { + +bool Equivalent(const FstClass &fst1, const FstClass &fst2, + float delta) { + if (!ArcTypesMatch(fst1, fst2, "Equivalent")) return false; + + EquivalentInnerArgs args(fst1, fst2, kDelta); + EquivalentArgs args_with_retval(args); + + Apply<Operation<EquivalentArgs> >("Equivalent", fst1.ArcType(), + &args_with_retval); + + return args_with_retval.retval; +} + +REGISTER_FST_OPERATION(Equivalent, StdArc, EquivalentArgs); +REGISTER_FST_OPERATION(Equivalent, LogArc, EquivalentArgs); +REGISTER_FST_OPERATION(Equivalent, Log64Arc, EquivalentArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/fst-class.cc b/src/script/fst-class.cc new file mode 100644 index 0000000..a784b08 --- /dev/null +++ b/src/script/fst-class.cc @@ -0,0 +1,141 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +// These classes are only recommended for use in high-level scripting +// applications. Most users should use the lower-level templated versions +// corresponding to these classes. + +#include <fst/script/fst-class.h> +#include <fst/script/register.h> +#include <fst/fst-decl.h> +#include <fst/union.h> +#include <fst/reverse.h> +#include <fst/equal.h> + +namespace fst { +namespace script { + +// +// REGISTRATION +// + +REGISTER_FST_CLASSES(StdArc); +REGISTER_FST_CLASSES(LogArc); +REGISTER_FST_CLASSES(Log64Arc); + +// +// FST CLASS METHODS +// + +template<class FstT> +FstT *ReadFst(istream &in, const string &fname) { + if (!in) { + LOG(ERROR) << "ReadFst: Can't open file: " << fname; + return 0; + } + + FstHeader hdr; + if (!hdr.Read(in, fname)) { + return 0; + } + + FstReadOptions read_options(fname, &hdr); + + typename IORegistration<FstT>::Register *reg = + IORegistration<FstT>::Register::GetRegister(); + + const typename IORegistration<FstT>::Reader reader = + reg->GetReader(hdr.ArcType()); + + if (!reader) { + LOG(ERROR) << "ReadFst : unknown arc type \"" + << hdr.ArcType() << "\" : " << read_options.source; + return 0; + } + + return reader(in, read_options); +} + +FstClass *FstClass::Read(const string &fname) { + if (!fname.empty()) { + ifstream in(fname.c_str(), ifstream::in | ifstream::binary); + return ReadFst<FstClass>(in, fname); + } else { + return ReadFst<FstClass>(std::cin, "standard input"); + } +} + +// +// MUTABLE FST CLASS METHODS +// + +MutableFstClass *MutableFstClass::Read(const string &fname, bool convert) { + if (convert == false) { + if (!fname.empty()) { + ifstream in(fname.c_str(), ifstream::in | ifstream::binary); + return ReadFst<MutableFstClass>(in, fname); + } else { + return ReadFst<MutableFstClass>(std::cin, "standard input"); + } + } else { // Converts to VectorFstClass if not mutable. + FstClass *ifst = FstClass::Read(fname); + if (!ifst) return 0; + if (ifst->Properties(fst::kMutable, false)) { + return static_cast<MutableFstClass *>(ifst); + } else { + MutableFstClass *ofst = new VectorFstClass(*ifst); + delete ifst; + return ofst; + } + } +} + +// +// VECTOR FST CLASS METHODS +// + +IORegistration<VectorFstClass>::Entry GetVFSTRegisterEntry( + const string &arc_type) { + IORegistration<VectorFstClass>::Register *reg = + IORegistration<VectorFstClass>::Register::GetRegister(); + const IORegistration<VectorFstClass>::Entry &entry = reg->GetEntry(arc_type); + + if (entry.converter == 0) { + LOG(ERROR) << "Unknown arc type " << arc_type; + return entry; + } + + return entry; +} + +VectorFstClass::VectorFstClass(const FstClass &other) + : MutableFstClass(GetVFSTRegisterEntry(other.ArcType()).converter(other)) { +} + +VectorFstClass::VectorFstClass(const string &arc_type) + : MutableFstClass(GetVFSTRegisterEntry(arc_type).creator()) { } + +VectorFstClass *VectorFstClass::Read(const string &fname) { + if (!fname.empty()) { + ifstream in(fname.c_str(), ifstream::in | ifstream::binary); + return ReadFst<VectorFstClass>(in, fname); + } else { + return ReadFst<VectorFstClass>(std::cin, "standard input"); + } +} + +} // namespace script +} // namespace fst diff --git a/src/script/info.cc b/src/script/info.cc new file mode 100644 index 0000000..018f46b --- /dev/null +++ b/src/script/info.cc @@ -0,0 +1,39 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <string> + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/info.h> + +namespace fst { +namespace script { + +void PrintFstInfo(const FstClass &f, bool test_properties, + const string &arc_filter, const string &info_type, + bool pipe, bool verify) { + InfoArgs args(f, test_properties, arc_filter, info_type, pipe, verify); + + Apply<Operation<InfoArgs> >("PrintFstInfo", f.ArcType(), &args); +} + +REGISTER_FST_OPERATION(PrintFstInfo, StdArc, InfoArgs); +REGISTER_FST_OPERATION(PrintFstInfo, LogArc, InfoArgs); +REGISTER_FST_OPERATION(PrintFstInfo, Log64Arc, InfoArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/intersect.cc b/src/script/intersect.cc new file mode 100644 index 0000000..acb9c49 --- /dev/null +++ b/src/script/intersect.cc @@ -0,0 +1,50 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/intersect.h> + +namespace fst { +namespace script { + +void Intersect(const FstClass &ifst1, const FstClass &ifst2, + MutableFstClass *ofst, ComposeFilter compose_filter) { + if (!ArcTypesMatch(ifst1, ifst2, "Intersect") || + !ArcTypesMatch(*ofst, ifst1, "Intersect")) return; + + IntersectArgs1 args(ifst1, ifst2, ofst, compose_filter); + Apply<Operation<IntersectArgs1> >("Intersect", ifst1.ArcType(), &args); +} + +void Intersect(const FstClass &ifst1, const FstClass &ifst2, + MutableFstClass *ofst, const ComposeOptions &copts) { + if (!ArcTypesMatch(ifst1, ifst2, "Intersect") || + !ArcTypesMatch(*ofst, ifst1, "Intersect")) return; + + IntersectArgs2 args(ifst1, ifst2, ofst, copts); + Apply<Operation<IntersectArgs2> >("Intersect", ifst1.ArcType(), &args); +} + +REGISTER_FST_OPERATION(Intersect, StdArc, IntersectArgs1); +REGISTER_FST_OPERATION(Intersect, LogArc, IntersectArgs1); +REGISTER_FST_OPERATION(Intersect, Log64Arc, IntersectArgs1); +REGISTER_FST_OPERATION(Intersect, StdArc, IntersectArgs2); +REGISTER_FST_OPERATION(Intersect, LogArc, IntersectArgs2); +REGISTER_FST_OPERATION(Intersect, Log64Arc, IntersectArgs2); + +} // namespace script +} // namespace fst diff --git a/src/script/invert.cc b/src/script/invert.cc new file mode 100644 index 0000000..a82f44d --- /dev/null +++ b/src/script/invert.cc @@ -0,0 +1,33 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/invert.h> + +namespace fst { +namespace script { + +void Invert(MutableFstClass *fst) { + Apply<Operation<MutableFstClass> >("Invert", fst->ArcType(), fst); +} + +REGISTER_FST_OPERATION(Invert, StdArc, MutableFstClass); +REGISTER_FST_OPERATION(Invert, LogArc, MutableFstClass); +REGISTER_FST_OPERATION(Invert, Log64Arc, MutableFstClass); + +} // namespace script +} // namespace fst diff --git a/src/script/map.cc b/src/script/map.cc new file mode 100644 index 0000000..2ef1086 --- /dev/null +++ b/src/script/map.cc @@ -0,0 +1,39 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/map.h> + +namespace fst { +namespace script { + +FstClass *Map(const FstClass& ifst, MapType map_type, + float delta, const WeightClass &w) { + MapInnerArgs args(ifst, map_type, delta, w); + MapArgs args_with_retval(args); + + Apply<Operation<MapArgs> >("Map", ifst.ArcType(), &args_with_retval); + + return args_with_retval.retval; +} + +REGISTER_FST_OPERATION(Map, StdArc, MapArgs); +REGISTER_FST_OPERATION(Map, LogArc, MapArgs); +REGISTER_FST_OPERATION(Map, Log64Arc, MapArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/minimize.cc b/src/script/minimize.cc new file mode 100644 index 0000000..461d20a --- /dev/null +++ b/src/script/minimize.cc @@ -0,0 +1,36 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/minimize.h> + +namespace fst { +namespace script { + +void Minimize(MutableFstClass *ofst1, MutableFstClass *ofst2, float delta) { + if (ofst2 && !ArcTypesMatch(*ofst1, *ofst2, "Minimize")) return; + MinimizeArgs args(ofst1, ofst2, delta); + + Apply<Operation<MinimizeArgs> >("Minimize", ofst1->ArcType(), &args); +} + +REGISTER_FST_OPERATION(Minimize, StdArc, MinimizeArgs); +REGISTER_FST_OPERATION(Minimize, LogArc, MinimizeArgs); +REGISTER_FST_OPERATION(Minimize, Log64Arc, MinimizeArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/print.cc b/src/script/print.cc new file mode 100644 index 0000000..4277d20 --- /dev/null +++ b/src/script/print.cc @@ -0,0 +1,41 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <string> + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/print.h> + +namespace fst { +namespace script { + +void PrintFst(const FstClass &fst, ostream &ostrm, const string &dest, + const SymbolTable *isyms, + const SymbolTable *osyms, + const SymbolTable *ssyms, + bool accept, bool show_weight_one) { + FstPrinterArgs args(fst, isyms, osyms, ssyms, accept, show_weight_one, + &ostrm, dest); + Apply<Operation<FstPrinterArgs> >("PrintFst", fst.ArcType(), &args); +} + +REGISTER_FST_OPERATION(PrintFst, StdArc, FstPrinterArgs); +REGISTER_FST_OPERATION(PrintFst, LogArc, FstPrinterArgs); +REGISTER_FST_OPERATION(PrintFst, Log64Arc, FstPrinterArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/project.cc b/src/script/project.cc new file mode 100644 index 0000000..690684a --- /dev/null +++ b/src/script/project.cc @@ -0,0 +1,35 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/project.h> + +namespace fst { +namespace script { + +void Project(MutableFstClass *ofst, ProjectType project_type) { + ProjectArgs args(ofst, project_type); + + Apply<Operation<ProjectArgs> >("Project", ofst->ArcType(), &args); +} + +REGISTER_FST_OPERATION(Project, StdArc, ProjectArgs); +REGISTER_FST_OPERATION(Project, LogArc, ProjectArgs); +REGISTER_FST_OPERATION(Project, Log64Arc, ProjectArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/prune.cc b/src/script/prune.cc new file mode 100644 index 0000000..36ca22f --- /dev/null +++ b/src/script/prune.cc @@ -0,0 +1,76 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/prune.h> + +namespace fst { +namespace script { + + +// 1 +void Prune(MutableFstClass *fst, const PruneOptions &opts) { + PruneArgs1 args(fst, opts); + + Apply<Operation<PruneArgs1> >("Prune", fst->ArcType(), &args); +} + +// 2 +void Prune(const FstClass &ifst, MutableFstClass *fst, + const PruneOptions &opts) { + PruneArgs2 args(ifst, fst, opts); + + Apply<Operation<PruneArgs2> >("Prune", fst->ArcType(), &args); +} + +// 3 +void Prune(const FstClass &ifst, + MutableFstClass *ofst, + const WeightClass& weight_threshold, + int64 state_threshold, float delta) { + PruneArgs3 args(ifst, ofst, weight_threshold, state_threshold, delta); + + Apply<Operation<PruneArgs3> >("Prune", ifst.ArcType(), &args); +} + +// 4 +void Prune(MutableFstClass *fst, const WeightClass& weight_threshold, + int64 state_threshold, float delta) { + PruneArgs4 args(fst, weight_threshold, state_threshold, delta); + + Apply<Operation<PruneArgs4> >("Prune", fst->ArcType(), &args); +} + +// 1 +REGISTER_FST_OPERATION(Prune, StdArc, PruneArgs1); +REGISTER_FST_OPERATION(Prune, LogArc, PruneArgs1); +REGISTER_FST_OPERATION(Prune, Log64Arc, PruneArgs1); +// 2 +REGISTER_FST_OPERATION(Prune, StdArc, PruneArgs2); +REGISTER_FST_OPERATION(Prune, LogArc, PruneArgs2); +REGISTER_FST_OPERATION(Prune, Log64Arc, PruneArgs2); +// 3 +REGISTER_FST_OPERATION(Prune, StdArc, PruneArgs3); +REGISTER_FST_OPERATION(Prune, LogArc, PruneArgs3); +REGISTER_FST_OPERATION(Prune, Log64Arc, PruneArgs3); +// 4 +REGISTER_FST_OPERATION(Prune, StdArc, PruneArgs4); +REGISTER_FST_OPERATION(Prune, LogArc, PruneArgs4); +REGISTER_FST_OPERATION(Prune, Log64Arc, PruneArgs4); + +} // namespace script +} // namespace fst diff --git a/src/script/push.cc b/src/script/push.cc new file mode 100644 index 0000000..ed3d1d0 --- /dev/null +++ b/src/script/push.cc @@ -0,0 +1,49 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/push.h> + +namespace fst { +namespace script { + +// 1 +void Push(MutableFstClass *ofst, ReweightType dir, float delta, + bool remove_total_weight) { + PushArgs1 args(ofst, dir, delta, remove_total_weight); + Apply<Operation<PushArgs1> >("Push", ofst->ArcType(), &args); +} + +// 2 +void Push(const FstClass &ifst, MutableFstClass *ofst, uint32 flags, + ReweightType dir, float delta) { + if (!ArcTypesMatch(ifst, *ofst, "Push")) return; + + PushArgs2 args(ifst, ofst, flags, dir, delta); + Apply<Operation<PushArgs2> >("Push", ifst.ArcType(), &args); +} + + +REGISTER_FST_OPERATION(Push, StdArc, PushArgs1); +REGISTER_FST_OPERATION(Push, LogArc, PushArgs1); +REGISTER_FST_OPERATION(Push, Log64Arc, PushArgs1); +REGISTER_FST_OPERATION(Push, StdArc, PushArgs2); +REGISTER_FST_OPERATION(Push, LogArc, PushArgs2); +REGISTER_FST_OPERATION(Push, Log64Arc, PushArgs2); + +} // namespace script +} // namespace fst diff --git a/src/script/randequivalent.cc b/src/script/randequivalent.cc new file mode 100644 index 0000000..eb44ee9 --- /dev/null +++ b/src/script/randequivalent.cc @@ -0,0 +1,61 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/randequivalent.h> + +namespace fst { +namespace script { + +// 1 +bool RandEquivalent(const FstClass &fst1, const FstClass &fst2, + int32 seed, ssize_t num_paths, float delta, + int path_length) { + if (!ArcTypesMatch(fst1, fst2, "RandEquivalent")) return false; + RandEquivalentInnerArgs1 args(fst1, fst2, seed, num_paths, delta, + path_length); + RandEquivalentArgs1 args_with_retval(args); + + Apply<Operation<RandEquivalentArgs1> >("RandEquivalent", fst1.ArcType(), + &args_with_retval); + return args_with_retval.retval; +} + +// 2 +bool RandEquivalent(const FstClass &fst1, const FstClass &fst2, int32 seed, + ssize_t num_paths, float delta, + const RandGenOptions<RandArcSelection> &opts) { + if (!ArcTypesMatch(fst1, fst2, "RandEquivalent")) return false; + + RandEquivalentInnerArgs2 args(fst1, fst2, seed, num_paths, delta, opts); + RandEquivalentArgs2 args_with_retval(args); + + Apply<Operation<RandEquivalentArgs2> >( + "RandEquivalent", fst1.ArcType(), &args_with_retval); + + return args_with_retval.retval; +} + +REGISTER_FST_OPERATION(RandEquivalent, StdArc, RandEquivalentArgs1); +REGISTER_FST_OPERATION(RandEquivalent, LogArc, RandEquivalentArgs1); +REGISTER_FST_OPERATION(RandEquivalent, Log64Arc, RandEquivalentArgs1); +REGISTER_FST_OPERATION(RandEquivalent, StdArc, RandEquivalentArgs2); +REGISTER_FST_OPERATION(RandEquivalent, LogArc, RandEquivalentArgs2); +REGISTER_FST_OPERATION(RandEquivalent, Log64Arc, RandEquivalentArgs2); + +} // namespace script +} // namespace fst diff --git a/src/script/randgen.cc b/src/script/randgen.cc new file mode 100644 index 0000000..f0efc63 --- /dev/null +++ b/src/script/randgen.cc @@ -0,0 +1,37 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/randgen.h> + +namespace fst { +namespace script { + +void RandGen(const FstClass &ifst, MutableFstClass *ofst, int32 seed, + const RandGenOptions<RandArcSelection> &opts) { + if (!ArcTypesMatch(ifst, *ofst, "RandGen")) return; + + RandGenArgs args(ifst, ofst, seed, opts); + Apply<Operation<RandGenArgs> >("RandGen", ifst.ArcType(), &args); +} + +REGISTER_FST_OPERATION(RandGen, StdArc, RandGenArgs); +REGISTER_FST_OPERATION(RandGen, LogArc, RandGenArgs); +REGISTER_FST_OPERATION(RandGen, Log64Arc, RandGenArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/relabel.cc b/src/script/relabel.cc new file mode 100644 index 0000000..a214079 --- /dev/null +++ b/src/script/relabel.cc @@ -0,0 +1,68 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/relabel.h> + +namespace fst { +namespace script { + +// 1 +void Relabel(MutableFstClass *ofst, + const SymbolTable *old_isyms, const SymbolTable *relabel_isyms, + bool attach_new_isyms, + const SymbolTable *old_osyms, const SymbolTable *relabel_osyms, + bool attach_new_osyms) { + RelabelArgs1 args(ofst, old_isyms, relabel_isyms, attach_new_isyms, + old_osyms, relabel_osyms, attach_new_osyms); + Apply<Operation<RelabelArgs1> >("Relabel", ofst->ArcType(), &args); +} + +// 2 +void Relabel(MutableFstClass *ofst, + const vector<pair<int64, int64> > &ipairs, + const vector<pair<int64, int64> > &opairs) { + RelabelArgs2 args(ofst, ipairs, opairs); + + Apply<Operation<RelabelArgs2> >("Relabel", ofst->ArcType(), &args); +} + +// 3 +void Relabel(MutableFstClass *fst, + const SymbolTable *new_isymbols, + const SymbolTable *new_osymbols) { + RelabelArgs3 args(fst, new_isymbols, new_osymbols); + Apply<Operation<RelabelArgs3> >("Relabel", fst->ArcType(), &args); +} + +// 1 +REGISTER_FST_OPERATION(Relabel, StdArc, RelabelArgs1); +REGISTER_FST_OPERATION(Relabel, LogArc, RelabelArgs1); +REGISTER_FST_OPERATION(Relabel, Log64Arc, RelabelArgs1); + +// 2 +REGISTER_FST_OPERATION(Relabel, StdArc, RelabelArgs2); +REGISTER_FST_OPERATION(Relabel, LogArc, RelabelArgs2); +REGISTER_FST_OPERATION(Relabel, Log64Arc, RelabelArgs2); + +// 3 +REGISTER_FST_OPERATION(Relabel, StdArc, RelabelArgs3); +REGISTER_FST_OPERATION(Relabel, LogArc, RelabelArgs3); +REGISTER_FST_OPERATION(Relabel, Log64Arc, RelabelArgs3); + +} // namespace script +} // namespace fst diff --git a/src/script/replace.cc b/src/script/replace.cc new file mode 100644 index 0000000..40c09be --- /dev/null +++ b/src/script/replace.cc @@ -0,0 +1,45 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/replace.h> + +namespace fst { +namespace script { + +void Replace(const vector<pair<int64, const FstClass *> > &tuples, + MutableFstClass *ofst, const int64 &root, + bool epsilon_on_replace) { + for (unsigned i = 0; i < tuples.size() - 1; ++i) { + if (!ArcTypesMatch(*tuples[i].second, *tuples[i+1].second, "Replace")) { + return; + } + } + + if (!ArcTypesMatch(*tuples[0].second, *ofst, "Replace")) return; + + ReplaceArgs args(tuples, ofst, root, epsilon_on_replace); + + Apply<Operation<ReplaceArgs> >("Replace", ofst->ArcType(), &args); +} + +REGISTER_FST_OPERATION(Replace, StdArc, ReplaceArgs); +REGISTER_FST_OPERATION(Replace, LogArc, ReplaceArgs); +REGISTER_FST_OPERATION(Replace, Log64Arc, ReplaceArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/reverse.cc b/src/script/reverse.cc new file mode 100644 index 0000000..c1c7305 --- /dev/null +++ b/src/script/reverse.cc @@ -0,0 +1,37 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/reverse.h> + +namespace fst { +namespace script { + +void Reverse(const FstClass &fst1, MutableFstClass *fst2) { + if (!ArcTypesMatch(fst1, *fst2, "Reverse")) return; + + ReverseArgs args(fst1, fst2); + + Apply<Operation<ReverseArgs> >("Reverse", fst1.ArcType(), &args); +} + +REGISTER_FST_OPERATION(Reverse, StdArc, ReverseArgs); +REGISTER_FST_OPERATION(Reverse, LogArc, ReverseArgs); +REGISTER_FST_OPERATION(Reverse, Log64Arc, ReverseArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/reweight.cc b/src/script/reweight.cc new file mode 100644 index 0000000..8f2dfd5 --- /dev/null +++ b/src/script/reweight.cc @@ -0,0 +1,36 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/reweight.h> + +namespace fst { +namespace script { + +void Reweight(MutableFstClass *fst, const vector<WeightClass> &potential, + ReweightType reweight_type) { + ReweightArgs args(fst, potential, reweight_type); + + Apply<Operation<ReweightArgs> >("Reweight", fst->ArcType(), &args); +} + +REGISTER_FST_OPERATION(Reweight, StdArc, ReweightArgs); +REGISTER_FST_OPERATION(Reweight, LogArc, ReweightArgs); +REGISTER_FST_OPERATION(Reweight, Log64Arc, ReweightArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/rmepsilon.cc b/src/script/rmepsilon.cc new file mode 100644 index 0000000..4d217ea --- /dev/null +++ b/src/script/rmepsilon.cc @@ -0,0 +1,61 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/rmepsilon.h> + +namespace fst { +namespace script { + +void RmEpsilon(const FstClass &ifst, MutableFstClass *ofst, + bool reverse, const RmEpsilonOptions &opts) { + if (!ArcTypesMatch(ifst, *ofst, "RmEpsilon")) return; + + RmEpsilonArgs1 args(ifst, ofst, reverse, opts); + + Apply<Operation<RmEpsilonArgs1> >("RmEpsilon", ifst.ArcType(), &args); +} + +void RmEpsilon(MutableFstClass *fst, bool connect, + const WeightClass &weight_threshold, + int64 state_threshold, float delta) { + RmEpsilonArgs2 args(fst, connect, weight_threshold, state_threshold, delta); + + Apply<Operation<RmEpsilonArgs2> >("RmEpsilon", fst->ArcType(), &args); +} + +void RmEpsilon(MutableFstClass *fst, vector<WeightClass> *distance, + const RmEpsilonOptions &opts) { + RmEpsilonArgs3 args(fst, distance, opts); + + Apply<Operation<RmEpsilonArgs3> >("RmEpsilon", fst->ArcType(), &args); +} + +REGISTER_FST_OPERATION(RmEpsilon, StdArc, RmEpsilonArgs1); +REGISTER_FST_OPERATION(RmEpsilon, LogArc, RmEpsilonArgs1); +REGISTER_FST_OPERATION(RmEpsilon, Log64Arc, RmEpsilonArgs1); + +REGISTER_FST_OPERATION(RmEpsilon, StdArc, RmEpsilonArgs2); +REGISTER_FST_OPERATION(RmEpsilon, LogArc, RmEpsilonArgs2); +REGISTER_FST_OPERATION(RmEpsilon, Log64Arc, RmEpsilonArgs2); + +REGISTER_FST_OPERATION(RmEpsilon, StdArc, RmEpsilonArgs3); +REGISTER_FST_OPERATION(RmEpsilon, LogArc, RmEpsilonArgs3); +REGISTER_FST_OPERATION(RmEpsilon, Log64Arc, RmEpsilonArgs3); + +} // namespace script +} // namespace fst diff --git a/src/script/script-impl.cc b/src/script/script-impl.cc new file mode 100644 index 0000000..96cac72 --- /dev/null +++ b/src/script/script-impl.cc @@ -0,0 +1,39 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <string> + +#include <fst/script/script-impl.h> + +namespace fst { +namespace script { + +// +// Utility function for checking that arc types match. +// +bool ArcTypesMatch(const FstClass &a, const FstClass &b, + const string &op_name) { + if (a.ArcType() != b.ArcType()) { + LOG(ERROR) << "FSTs with non-matching arc types passed to " << op_name + << ":\n\t" << a.ArcType() << " and " << b.ArcType(); + return false; + } else { + return true; + } +} + +} // namespace script +} // namespace fst diff --git a/src/script/shortest-distance.cc b/src/script/shortest-distance.cc new file mode 100644 index 0000000..49ee09b --- /dev/null +++ b/src/script/shortest-distance.cc @@ -0,0 +1,66 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/shortest-distance.h> + +namespace fst { +namespace script { + +// 1 +void ShortestDistance(const FstClass &fst, vector<WeightClass> *distance, + const ShortestDistanceOptions &opts) { + ShortestDistanceArgs1 args(fst, distance, opts); + + Apply<Operation<ShortestDistanceArgs1> >("ShortestDistance", fst.ArcType(), + &args); +} + +// 2 +void ShortestDistance(const FstClass &ifst, vector<WeightClass> *distance, + bool reverse, double delta) { + ShortestDistanceArgs2 args(ifst, distance, reverse, delta); + + Apply<Operation<ShortestDistanceArgs2> >("ShortestDistance", ifst.ArcType(), + &args); +} + +// 3 +WeightClass ShortestDistance(const FstClass &ifst) { + ShortestDistanceArgs3 args(ifst); + + Apply<Operation<ShortestDistanceArgs3> >("ShortestDistance", ifst.ArcType(), + &args); + + return args.retval; +} + +REGISTER_FST_OPERATION(ShortestDistance, StdArc, ShortestDistanceArgs1); +REGISTER_FST_OPERATION(ShortestDistance, LogArc, ShortestDistanceArgs1); +REGISTER_FST_OPERATION(ShortestDistance, Log64Arc, ShortestDistanceArgs1); + +REGISTER_FST_OPERATION(ShortestDistance, StdArc, ShortestDistanceArgs2); +REGISTER_FST_OPERATION(ShortestDistance, LogArc, ShortestDistanceArgs2); +REGISTER_FST_OPERATION(ShortestDistance, Log64Arc, ShortestDistanceArgs2); + +REGISTER_FST_OPERATION(ShortestDistance, StdArc, ShortestDistanceArgs3); +REGISTER_FST_OPERATION(ShortestDistance, LogArc, ShortestDistanceArgs3); +REGISTER_FST_OPERATION(ShortestDistance, Log64Arc, ShortestDistanceArgs3); + + +} // namespace script +} // namespace fst diff --git a/src/script/shortest-path.cc b/src/script/shortest-path.cc new file mode 100644 index 0000000..75749a0 --- /dev/null +++ b/src/script/shortest-path.cc @@ -0,0 +1,53 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/shortest-path.h> + +namespace fst { +namespace script { + +void ShortestPath(const FstClass &ifst, MutableFstClass *ofst, + vector<WeightClass> *distance, + const ShortestPathOptions &opts) { + if (!ArcTypesMatch(ifst, *ofst, "ShortestPath")) return; + + ShortestPathArgs1 args(ifst, ofst, distance, opts); + Apply<Operation<ShortestPathArgs1> >("ShortestPath", ifst.ArcType(), &args); +} + +void ShortestPath(const FstClass &ifst, MutableFstClass *ofst, + size_t n, bool unique, bool first_path, + WeightClass weight_threshold, int64 state_threshold) { + if (!ArcTypesMatch(ifst, *ofst, "ShortestPath")) return; + + ShortestPathArgs2 args(ifst, ofst, n, unique, first_path, weight_threshold, + state_threshold); + Apply<Operation<ShortestPathArgs2> >("ShortestPath", ifst.ArcType(), &args); +} + + +REGISTER_FST_OPERATION(ShortestPath, StdArc, ShortestPathArgs1); +REGISTER_FST_OPERATION(ShortestPath, LogArc, ShortestPathArgs1); +REGISTER_FST_OPERATION(ShortestPath, Log64Arc, ShortestPathArgs1); + +REGISTER_FST_OPERATION(ShortestPath, StdArc, ShortestPathArgs2); +REGISTER_FST_OPERATION(ShortestPath, LogArc, ShortestPathArgs2); +REGISTER_FST_OPERATION(ShortestPath, Log64Arc, ShortestPathArgs2); + +} // namespace script +} // namespace fst diff --git a/src/script/synchronize.cc b/src/script/synchronize.cc new file mode 100644 index 0000000..edb09c6 --- /dev/null +++ b/src/script/synchronize.cc @@ -0,0 +1,36 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/synchronize.h> + +namespace fst { +namespace script { + +void Synchronize(const FstClass &ifst, MutableFstClass *ofst) { + if (!ArcTypesMatch(ifst, *ofst, "Synchronize")) return; + + SynchronizeArgs args(ifst, ofst); + Apply<Operation<SynchronizeArgs> >("Synchronize", ifst.ArcType(), &args); +} + +REGISTER_FST_OPERATION(Synchronize, StdArc, SynchronizeArgs); +REGISTER_FST_OPERATION(Synchronize, LogArc, SynchronizeArgs); +REGISTER_FST_OPERATION(Synchronize, Log64Arc, SynchronizeArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/text-io.cc b/src/script/text-io.cc new file mode 100644 index 0000000..2f5efab --- /dev/null +++ b/src/script/text-io.cc @@ -0,0 +1,95 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/text-io.h> + +#include <cstring> +#include <sstream> +#include <utility> +using std::pair; using std::make_pair; + +#include <fst/types.h> +#include <fst/util.h> + +namespace fst { +namespace script { + +// Reads vector of weights; returns true on success. +bool ReadPotentials(const string &weight_type, + const string& filename, + vector<WeightClass>* potential) { + ifstream strm(filename.c_str()); + if (!strm) { + LOG(ERROR) << "ReadPotentials: Can't open file: " << filename; + return false; + } + + const int kLineLen = 8096; + char line[kLineLen]; + size_t nline = 0; + + potential->clear(); + while (strm.getline(line, kLineLen)) { + ++nline; + vector<char *> col; + SplitToVector(line, "\n\t ", &col, true); + if (col.size() == 0 || col[0][0] == '\0') // empty line + continue; + if (col.size() != 2) { + LOG(ERROR) << "ReadPotentials: Bad number of columns, " + << "file = " << filename << ", line = " << nline; + return false; + } + + ssize_t s = StrToInt64(col[0], filename, nline, false); + WeightClass weight(weight_type, col[1]); + + while (potential->size() <= s) + potential->push_back(WeightClass::Zero()); + (*potential)[s] = weight; + } + return true; +} + +// Writes vector of weights; returns true on success. +bool WritePotentials(const string& filename, + const vector<WeightClass>& potential) { + ostream *strm = &std::cout; + if (!filename.empty()) { + strm = new ofstream(filename.c_str()); + if (!*strm) { + LOG(ERROR) << "WritePotentials: Can't open file: " << filename; + delete strm; + return false; + } + } + + strm->precision(9); + for (ssize_t s = 0; s < potential.size(); ++s) + *strm << s << "\t" << potential[s] << "\n"; + + if (!*strm) + LOG(ERROR) << "WritePotentials: Write failed: " + << (filename.empty() ? "standard output" : filename); + bool ret = *strm; + if (strm != &std::cout) + delete strm; + return ret; +} + + +} // namespace script +} // namespace fst diff --git a/src/script/topsort.cc b/src/script/topsort.cc new file mode 100644 index 0000000..65cc85c --- /dev/null +++ b/src/script/topsort.cc @@ -0,0 +1,37 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/topsort.h> + +namespace fst { +namespace script { + +bool TopSort(MutableFstClass *fst) { + TopSortArgs args(fst); + + Apply<Operation<TopSortArgs> >("TopSort", fst->ArcType(), &args); + + return args.retval; +} + +REGISTER_FST_OPERATION(TopSort, StdArc, TopSortArgs); +REGISTER_FST_OPERATION(TopSort, LogArc, TopSortArgs); +REGISTER_FST_OPERATION(TopSort, Log64Arc, TopSortArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/union.cc b/src/script/union.cc new file mode 100644 index 0000000..21b8a44 --- /dev/null +++ b/src/script/union.cc @@ -0,0 +1,37 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/union.h> + +namespace fst { +namespace script { + +void Union(MutableFstClass *fst1, const FstClass &fst2) { + if (!ArcTypesMatch(*fst1, fst2, "Union")) return; + + UnionArgs args(fst1, fst2); + + Apply<Operation<UnionArgs> >("Union", fst1->ArcType(), &args); +} + +REGISTER_FST_OPERATION(Union, StdArc, UnionArgs); +REGISTER_FST_OPERATION(Union, LogArc, UnionArgs); +REGISTER_FST_OPERATION(Union, Log64Arc, UnionArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/verify.cc b/src/script/verify.cc new file mode 100644 index 0000000..48e9af4 --- /dev/null +++ b/src/script/verify.cc @@ -0,0 +1,37 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <fst/script/fst-class.h> +#include <fst/script/script-impl.h> +#include <fst/script/verify.h> + +namespace fst { +namespace script { + +bool Verify(const FstClass &fst) { + VerifyArgs args(&fst); + + Apply<Operation<VerifyArgs> >("Verify", fst.ArcType(), &args); + + return args.retval; +} + +REGISTER_FST_OPERATION(Verify, StdArc, VerifyArgs); +REGISTER_FST_OPERATION(Verify, LogArc, VerifyArgs); +REGISTER_FST_OPERATION(Verify, Log64Arc, VerifyArgs); + +} // namespace script +} // namespace fst diff --git a/src/script/weight-class.cc b/src/script/weight-class.cc new file mode 100644 index 0000000..2a586d7 --- /dev/null +++ b/src/script/weight-class.cc @@ -0,0 +1,45 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +#include <string> + +#include <fst/arc.h> +#include <fst/script/weight-class.h> + +namespace fst { +namespace script { + +REGISTER_FST_WEIGHT(StdArc::Weight); +REGISTER_FST_WEIGHT(LogArc::Weight); +REGISTER_FST_WEIGHT(Log64Arc::Weight); + +WeightClass::WeightClass(const string &weight_type, + const string &weight_str) + : element_type_(OTHER) { + WeightClassRegister *reg = WeightClassRegister::GetRegister(); + + StrToWeightImplBaseT stw = reg->GetEntry(weight_type); + + impl_ = stw(weight_str, "WeightClass", 0); +}; + +ostream& operator << (ostream &o, const WeightClass &c) { + c.impl_->Print(&o); + return o; +} + +} // namespace script +} // namespace fst |