aboutsummaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/Makefile.am82
-rw-r--r--src/bin/Makefile.in923
-rw-r--r--src/bin/fstarcsort.cc67
-rw-r--r--src/bin/fstclosure.cc56
-rw-r--r--src/bin/fstcompile.cc92
-rw-r--r--src/bin/fstcompose.cc95
-rw-r--r--src/bin/fstconcat.cc62
-rw-r--r--src/bin/fstconnect.cc52
-rw-r--r--src/bin/fstconvert.cc58
-rw-r--r--src/bin/fstdeterminize.cc68
-rw-r--r--src/bin/fstdifference.cc87
-rw-r--r--src/bin/fstdraw.cc118
-rw-r--r--src/bin/fstencode.cc68
-rw-r--r--src/bin/fstepsnormalize.cc58
-rw-r--r--src/bin/fstequal.cc61
-rw-r--r--src/bin/fstequivalent.cc91
-rw-r--r--src/bin/fstinfo.cc59
-rw-r--r--src/bin/fstintersect.cc88
-rw-r--r--src/bin/fstinvert.cc51
-rw-r--r--src/bin/fstmap.cc97
-rw-r--r--src/bin/fstminimize.cc67
-rw-r--r--src/bin/fstprint.cc105
-rw-r--r--src/bin/fstproject.cc58
-rw-r--r--src/bin/fstprune.cc64
-rw-r--r--src/bin/fstpush.cc77
-rw-r--r--src/bin/fstrandgen.cc82
-rw-r--r--src/bin/fstrelabel.cc117
-rw-r--r--src/bin/fstreplace.cc65
-rw-r--r--src/bin/fstreverse.cc59
-rw-r--r--src/bin/fstreweight.cc63
-rw-r--r--src/bin/fstrmepsilon.cc89
-rw-r--r--src/bin/fstshortestdistance.cc93
-rw-r--r--src/bin/fstshortestpath.cc92
-rw-r--r--src/bin/fstsymbols.cc117
-rw-r--r--src/bin/fstsynchronize.cc54
-rw-r--r--src/bin/fsttopsort.cc53
-rw-r--r--src/bin/fstunion.cc67
37 files changed, 3655 insertions, 0 deletions
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
new file mode 100644
index 0000000..13fc64c
--- /dev/null
+++ b/src/bin/Makefile.am
@@ -0,0 +1,82 @@
+AM_CPPFLAGS = -I$(srcdir)/../include -I$(srcdir)/../script $(ICU_FLAGS)
+LDADD = ../script/libfstscript.la ../lib/libfst.la -lm -ldl
+
+if HAVE_BIN
+bin_PROGRAMS = fstarcsort fstclosure fstcompile fstcompose fstconcat \
+fstconnect fstconvert fstdeterminize fstdifference fstdraw fstencode \
+fstepsnormalize fstequal fstequivalent fstinfo fstintersect fstinvert \
+fstmap fstminimize fstprint fstproject fstprune fstpush fstrandgen \
+fstrelabel fstreplace fstreverse fstreweight fstrmepsilon \
+fstshortestdistance fstshortestpath fstsymbols fstsynchronize fsttopsort \
+fstunion
+
+fstarcsort_SOURCES = fstarcsort.cc
+
+fstclosure_SOURCES = fstclosure.cc
+
+fstcompile_SOURCES = fstcompile.cc
+
+fstcompose_SOURCES = fstcompose.cc
+
+fstconcat_SOURCES = fstconcat.cc
+
+fstconnect_SOURCES = fstconnect.cc
+
+fstconvert_SOURCES = fstconvert.cc
+
+fstdeterminize_SOURCES = fstdeterminize.cc
+
+fstdifference_SOURCES = fstdifference.cc
+
+fstdraw_SOURCES = fstdraw.cc
+
+fstencode_SOURCES = fstencode.cc
+
+fstepsnormalize_SOURCES = fstepsnormalize.cc
+
+fstequal_SOURCES = fstequal.cc
+
+fstequivalent_SOURCES = fstequivalent.cc
+
+fstinfo_SOURCES = fstinfo.cc
+
+fstintersect_SOURCES = fstintersect.cc
+
+fstinvert_SOURCES = fstinvert.cc
+
+fstmap_SOURCES = fstmap.cc
+
+fstminimize_SOURCES = fstminimize.cc
+
+fstprint_SOURCES = fstprint.cc
+
+fstproject_SOURCES = fstproject.cc
+
+fstprune_SOURCES = fstprune.cc
+
+fstpush_SOURCES = fstpush.cc
+
+fstrandgen_SOURCES = fstrandgen.cc
+
+fstrelabel_SOURCES = fstrelabel.cc
+
+fstreplace_SOURCES = fstreplace.cc
+
+fstreverse_SOURCES = fstreverse.cc
+
+fstreweight_SOURCES = fstreweight.cc
+
+fstrmepsilon_SOURCES = fstrmepsilon.cc
+
+fstshortestdistance_SOURCES = fstshortestdistance.cc
+
+fstshortestpath_SOURCES = fstshortestpath.cc
+
+fstsymbols_SOURCES = fstsymbols.cc
+
+fstsynchronize_SOURCES = fstsynchronize.cc
+
+fsttopsort_SOURCES = fsttopsort.cc
+
+fstunion_SOURCES = fstunion.cc
+endif \ No newline at end of file
diff --git a/src/bin/Makefile.in b/src/bin/Makefile.in
new file mode 100644
index 0000000..5d27164
--- /dev/null
+++ b/src/bin/Makefile.in
@@ -0,0 +1,923 @@
+# 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@
+@HAVE_BIN_TRUE@bin_PROGRAMS = fstarcsort$(EXEEXT) fstclosure$(EXEEXT) \
+@HAVE_BIN_TRUE@ fstcompile$(EXEEXT) fstcompose$(EXEEXT) \
+@HAVE_BIN_TRUE@ fstconcat$(EXEEXT) fstconnect$(EXEEXT) \
+@HAVE_BIN_TRUE@ fstconvert$(EXEEXT) fstdeterminize$(EXEEXT) \
+@HAVE_BIN_TRUE@ fstdifference$(EXEEXT) fstdraw$(EXEEXT) \
+@HAVE_BIN_TRUE@ fstencode$(EXEEXT) fstepsnormalize$(EXEEXT) \
+@HAVE_BIN_TRUE@ fstequal$(EXEEXT) fstequivalent$(EXEEXT) \
+@HAVE_BIN_TRUE@ fstinfo$(EXEEXT) fstintersect$(EXEEXT) \
+@HAVE_BIN_TRUE@ fstinvert$(EXEEXT) fstmap$(EXEEXT) \
+@HAVE_BIN_TRUE@ fstminimize$(EXEEXT) fstprint$(EXEEXT) \
+@HAVE_BIN_TRUE@ fstproject$(EXEEXT) fstprune$(EXEEXT) \
+@HAVE_BIN_TRUE@ fstpush$(EXEEXT) fstrandgen$(EXEEXT) \
+@HAVE_BIN_TRUE@ fstrelabel$(EXEEXT) fstreplace$(EXEEXT) \
+@HAVE_BIN_TRUE@ fstreverse$(EXEEXT) fstreweight$(EXEEXT) \
+@HAVE_BIN_TRUE@ fstrmepsilon$(EXEEXT) \
+@HAVE_BIN_TRUE@ fstshortestdistance$(EXEEXT) \
+@HAVE_BIN_TRUE@ fstshortestpath$(EXEEXT) fstsymbols$(EXEEXT) \
+@HAVE_BIN_TRUE@ fstsynchronize$(EXEEXT) fsttopsort$(EXEEXT) \
+@HAVE_BIN_TRUE@ fstunion$(EXEEXT)
+subdir = src/bin
+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__installdirs = "$(DESTDIR)$(bindir)"
+PROGRAMS = $(bin_PROGRAMS)
+am__fstarcsort_SOURCES_DIST = fstarcsort.cc
+@HAVE_BIN_TRUE@am_fstarcsort_OBJECTS = fstarcsort.$(OBJEXT)
+fstarcsort_OBJECTS = $(am_fstarcsort_OBJECTS)
+fstarcsort_LDADD = $(LDADD)
+fstarcsort_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstclosure_SOURCES_DIST = fstclosure.cc
+@HAVE_BIN_TRUE@am_fstclosure_OBJECTS = fstclosure.$(OBJEXT)
+fstclosure_OBJECTS = $(am_fstclosure_OBJECTS)
+fstclosure_LDADD = $(LDADD)
+fstclosure_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstcompile_SOURCES_DIST = fstcompile.cc
+@HAVE_BIN_TRUE@am_fstcompile_OBJECTS = fstcompile.$(OBJEXT)
+fstcompile_OBJECTS = $(am_fstcompile_OBJECTS)
+fstcompile_LDADD = $(LDADD)
+fstcompile_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstcompose_SOURCES_DIST = fstcompose.cc
+@HAVE_BIN_TRUE@am_fstcompose_OBJECTS = fstcompose.$(OBJEXT)
+fstcompose_OBJECTS = $(am_fstcompose_OBJECTS)
+fstcompose_LDADD = $(LDADD)
+fstcompose_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstconcat_SOURCES_DIST = fstconcat.cc
+@HAVE_BIN_TRUE@am_fstconcat_OBJECTS = fstconcat.$(OBJEXT)
+fstconcat_OBJECTS = $(am_fstconcat_OBJECTS)
+fstconcat_LDADD = $(LDADD)
+fstconcat_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstconnect_SOURCES_DIST = fstconnect.cc
+@HAVE_BIN_TRUE@am_fstconnect_OBJECTS = fstconnect.$(OBJEXT)
+fstconnect_OBJECTS = $(am_fstconnect_OBJECTS)
+fstconnect_LDADD = $(LDADD)
+fstconnect_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstconvert_SOURCES_DIST = fstconvert.cc
+@HAVE_BIN_TRUE@am_fstconvert_OBJECTS = fstconvert.$(OBJEXT)
+fstconvert_OBJECTS = $(am_fstconvert_OBJECTS)
+fstconvert_LDADD = $(LDADD)
+fstconvert_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstdeterminize_SOURCES_DIST = fstdeterminize.cc
+@HAVE_BIN_TRUE@am_fstdeterminize_OBJECTS = fstdeterminize.$(OBJEXT)
+fstdeterminize_OBJECTS = $(am_fstdeterminize_OBJECTS)
+fstdeterminize_LDADD = $(LDADD)
+fstdeterminize_DEPENDENCIES = ../script/libfstscript.la \
+ ../lib/libfst.la
+am__fstdifference_SOURCES_DIST = fstdifference.cc
+@HAVE_BIN_TRUE@am_fstdifference_OBJECTS = fstdifference.$(OBJEXT)
+fstdifference_OBJECTS = $(am_fstdifference_OBJECTS)
+fstdifference_LDADD = $(LDADD)
+fstdifference_DEPENDENCIES = ../script/libfstscript.la \
+ ../lib/libfst.la
+am__fstdraw_SOURCES_DIST = fstdraw.cc
+@HAVE_BIN_TRUE@am_fstdraw_OBJECTS = fstdraw.$(OBJEXT)
+fstdraw_OBJECTS = $(am_fstdraw_OBJECTS)
+fstdraw_LDADD = $(LDADD)
+fstdraw_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstencode_SOURCES_DIST = fstencode.cc
+@HAVE_BIN_TRUE@am_fstencode_OBJECTS = fstencode.$(OBJEXT)
+fstencode_OBJECTS = $(am_fstencode_OBJECTS)
+fstencode_LDADD = $(LDADD)
+fstencode_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstepsnormalize_SOURCES_DIST = fstepsnormalize.cc
+@HAVE_BIN_TRUE@am_fstepsnormalize_OBJECTS = fstepsnormalize.$(OBJEXT)
+fstepsnormalize_OBJECTS = $(am_fstepsnormalize_OBJECTS)
+fstepsnormalize_LDADD = $(LDADD)
+fstepsnormalize_DEPENDENCIES = ../script/libfstscript.la \
+ ../lib/libfst.la
+am__fstequal_SOURCES_DIST = fstequal.cc
+@HAVE_BIN_TRUE@am_fstequal_OBJECTS = fstequal.$(OBJEXT)
+fstequal_OBJECTS = $(am_fstequal_OBJECTS)
+fstequal_LDADD = $(LDADD)
+fstequal_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstequivalent_SOURCES_DIST = fstequivalent.cc
+@HAVE_BIN_TRUE@am_fstequivalent_OBJECTS = fstequivalent.$(OBJEXT)
+fstequivalent_OBJECTS = $(am_fstequivalent_OBJECTS)
+fstequivalent_LDADD = $(LDADD)
+fstequivalent_DEPENDENCIES = ../script/libfstscript.la \
+ ../lib/libfst.la
+am__fstinfo_SOURCES_DIST = fstinfo.cc
+@HAVE_BIN_TRUE@am_fstinfo_OBJECTS = fstinfo.$(OBJEXT)
+fstinfo_OBJECTS = $(am_fstinfo_OBJECTS)
+fstinfo_LDADD = $(LDADD)
+fstinfo_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstintersect_SOURCES_DIST = fstintersect.cc
+@HAVE_BIN_TRUE@am_fstintersect_OBJECTS = fstintersect.$(OBJEXT)
+fstintersect_OBJECTS = $(am_fstintersect_OBJECTS)
+fstintersect_LDADD = $(LDADD)
+fstintersect_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstinvert_SOURCES_DIST = fstinvert.cc
+@HAVE_BIN_TRUE@am_fstinvert_OBJECTS = fstinvert.$(OBJEXT)
+fstinvert_OBJECTS = $(am_fstinvert_OBJECTS)
+fstinvert_LDADD = $(LDADD)
+fstinvert_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstmap_SOURCES_DIST = fstmap.cc
+@HAVE_BIN_TRUE@am_fstmap_OBJECTS = fstmap.$(OBJEXT)
+fstmap_OBJECTS = $(am_fstmap_OBJECTS)
+fstmap_LDADD = $(LDADD)
+fstmap_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstminimize_SOURCES_DIST = fstminimize.cc
+@HAVE_BIN_TRUE@am_fstminimize_OBJECTS = fstminimize.$(OBJEXT)
+fstminimize_OBJECTS = $(am_fstminimize_OBJECTS)
+fstminimize_LDADD = $(LDADD)
+fstminimize_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstprint_SOURCES_DIST = fstprint.cc
+@HAVE_BIN_TRUE@am_fstprint_OBJECTS = fstprint.$(OBJEXT)
+fstprint_OBJECTS = $(am_fstprint_OBJECTS)
+fstprint_LDADD = $(LDADD)
+fstprint_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstproject_SOURCES_DIST = fstproject.cc
+@HAVE_BIN_TRUE@am_fstproject_OBJECTS = fstproject.$(OBJEXT)
+fstproject_OBJECTS = $(am_fstproject_OBJECTS)
+fstproject_LDADD = $(LDADD)
+fstproject_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstprune_SOURCES_DIST = fstprune.cc
+@HAVE_BIN_TRUE@am_fstprune_OBJECTS = fstprune.$(OBJEXT)
+fstprune_OBJECTS = $(am_fstprune_OBJECTS)
+fstprune_LDADD = $(LDADD)
+fstprune_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstpush_SOURCES_DIST = fstpush.cc
+@HAVE_BIN_TRUE@am_fstpush_OBJECTS = fstpush.$(OBJEXT)
+fstpush_OBJECTS = $(am_fstpush_OBJECTS)
+fstpush_LDADD = $(LDADD)
+fstpush_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstrandgen_SOURCES_DIST = fstrandgen.cc
+@HAVE_BIN_TRUE@am_fstrandgen_OBJECTS = fstrandgen.$(OBJEXT)
+fstrandgen_OBJECTS = $(am_fstrandgen_OBJECTS)
+fstrandgen_LDADD = $(LDADD)
+fstrandgen_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstrelabel_SOURCES_DIST = fstrelabel.cc
+@HAVE_BIN_TRUE@am_fstrelabel_OBJECTS = fstrelabel.$(OBJEXT)
+fstrelabel_OBJECTS = $(am_fstrelabel_OBJECTS)
+fstrelabel_LDADD = $(LDADD)
+fstrelabel_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstreplace_SOURCES_DIST = fstreplace.cc
+@HAVE_BIN_TRUE@am_fstreplace_OBJECTS = fstreplace.$(OBJEXT)
+fstreplace_OBJECTS = $(am_fstreplace_OBJECTS)
+fstreplace_LDADD = $(LDADD)
+fstreplace_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstreverse_SOURCES_DIST = fstreverse.cc
+@HAVE_BIN_TRUE@am_fstreverse_OBJECTS = fstreverse.$(OBJEXT)
+fstreverse_OBJECTS = $(am_fstreverse_OBJECTS)
+fstreverse_LDADD = $(LDADD)
+fstreverse_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstreweight_SOURCES_DIST = fstreweight.cc
+@HAVE_BIN_TRUE@am_fstreweight_OBJECTS = fstreweight.$(OBJEXT)
+fstreweight_OBJECTS = $(am_fstreweight_OBJECTS)
+fstreweight_LDADD = $(LDADD)
+fstreweight_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstrmepsilon_SOURCES_DIST = fstrmepsilon.cc
+@HAVE_BIN_TRUE@am_fstrmepsilon_OBJECTS = fstrmepsilon.$(OBJEXT)
+fstrmepsilon_OBJECTS = $(am_fstrmepsilon_OBJECTS)
+fstrmepsilon_LDADD = $(LDADD)
+fstrmepsilon_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstshortestdistance_SOURCES_DIST = fstshortestdistance.cc
+@HAVE_BIN_TRUE@am_fstshortestdistance_OBJECTS = \
+@HAVE_BIN_TRUE@ fstshortestdistance.$(OBJEXT)
+fstshortestdistance_OBJECTS = $(am_fstshortestdistance_OBJECTS)
+fstshortestdistance_LDADD = $(LDADD)
+fstshortestdistance_DEPENDENCIES = ../script/libfstscript.la \
+ ../lib/libfst.la
+am__fstshortestpath_SOURCES_DIST = fstshortestpath.cc
+@HAVE_BIN_TRUE@am_fstshortestpath_OBJECTS = fstshortestpath.$(OBJEXT)
+fstshortestpath_OBJECTS = $(am_fstshortestpath_OBJECTS)
+fstshortestpath_LDADD = $(LDADD)
+fstshortestpath_DEPENDENCIES = ../script/libfstscript.la \
+ ../lib/libfst.la
+am__fstsymbols_SOURCES_DIST = fstsymbols.cc
+@HAVE_BIN_TRUE@am_fstsymbols_OBJECTS = fstsymbols.$(OBJEXT)
+fstsymbols_OBJECTS = $(am_fstsymbols_OBJECTS)
+fstsymbols_LDADD = $(LDADD)
+fstsymbols_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstsynchronize_SOURCES_DIST = fstsynchronize.cc
+@HAVE_BIN_TRUE@am_fstsynchronize_OBJECTS = fstsynchronize.$(OBJEXT)
+fstsynchronize_OBJECTS = $(am_fstsynchronize_OBJECTS)
+fstsynchronize_LDADD = $(LDADD)
+fstsynchronize_DEPENDENCIES = ../script/libfstscript.la \
+ ../lib/libfst.la
+am__fsttopsort_SOURCES_DIST = fsttopsort.cc
+@HAVE_BIN_TRUE@am_fsttopsort_OBJECTS = fsttopsort.$(OBJEXT)
+fsttopsort_OBJECTS = $(am_fsttopsort_OBJECTS)
+fsttopsort_LDADD = $(LDADD)
+fsttopsort_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+am__fstunion_SOURCES_DIST = fstunion.cc
+@HAVE_BIN_TRUE@am_fstunion_OBJECTS = fstunion.$(OBJEXT)
+fstunion_OBJECTS = $(am_fstunion_OBJECTS)
+fstunion_LDADD = $(LDADD)
+fstunion_DEPENDENCIES = ../script/libfstscript.la ../lib/libfst.la
+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 = $(fstarcsort_SOURCES) $(fstclosure_SOURCES) \
+ $(fstcompile_SOURCES) $(fstcompose_SOURCES) \
+ $(fstconcat_SOURCES) $(fstconnect_SOURCES) \
+ $(fstconvert_SOURCES) $(fstdeterminize_SOURCES) \
+ $(fstdifference_SOURCES) $(fstdraw_SOURCES) \
+ $(fstencode_SOURCES) $(fstepsnormalize_SOURCES) \
+ $(fstequal_SOURCES) $(fstequivalent_SOURCES) \
+ $(fstinfo_SOURCES) $(fstintersect_SOURCES) \
+ $(fstinvert_SOURCES) $(fstmap_SOURCES) $(fstminimize_SOURCES) \
+ $(fstprint_SOURCES) $(fstproject_SOURCES) $(fstprune_SOURCES) \
+ $(fstpush_SOURCES) $(fstrandgen_SOURCES) $(fstrelabel_SOURCES) \
+ $(fstreplace_SOURCES) $(fstreverse_SOURCES) \
+ $(fstreweight_SOURCES) $(fstrmepsilon_SOURCES) \
+ $(fstshortestdistance_SOURCES) $(fstshortestpath_SOURCES) \
+ $(fstsymbols_SOURCES) $(fstsynchronize_SOURCES) \
+ $(fsttopsort_SOURCES) $(fstunion_SOURCES)
+DIST_SOURCES = $(am__fstarcsort_SOURCES_DIST) \
+ $(am__fstclosure_SOURCES_DIST) $(am__fstcompile_SOURCES_DIST) \
+ $(am__fstcompose_SOURCES_DIST) $(am__fstconcat_SOURCES_DIST) \
+ $(am__fstconnect_SOURCES_DIST) $(am__fstconvert_SOURCES_DIST) \
+ $(am__fstdeterminize_SOURCES_DIST) \
+ $(am__fstdifference_SOURCES_DIST) $(am__fstdraw_SOURCES_DIST) \
+ $(am__fstencode_SOURCES_DIST) \
+ $(am__fstepsnormalize_SOURCES_DIST) \
+ $(am__fstequal_SOURCES_DIST) $(am__fstequivalent_SOURCES_DIST) \
+ $(am__fstinfo_SOURCES_DIST) $(am__fstintersect_SOURCES_DIST) \
+ $(am__fstinvert_SOURCES_DIST) $(am__fstmap_SOURCES_DIST) \
+ $(am__fstminimize_SOURCES_DIST) $(am__fstprint_SOURCES_DIST) \
+ $(am__fstproject_SOURCES_DIST) $(am__fstprune_SOURCES_DIST) \
+ $(am__fstpush_SOURCES_DIST) $(am__fstrandgen_SOURCES_DIST) \
+ $(am__fstrelabel_SOURCES_DIST) $(am__fstreplace_SOURCES_DIST) \
+ $(am__fstreverse_SOURCES_DIST) $(am__fstreweight_SOURCES_DIST) \
+ $(am__fstrmepsilon_SOURCES_DIST) \
+ $(am__fstshortestdistance_SOURCES_DIST) \
+ $(am__fstshortestpath_SOURCES_DIST) \
+ $(am__fstsymbols_SOURCES_DIST) \
+ $(am__fstsynchronize_SOURCES_DIST) \
+ $(am__fsttopsort_SOURCES_DIST) $(am__fstunion_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 -I$(srcdir)/../script $(ICU_FLAGS)
+LDADD = ../script/libfstscript.la ../lib/libfst.la -lm -ldl
+@HAVE_BIN_TRUE@fstarcsort_SOURCES = fstarcsort.cc
+@HAVE_BIN_TRUE@fstclosure_SOURCES = fstclosure.cc
+@HAVE_BIN_TRUE@fstcompile_SOURCES = fstcompile.cc
+@HAVE_BIN_TRUE@fstcompose_SOURCES = fstcompose.cc
+@HAVE_BIN_TRUE@fstconcat_SOURCES = fstconcat.cc
+@HAVE_BIN_TRUE@fstconnect_SOURCES = fstconnect.cc
+@HAVE_BIN_TRUE@fstconvert_SOURCES = fstconvert.cc
+@HAVE_BIN_TRUE@fstdeterminize_SOURCES = fstdeterminize.cc
+@HAVE_BIN_TRUE@fstdifference_SOURCES = fstdifference.cc
+@HAVE_BIN_TRUE@fstdraw_SOURCES = fstdraw.cc
+@HAVE_BIN_TRUE@fstencode_SOURCES = fstencode.cc
+@HAVE_BIN_TRUE@fstepsnormalize_SOURCES = fstepsnormalize.cc
+@HAVE_BIN_TRUE@fstequal_SOURCES = fstequal.cc
+@HAVE_BIN_TRUE@fstequivalent_SOURCES = fstequivalent.cc
+@HAVE_BIN_TRUE@fstinfo_SOURCES = fstinfo.cc
+@HAVE_BIN_TRUE@fstintersect_SOURCES = fstintersect.cc
+@HAVE_BIN_TRUE@fstinvert_SOURCES = fstinvert.cc
+@HAVE_BIN_TRUE@fstmap_SOURCES = fstmap.cc
+@HAVE_BIN_TRUE@fstminimize_SOURCES = fstminimize.cc
+@HAVE_BIN_TRUE@fstprint_SOURCES = fstprint.cc
+@HAVE_BIN_TRUE@fstproject_SOURCES = fstproject.cc
+@HAVE_BIN_TRUE@fstprune_SOURCES = fstprune.cc
+@HAVE_BIN_TRUE@fstpush_SOURCES = fstpush.cc
+@HAVE_BIN_TRUE@fstrandgen_SOURCES = fstrandgen.cc
+@HAVE_BIN_TRUE@fstrelabel_SOURCES = fstrelabel.cc
+@HAVE_BIN_TRUE@fstreplace_SOURCES = fstreplace.cc
+@HAVE_BIN_TRUE@fstreverse_SOURCES = fstreverse.cc
+@HAVE_BIN_TRUE@fstreweight_SOURCES = fstreweight.cc
+@HAVE_BIN_TRUE@fstrmepsilon_SOURCES = fstrmepsilon.cc
+@HAVE_BIN_TRUE@fstshortestdistance_SOURCES = fstshortestdistance.cc
+@HAVE_BIN_TRUE@fstshortestpath_SOURCES = fstshortestpath.cc
+@HAVE_BIN_TRUE@fstsymbols_SOURCES = fstsymbols.cc
+@HAVE_BIN_TRUE@fstsynchronize_SOURCES = fstsynchronize.cc
+@HAVE_BIN_TRUE@fsttopsort_SOURCES = fsttopsort.cc
+@HAVE_BIN_TRUE@fstunion_SOURCES = fstunion.cc
+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/bin/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/bin/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-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed 's/$(EXEEXT)$$//' | \
+ while read p p1; do if test -f $$p || test -f $$p1; \
+ then echo "$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+ sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) files[d] = files[d] " " $$1; \
+ else { print "f", $$3 "/" $$4, $$1; } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+ -e 's/$$/$(EXEEXT)/' `; \
+ test -n "$$list" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+fstarcsort$(EXEEXT): $(fstarcsort_OBJECTS) $(fstarcsort_DEPENDENCIES)
+ @rm -f fstarcsort$(EXEEXT)
+ $(CXXLINK) $(fstarcsort_OBJECTS) $(fstarcsort_LDADD) $(LIBS)
+fstclosure$(EXEEXT): $(fstclosure_OBJECTS) $(fstclosure_DEPENDENCIES)
+ @rm -f fstclosure$(EXEEXT)
+ $(CXXLINK) $(fstclosure_OBJECTS) $(fstclosure_LDADD) $(LIBS)
+fstcompile$(EXEEXT): $(fstcompile_OBJECTS) $(fstcompile_DEPENDENCIES)
+ @rm -f fstcompile$(EXEEXT)
+ $(CXXLINK) $(fstcompile_OBJECTS) $(fstcompile_LDADD) $(LIBS)
+fstcompose$(EXEEXT): $(fstcompose_OBJECTS) $(fstcompose_DEPENDENCIES)
+ @rm -f fstcompose$(EXEEXT)
+ $(CXXLINK) $(fstcompose_OBJECTS) $(fstcompose_LDADD) $(LIBS)
+fstconcat$(EXEEXT): $(fstconcat_OBJECTS) $(fstconcat_DEPENDENCIES)
+ @rm -f fstconcat$(EXEEXT)
+ $(CXXLINK) $(fstconcat_OBJECTS) $(fstconcat_LDADD) $(LIBS)
+fstconnect$(EXEEXT): $(fstconnect_OBJECTS) $(fstconnect_DEPENDENCIES)
+ @rm -f fstconnect$(EXEEXT)
+ $(CXXLINK) $(fstconnect_OBJECTS) $(fstconnect_LDADD) $(LIBS)
+fstconvert$(EXEEXT): $(fstconvert_OBJECTS) $(fstconvert_DEPENDENCIES)
+ @rm -f fstconvert$(EXEEXT)
+ $(CXXLINK) $(fstconvert_OBJECTS) $(fstconvert_LDADD) $(LIBS)
+fstdeterminize$(EXEEXT): $(fstdeterminize_OBJECTS) $(fstdeterminize_DEPENDENCIES)
+ @rm -f fstdeterminize$(EXEEXT)
+ $(CXXLINK) $(fstdeterminize_OBJECTS) $(fstdeterminize_LDADD) $(LIBS)
+fstdifference$(EXEEXT): $(fstdifference_OBJECTS) $(fstdifference_DEPENDENCIES)
+ @rm -f fstdifference$(EXEEXT)
+ $(CXXLINK) $(fstdifference_OBJECTS) $(fstdifference_LDADD) $(LIBS)
+fstdraw$(EXEEXT): $(fstdraw_OBJECTS) $(fstdraw_DEPENDENCIES)
+ @rm -f fstdraw$(EXEEXT)
+ $(CXXLINK) $(fstdraw_OBJECTS) $(fstdraw_LDADD) $(LIBS)
+fstencode$(EXEEXT): $(fstencode_OBJECTS) $(fstencode_DEPENDENCIES)
+ @rm -f fstencode$(EXEEXT)
+ $(CXXLINK) $(fstencode_OBJECTS) $(fstencode_LDADD) $(LIBS)
+fstepsnormalize$(EXEEXT): $(fstepsnormalize_OBJECTS) $(fstepsnormalize_DEPENDENCIES)
+ @rm -f fstepsnormalize$(EXEEXT)
+ $(CXXLINK) $(fstepsnormalize_OBJECTS) $(fstepsnormalize_LDADD) $(LIBS)
+fstequal$(EXEEXT): $(fstequal_OBJECTS) $(fstequal_DEPENDENCIES)
+ @rm -f fstequal$(EXEEXT)
+ $(CXXLINK) $(fstequal_OBJECTS) $(fstequal_LDADD) $(LIBS)
+fstequivalent$(EXEEXT): $(fstequivalent_OBJECTS) $(fstequivalent_DEPENDENCIES)
+ @rm -f fstequivalent$(EXEEXT)
+ $(CXXLINK) $(fstequivalent_OBJECTS) $(fstequivalent_LDADD) $(LIBS)
+fstinfo$(EXEEXT): $(fstinfo_OBJECTS) $(fstinfo_DEPENDENCIES)
+ @rm -f fstinfo$(EXEEXT)
+ $(CXXLINK) $(fstinfo_OBJECTS) $(fstinfo_LDADD) $(LIBS)
+fstintersect$(EXEEXT): $(fstintersect_OBJECTS) $(fstintersect_DEPENDENCIES)
+ @rm -f fstintersect$(EXEEXT)
+ $(CXXLINK) $(fstintersect_OBJECTS) $(fstintersect_LDADD) $(LIBS)
+fstinvert$(EXEEXT): $(fstinvert_OBJECTS) $(fstinvert_DEPENDENCIES)
+ @rm -f fstinvert$(EXEEXT)
+ $(CXXLINK) $(fstinvert_OBJECTS) $(fstinvert_LDADD) $(LIBS)
+fstmap$(EXEEXT): $(fstmap_OBJECTS) $(fstmap_DEPENDENCIES)
+ @rm -f fstmap$(EXEEXT)
+ $(CXXLINK) $(fstmap_OBJECTS) $(fstmap_LDADD) $(LIBS)
+fstminimize$(EXEEXT): $(fstminimize_OBJECTS) $(fstminimize_DEPENDENCIES)
+ @rm -f fstminimize$(EXEEXT)
+ $(CXXLINK) $(fstminimize_OBJECTS) $(fstminimize_LDADD) $(LIBS)
+fstprint$(EXEEXT): $(fstprint_OBJECTS) $(fstprint_DEPENDENCIES)
+ @rm -f fstprint$(EXEEXT)
+ $(CXXLINK) $(fstprint_OBJECTS) $(fstprint_LDADD) $(LIBS)
+fstproject$(EXEEXT): $(fstproject_OBJECTS) $(fstproject_DEPENDENCIES)
+ @rm -f fstproject$(EXEEXT)
+ $(CXXLINK) $(fstproject_OBJECTS) $(fstproject_LDADD) $(LIBS)
+fstprune$(EXEEXT): $(fstprune_OBJECTS) $(fstprune_DEPENDENCIES)
+ @rm -f fstprune$(EXEEXT)
+ $(CXXLINK) $(fstprune_OBJECTS) $(fstprune_LDADD) $(LIBS)
+fstpush$(EXEEXT): $(fstpush_OBJECTS) $(fstpush_DEPENDENCIES)
+ @rm -f fstpush$(EXEEXT)
+ $(CXXLINK) $(fstpush_OBJECTS) $(fstpush_LDADD) $(LIBS)
+fstrandgen$(EXEEXT): $(fstrandgen_OBJECTS) $(fstrandgen_DEPENDENCIES)
+ @rm -f fstrandgen$(EXEEXT)
+ $(CXXLINK) $(fstrandgen_OBJECTS) $(fstrandgen_LDADD) $(LIBS)
+fstrelabel$(EXEEXT): $(fstrelabel_OBJECTS) $(fstrelabel_DEPENDENCIES)
+ @rm -f fstrelabel$(EXEEXT)
+ $(CXXLINK) $(fstrelabel_OBJECTS) $(fstrelabel_LDADD) $(LIBS)
+fstreplace$(EXEEXT): $(fstreplace_OBJECTS) $(fstreplace_DEPENDENCIES)
+ @rm -f fstreplace$(EXEEXT)
+ $(CXXLINK) $(fstreplace_OBJECTS) $(fstreplace_LDADD) $(LIBS)
+fstreverse$(EXEEXT): $(fstreverse_OBJECTS) $(fstreverse_DEPENDENCIES)
+ @rm -f fstreverse$(EXEEXT)
+ $(CXXLINK) $(fstreverse_OBJECTS) $(fstreverse_LDADD) $(LIBS)
+fstreweight$(EXEEXT): $(fstreweight_OBJECTS) $(fstreweight_DEPENDENCIES)
+ @rm -f fstreweight$(EXEEXT)
+ $(CXXLINK) $(fstreweight_OBJECTS) $(fstreweight_LDADD) $(LIBS)
+fstrmepsilon$(EXEEXT): $(fstrmepsilon_OBJECTS) $(fstrmepsilon_DEPENDENCIES)
+ @rm -f fstrmepsilon$(EXEEXT)
+ $(CXXLINK) $(fstrmepsilon_OBJECTS) $(fstrmepsilon_LDADD) $(LIBS)
+fstshortestdistance$(EXEEXT): $(fstshortestdistance_OBJECTS) $(fstshortestdistance_DEPENDENCIES)
+ @rm -f fstshortestdistance$(EXEEXT)
+ $(CXXLINK) $(fstshortestdistance_OBJECTS) $(fstshortestdistance_LDADD) $(LIBS)
+fstshortestpath$(EXEEXT): $(fstshortestpath_OBJECTS) $(fstshortestpath_DEPENDENCIES)
+ @rm -f fstshortestpath$(EXEEXT)
+ $(CXXLINK) $(fstshortestpath_OBJECTS) $(fstshortestpath_LDADD) $(LIBS)
+fstsymbols$(EXEEXT): $(fstsymbols_OBJECTS) $(fstsymbols_DEPENDENCIES)
+ @rm -f fstsymbols$(EXEEXT)
+ $(CXXLINK) $(fstsymbols_OBJECTS) $(fstsymbols_LDADD) $(LIBS)
+fstsynchronize$(EXEEXT): $(fstsynchronize_OBJECTS) $(fstsynchronize_DEPENDENCIES)
+ @rm -f fstsynchronize$(EXEEXT)
+ $(CXXLINK) $(fstsynchronize_OBJECTS) $(fstsynchronize_LDADD) $(LIBS)
+fsttopsort$(EXEEXT): $(fsttopsort_OBJECTS) $(fsttopsort_DEPENDENCIES)
+ @rm -f fsttopsort$(EXEEXT)
+ $(CXXLINK) $(fsttopsort_OBJECTS) $(fsttopsort_LDADD) $(LIBS)
+fstunion$(EXEEXT): $(fstunion_OBJECTS) $(fstunion_DEPENDENCIES)
+ @rm -f fstunion$(EXEEXT)
+ $(CXXLINK) $(fstunion_OBJECTS) $(fstunion_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstarcsort.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstclosure.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstcompile.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstcompose.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstconcat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstconnect.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstconvert.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstdeterminize.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstdifference.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstdraw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstencode.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstepsnormalize.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstequal.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstequivalent.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstinfo.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstintersect.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstinvert.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstminimize.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstprint.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstproject.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstprune.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstpush.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstrandgen.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstrelabel.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstreplace.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstreverse.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstreweight.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstrmepsilon.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstshortestdistance.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstshortestpath.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstsymbols.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstsynchronize.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fsttopsort.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstunion.Po@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 $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; 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-binPROGRAMS clean-generic 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-binPROGRAMS
+
+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-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic 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-binPROGRAMS 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-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-binPROGRAMS
+
+
+# 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/bin/fstarcsort.cc b/src/bin/fstarcsort.cc
new file mode 100644
index 0000000..33e534d
--- /dev/null
+++ b/src/bin/fstarcsort.cc
@@ -0,0 +1,67 @@
+// fstarcsort.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Sorts arcs of an FST.
+//
+
+#include <string>
+
+#include <fst/compat.h>
+#include <fst/script/arcsort.h>
+
+DEFINE_string(sort_type, "ilabel",
+ "Comparison method, one of: \"ilabel\", \"olabel\"");
+
+int main(int argc, char **argv) {
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+ using fst::script::ArcSort;
+
+ string usage = "Sorts arcs of an FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_name = (argc > 1 && (strcmp(argv[1], "-") != 0)) ? argv[1] : "";
+ string out_name = argc > 2 ? argv[2] : "";
+
+ MutableFstClass *fst = MutableFstClass::Read(in_name, true);
+ if (!fst) return 1;
+
+ if (FLAGS_sort_type == "ilabel") {
+ ArcSort(fst, fst::script::ILABEL_COMPARE);
+ } else if (FLAGS_sort_type == "olabel") {
+ ArcSort(fst, fst::script::OLABEL_COMPARE);
+ } else {
+ LOG(ERROR) << argv[0] << ": Unknown sort type \""
+ << FLAGS_sort_type << "\"\n";
+ return 1;
+ }
+
+ fst->Write(out_name);
+
+ return 0;
+}
diff --git a/src/bin/fstclosure.cc b/src/bin/fstclosure.cc
new file mode 100644
index 0000000..569c708
--- /dev/null
+++ b/src/bin/fstclosure.cc
@@ -0,0 +1,56 @@
+// fstclosure.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Creates the Kleene closure of an FST.
+//
+
+#include <fst/script/closure.h>
+
+DEFINE_bool(closure_plus, false,
+ "Do not add the empty path (T+ instead of T*)");
+
+int main(int argc, char **argv) {
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+
+ string usage = "Creates the Kleene closure of an FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_fname = (argc > 1 && strcmp(argv[1], "-") != 0) ? argv[1] : "";
+ string out_fname = argc > 2 ? argv[2] : "";
+
+ MutableFstClass *fst = MutableFstClass::Read(in_fname, true);
+ if (!fst) return 1;
+
+ fst::ClosureType closure_type =
+ FLAGS_closure_plus ? fst::CLOSURE_PLUS : fst::CLOSURE_STAR;
+
+ fst::script::Closure(fst, closure_type);
+ fst->Write(out_fname);
+
+ return 0;
+}
diff --git a/src/bin/fstcompile.cc b/src/bin/fstcompile.cc
new file mode 100644
index 0000000..db62f95
--- /dev/null
+++ b/src/bin/fstcompile.cc
@@ -0,0 +1,92 @@
+// fstcompile.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Creates binary FSTs from simple text format used by AT&T
+// (see http://www.research.att.com/projects/mohri/fsm/doc4/fsm.5.html).
+
+#include <fst/script/compile.h>
+
+DEFINE_bool(acceptor, false, "Input in acceptor format");
+DEFINE_string(arc_type, "standard", "Output arc type");
+DEFINE_string(fst_type, "vector", "Output FST type");
+DEFINE_string(isymbols, "", "Input label symbol table");
+DEFINE_string(osymbols, "", "Output label symbol table");
+DEFINE_string(ssymbols, "", "State label symbol table");
+DEFINE_bool(keep_isymbols, false, "Store input label symbol table with FST");
+DEFINE_bool(keep_osymbols, false, "Store output label symbol table with FST");
+DEFINE_bool(keep_state_numbering, false, "Do not renumber input states");
+DEFINE_bool(allow_negative_labels, false,
+ "Allow negative labels (not recommended; may cause conflicts)");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::istream;
+ using fst::ifstream;
+ using fst::SymbolTable;
+
+ string usage = "Creates binary FSTs from simple text format.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [text.fst [binary.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ const char *source = "standard input";
+ istream *istrm = &std::cin;
+ if (argc > 1 && strcmp(argv[1], "-") != 0) {
+ source = argv[1];
+ istrm = new fst::ifstream(argv[1]);
+ if (!*istrm) {
+ LOG(ERROR) << argv[0] << ": Open failed, file = " << argv[1];
+ return 1;
+ }
+ }
+ const SymbolTable *isyms = 0, *osyms = 0, *ssyms = 0;
+
+ if (!FLAGS_isymbols.empty()) {
+ isyms = SymbolTable::ReadText(FLAGS_isymbols, FLAGS_allow_negative_labels);
+ if (!isyms) exit(1);
+ }
+
+ if (!FLAGS_osymbols.empty()) {
+ osyms = SymbolTable::ReadText(FLAGS_osymbols, FLAGS_allow_negative_labels);
+ if (!osyms) exit(1);
+ }
+
+ if (!FLAGS_ssymbols.empty()) {
+ ssyms = SymbolTable::ReadText(FLAGS_ssymbols);
+ if (!ssyms) exit(1);
+ }
+
+ string dest = argc > 2 ? argv[2] : "";
+
+ s::CompileFst(*istrm, source, dest, FLAGS_fst_type, FLAGS_arc_type,
+ isyms, osyms, ssyms,
+ FLAGS_acceptor, FLAGS_keep_isymbols, FLAGS_keep_osymbols,
+ FLAGS_keep_state_numbering, FLAGS_allow_negative_labels);
+
+ if (istrm != &std::cin)
+ delete istrm;
+
+ return 0;
+}
diff --git a/src/bin/fstcompose.cc b/src/bin/fstcompose.cc
new file mode 100644
index 0000000..0ba8c47
--- /dev/null
+++ b/src/bin/fstcompose.cc
@@ -0,0 +1,95 @@
+// fstcompose.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Composes two FSTs.
+//
+
+#include <fst/script/compose.h>
+#include <fst/script/connect.h>
+
+
+DEFINE_string(compose_filter, "auto",
+ "Composition filter, one of: \"alt_sequence\", \"auto\", "
+ "\"match\", \"sequence\"");
+DEFINE_bool(connect, true, "Trim output");
+
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+ using fst::script::VectorFstClass;
+
+ string usage = "Composes two FSTs.\n\n Usage: ";
+ usage += argv[0];
+ usage += " in1.fst in2.fst [out.fst]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc < 3 || argc > 4) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in1_name = strcmp(argv[1], "-") != 0 ? argv[1] : "";
+ string in2_name = (argc > 2 && (strcmp(argv[2], "-") != 0)) ? argv[2] : "";
+ string out_name = argc > 3 ? argv[3] : "";
+
+ if (in1_name.empty() && in2_name.empty()) {
+ LOG(ERROR) << argv[0] << ": Can't take both inputs from standard input.";
+ return 1;
+ }
+
+ FstClass *ifst1 = FstClass::Read(in1_name);
+ if (!ifst1) return 1;
+
+ FstClass *ifst2 = FstClass::Read(in2_name);
+ if (!ifst2) return 1;
+
+ if (ifst1->ArcType() != ifst2->ArcType()) {
+ LOG(ERROR) << argv[0] << ": Input FSTs must have the same arc type.";
+ return 1;
+ }
+
+ VectorFstClass ofst(ifst1->ArcType());
+
+ fst::ComposeFilter compose_filter;
+
+ if (FLAGS_compose_filter == "alt_sequence") {
+ compose_filter = fst::ALT_SEQUENCE_FILTER;
+ } else if (FLAGS_compose_filter == "auto") {
+ compose_filter = fst::AUTO_FILTER;
+ } else if (FLAGS_compose_filter == "match") {
+ compose_filter = fst::MATCH_FILTER;
+ } else if (FLAGS_compose_filter == "sequence") {
+ compose_filter = fst::SEQUENCE_FILTER;
+ } else {
+ LOG(ERROR) << argv[0] << "Unknown compose filter type: "
+ << FLAGS_compose_filter;
+ return 1;
+ }
+
+ fst::ComposeOptions opts(FLAGS_connect, compose_filter);
+
+ s::Compose(*ifst1, *ifst2, &ofst, opts);
+
+ ofst.Write(out_name);
+
+ return 0;
+}
diff --git a/src/bin/fstconcat.cc b/src/bin/fstconcat.cc
new file mode 100644
index 0000000..fbe9b68
--- /dev/null
+++ b/src/bin/fstconcat.cc
@@ -0,0 +1,62 @@
+// fstconcat.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Concatenates two FSTs.
+//
+
+#include <string>
+
+#include <fst/script/concat.h>
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+
+ string usage = "Concatenates two FSTs.\n\n Usage: ";
+ usage += argv[0];
+ usage += " in1.fst in2.fst [out.fst]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc < 3 || argc > 4) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in1_name = strcmp(argv[1], "-") == 0 ? "" : argv[1];
+ string in2_name = strcmp(argv[2], "-") == 0 ? "" : argv[2];
+ string out_fname = argc > 3 ? argv[3] : "";
+
+ if (in1_name.empty() && in2_name.empty()) {
+ LOG(ERROR) << argv[0] << ": Can't take both inputs from standard input.";
+ return 1;
+ }
+
+ MutableFstClass *fst1 = MutableFstClass::Read(in1_name, true);
+ if (!fst1) return 1;
+
+ FstClass *fst2 = FstClass::Read(in2_name);
+ if (!fst2) return 1;
+
+ s::Concat(fst1, *fst2);
+ fst1->Write(out_fname);
+
+ return 0;
+}
diff --git a/src/bin/fstconnect.cc b/src/bin/fstconnect.cc
new file mode 100644
index 0000000..f774767
--- /dev/null
+++ b/src/bin/fstconnect.cc
@@ -0,0 +1,52 @@
+// fstconnect.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Removes useless (inaccessible or non-coaccessible) states and arcs
+// from an FST.
+//
+
+#include <fst/script/connect.h>
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+
+ string usage = "Removes useless states and arcs from an FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_name = (argc > 1 && strcmp(argv[1], "-") != 0) ? argv[1] : "";
+ string out_name = argc > 2 ? argv[2] : "";
+
+ MutableFstClass *fst = MutableFstClass::Read(in_name, true);
+ if (!fst) return 1;
+
+ s::Connect(fst);
+ fst->Write(out_name);
+
+ return 0;
+}
diff --git a/src/bin/fstconvert.cc b/src/bin/fstconvert.cc
new file mode 100644
index 0000000..f7c4ad9
--- /dev/null
+++ b/src/bin/fstconvert.cc
@@ -0,0 +1,58 @@
+// fstconvert.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Converts an FST to another type.
+//
+
+#include <fst/script/convert.h>
+
+DEFINE_string(fst_type, "vector", "Output FST type");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+
+ string usage = "Converts an FST to another type.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_name = (argc > 1 && strcmp(argv[1], "-") != 0) ? argv[1] : "";
+ string out_name = argc > 2 ? argv[2] : "";
+
+ FstClass *ifst = FstClass::Read(in_name);
+ if (!ifst) return 1;
+
+ FstClass *ofst = ifst;
+ if (!ofst) return 1;
+
+ if (ofst->FstType() != FLAGS_fst_type) {
+ ofst = s::Convert(*ifst, FLAGS_fst_type);
+ }
+
+ ofst->Write(out_name);
+
+ return 0;
+}
diff --git a/src/bin/fstdeterminize.cc b/src/bin/fstdeterminize.cc
new file mode 100644
index 0000000..aa5064f
--- /dev/null
+++ b/src/bin/fstdeterminize.cc
@@ -0,0 +1,68 @@
+// fstdeterminize.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Determinizes an FST.
+//
+
+#include <fst/script/determinize.h>
+
+DEFINE_double(delta, fst::kDelta, "Comparison/quantization delta");
+DEFINE_int64(nstate, fst::kNoStateId, "State number threshold");
+DEFINE_string(weight, "", "Weight threshold");
+DEFINE_int64(subsequential_label, 0,
+ "Input label of arc corresponding to residual final output when"
+ " producing a subsequential transducer");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+ using fst::script::VectorFstClass;
+ using fst::script::WeightClass;
+
+ string usage = "Determinizes an FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_name = (argc > 1 && strcmp(argv[1], "-") != 0) ? argv[1] : "";
+ string out_name = argc > 2 ? argv[2] : "";
+
+ FstClass *ifst = FstClass::Read(in_name);
+ if (!ifst) return 1;
+
+ VectorFstClass ofst(ifst->ArcType());
+
+ s::DeterminizeOptions opts(
+ FLAGS_delta, FLAGS_weight.empty() ?
+ WeightClass::Zero() : WeightClass(ifst->WeightType(), FLAGS_weight),
+ FLAGS_nstate, FLAGS_subsequential_label);
+
+ s::Determinize(*ifst, &ofst, opts);
+
+ ofst.Write(out_name);
+
+ return 0;
+}
diff --git a/src/bin/fstdifference.cc b/src/bin/fstdifference.cc
new file mode 100644
index 0000000..5459b03
--- /dev/null
+++ b/src/bin/fstdifference.cc
@@ -0,0 +1,87 @@
+// fstdifference.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Subtracts an unweighted DFA from an FSA.
+//
+
+#include <fst/script/difference.h>
+#include <fst/script/connect.h>
+
+DEFINE_string(compose_filter, "auto",
+ "Composition filter, one of: \"alt_sequence\", \"auto\","
+ " \"match\", \"sequence\"");
+DEFINE_bool(connect, true, "Trim output");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+ using fst::script::VectorFstClass;
+
+ string usage = "Subtracts an unweighted DFA from an FSA.\n\n Usage: ";
+ usage += argv[0];
+ usage += " in1.fst in2.fst [out.fst]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc < 3 || argc > 4) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in1_name = strcmp(argv[1], "-") == 0 ? "" : argv[1];
+ string in2_name = strcmp(argv[2], "-") == 0 ? "" : argv[2];
+ string out_name = argc > 3 ? argv[3] : "";
+
+ if (in1_name.empty() && in2_name.empty()) {
+ LOG(ERROR) << argv[0] << ": Can't take both inputs from standard input.";
+ return 1;
+ }
+
+ FstClass *ifst1 = FstClass::Read(in1_name);
+ if (!ifst1) return 1;
+ FstClass *ifst2 = FstClass::Read(in2_name);
+ if (!ifst2) return 1;
+
+ VectorFstClass ofst(ifst1->ArcType());
+
+ fst::ComposeFilter cf;
+
+ if (FLAGS_compose_filter == "auto") {
+ cf = fst::AUTO_FILTER;
+ } else if (FLAGS_compose_filter == "sequence") {
+ cf = fst::SEQUENCE_FILTER;
+ } else if (FLAGS_compose_filter == "alt_sequence") {
+ cf = fst::ALT_SEQUENCE_FILTER;
+ } else if (FLAGS_compose_filter == "match") {
+ cf = fst::MATCH_FILTER;
+ } else {
+ LOG(ERROR) << argv[0] << ": Bad filter type \""
+ << FLAGS_compose_filter << "\"";
+ return 1;
+ }
+
+ fst::DifferenceOptions opts(FLAGS_connect, cf);
+
+ s::Difference(*ifst1, *ifst2, &ofst, opts);
+
+ ofst.Write(out_name);
+
+ return 0;
+}
diff --git a/src/bin/fstdraw.cc b/src/bin/fstdraw.cc
new file mode 100644
index 0000000..51ebb2d
--- /dev/null
+++ b/src/bin/fstdraw.cc
@@ -0,0 +1,118 @@
+// fstdraw.cc
+
+// 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: allauzen@google.com (Cyril Allauzen)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Draws a binary FSTs in the Graphviz dot text format
+
+#include <fst/script/draw.h>
+
+DEFINE_bool(acceptor, false, "Input in acceptor format");
+DEFINE_string(isymbols, "", "Input label symbol table");
+DEFINE_string(osymbols, "", "Output label symbol table");
+DEFINE_string(ssymbols, "", "State label symbol table");
+DEFINE_bool(numeric, false, "Print numeric labels");
+DEFINE_string(save_isymbols, "", "Save input symbol table to file");
+DEFINE_string(save_osymbols, "", "Save output symbol table to file");
+DEFINE_int32(precision, 5, "Set precision (number of char/float)");
+DEFINE_bool(show_weight_one, false,
+ "Print/draw arc weights and final weights equal to Weight::One()");
+DEFINE_string(title, "", "Set figure title");
+DEFINE_bool(portrait, false, "Portrait mode (def: landscape)");
+DEFINE_bool(vertical, false, "Draw bottom-to-top instead of left-to-right");
+DEFINE_int32(fontsize, 14, "Set fontsize");
+DEFINE_double(height, 11, "Set height");
+DEFINE_double(width, 8.5, "Set width");
+DEFINE_double(nodesep, 0.25,
+ "Set minimum separation between nodes (see dot documentation)");
+DEFINE_double(ranksep, 0.40,
+ "Set minimum separation between ranks (see dot documentation)");
+DEFINE_bool(allow_negative_labels, false,
+ "Allow negative labels (not recommended; may cause conflicts)");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::ostream;
+ using fst::SymbolTable;
+
+ string usage = "Prints out binary FSTs in dot text format.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [binary.fst [text.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_name = (argc > 1 && strcmp(argv[1], "-") != 0) ? argv[1] : "";
+
+ s::FstClass *fst = s::FstClass::Read(in_name);
+ if (!fst) return 1;
+
+ ostream *ostrm = &std::cout;
+ string dest = "stdout";
+ if (argc == 3) {
+ dest = argv[2];
+ ostrm = new fst::ofstream(argv[2]);
+ if (!*ostrm) {
+ LOG(ERROR) << argv[0] << ": Open failed, file = " << argv[2];
+ return 1;
+ }
+ }
+ ostrm->precision(FLAGS_precision);
+
+ const SymbolTable *isyms = 0, *osyms = 0, *ssyms = 0;
+
+ if (!FLAGS_isymbols.empty() && !FLAGS_numeric) {
+ isyms = SymbolTable::ReadText(FLAGS_isymbols, FLAGS_allow_negative_labels);
+ if (!isyms) exit(1);
+ }
+
+ if (!FLAGS_osymbols.empty() && !FLAGS_numeric) {
+ osyms = SymbolTable::ReadText(FLAGS_osymbols, FLAGS_allow_negative_labels);
+ if (!osyms) exit(1);
+ }
+
+ if (!FLAGS_ssymbols.empty() && !FLAGS_numeric) {
+ ssyms = SymbolTable::ReadText(FLAGS_ssymbols);
+ if (!ssyms) exit(1);
+ }
+
+ if (!isyms && !FLAGS_numeric)
+ isyms = fst->InputSymbols();
+ if (!osyms && !FLAGS_numeric)
+ osyms = fst->OutputSymbols();
+
+ s::DrawFst(*fst, isyms, osyms, ssyms, FLAGS_acceptor,
+ FLAGS_title, FLAGS_width, FLAGS_height,
+ FLAGS_portrait, FLAGS_vertical,
+ FLAGS_ranksep, FLAGS_nodesep,
+ FLAGS_fontsize, FLAGS_precision,
+ FLAGS_show_weight_one, ostrm, dest);
+
+ if (isyms && !FLAGS_save_isymbols.empty())
+ isyms->WriteText(FLAGS_save_isymbols);
+
+ if (osyms && !FLAGS_save_osymbols.empty())
+ osyms->WriteText(FLAGS_save_osymbols);
+
+ if (ostrm != &std::cout)
+ delete ostrm;
+ return 0;
+}
diff --git a/src/bin/fstencode.cc b/src/bin/fstencode.cc
new file mode 100644
index 0000000..95dd49c
--- /dev/null
+++ b/src/bin/fstencode.cc
@@ -0,0 +1,68 @@
+// fstencode.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Encode transducer labels and/or weights.
+//
+
+#include <fst/script/encode.h>
+#include <fst/script/decode.h>
+
+/// EncodeMain specific flag definitions
+DEFINE_bool(encode_labels, false, "Encode output labels");
+DEFINE_bool(encode_weights, false, "Encode weights");
+DEFINE_bool(encode_reuse, false, "Re-use existing codex");
+DEFINE_bool(decode, false, "Decode labels and/or weights");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+
+ string usage = "Encodes transducer labels and/or weights.\n\n Usage: ";
+ usage += argv[0];
+ usage += " in.fst codex [out.fst]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc < 3 || argc > 4) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_name = (strcmp(argv[1], "-") != 0) ? argv[1] : "";
+ string codex_name = argv[2];
+ string out_name = argc > 3 ? argv[3] : "";
+
+ MutableFstClass *fst = MutableFstClass::Read(in_name, true);
+ if (!fst) return 1;
+
+ if (FLAGS_decode == false) {
+ uint32 flags = 0;
+ flags |= FLAGS_encode_labels ? fst::kEncodeLabels : 0;
+ flags |= FLAGS_encode_weights ? fst::kEncodeWeights : 0;
+ s::Encode(fst, flags, FLAGS_encode_reuse, codex_name);
+ fst->Write(out_name);
+ } else {
+ s::Decode(fst, codex_name);
+ fst->Write(out_name);
+ }
+
+ delete fst;
+ return 0;
+}
diff --git a/src/bin/fstepsnormalize.cc b/src/bin/fstepsnormalize.cc
new file mode 100644
index 0000000..c8813c6
--- /dev/null
+++ b/src/bin/fstepsnormalize.cc
@@ -0,0 +1,58 @@
+// fstepsnormalize.cc
+
+// 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: allauzen@google.com (Cyril Allauzen)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Epsilon normalizes an FST.
+//
+
+#include <fst/script/epsnormalize.h>
+
+DEFINE_bool(eps_norm_output, false, "Normalize output epsilons");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::VectorFstClass;
+
+
+ string usage = "Epsilon normalizes an FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_name = (argc > 1 && strcmp(argv[1], "-") != 0) ? argv[1] : "";
+ string out_name = argc > 2 ? argv[2] : "";
+
+ FstClass *ifst = FstClass::Read(in_name);
+ if (!ifst) return 1;
+
+ fst::EpsNormalizeType eps_norm_type = FLAGS_eps_norm_output ?
+ fst::EPS_NORM_OUTPUT : fst::EPS_NORM_INPUT;
+
+ VectorFstClass ofst(ifst->ArcType());
+ s::EpsNormalize(*ifst, &ofst, eps_norm_type);
+ ofst.Write(out_name);
+
+ return 0;
+}
diff --git a/src/bin/fstequal.cc b/src/bin/fstequal.cc
new file mode 100644
index 0000000..885b330
--- /dev/null
+++ b/src/bin/fstequal.cc
@@ -0,0 +1,61 @@
+// fstequal.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Two FSTS are equal iff they their exit status is zero.
+//
+
+#include <fst/script/equal.h>
+
+DEFINE_double(delta, fst::kDelta, "Comparison/quantization delta");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+
+ string usage = "Two FSTs are equal iff the exit status is zero.\n\n Usage: ";
+ usage += argv[0];
+ usage += " in1.fst in2.fst\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc != 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in1_name = strcmp(argv[1], "-") == 0 ? "" : argv[1];
+ string in2_name = strcmp(argv[2], "-") == 0 ? "" : argv[2];
+
+ if (in1_name.empty() && in2_name.empty()) {
+ LOG(ERROR) << argv[0] << ": Can't take both inputs from standard input.";
+ return 1;
+ }
+
+ FstClass *ifst1 = FstClass::Read(in1_name);
+ if (!ifst1) return 1;
+
+ FstClass *ifst2 = FstClass::Read(in2_name);
+ if (!ifst2) return 1;
+
+ bool result = s::Equal(*ifst1, *ifst2, FLAGS_delta);
+ if (!result)
+ VLOG(1) << "FSTs are not equal.";
+
+ return result ? 0 : 2;
+}
diff --git a/src/bin/fstequivalent.cc b/src/bin/fstequivalent.cc
new file mode 100644
index 0000000..e7e09f2
--- /dev/null
+++ b/src/bin/fstequivalent.cc
@@ -0,0 +1,91 @@
+// fstequivalent.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Two DFAs are equivalent iff their exit status is zero.
+//
+
+#include <fst/script/equivalent.h>
+#include <fst/script/randequivalent.h>
+
+DEFINE_double(delta, fst::kDelta, "Comparison/quantization delta");
+DEFINE_bool(random, false,
+ "Test equivalence by randomly selecting paths in the input FSTs");
+DEFINE_int32(max_length, INT_MAX, "Maximum path length");
+DEFINE_int32(npath, 1, "Number of paths to generate");
+DEFINE_int32(seed, time(0), "Random seed");
+DEFINE_string(select, "uniform", "Selection type: one of: "
+ " \"uniform\", \"log_prob (when appropriate),"
+ " \"fast_log_prob\" (when appropriate)");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+
+ string usage = "Two DFAs are equivalent iff the exit status is zero.\n\n"
+ " Usage: ";
+ usage += argv[0];
+ usage += " in1.fst in2.fst\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc != 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in1_name = strcmp(argv[1], "-") == 0 ? "" : argv[1];
+ string in2_name = strcmp(argv[2], "-") == 0 ? "" : argv[2];
+
+ if (in1_name.empty() && in2_name.empty()) {
+ LOG(ERROR) << argv[0] << ": Can't take both inputs from standard input.";
+ return 1;
+ }
+
+ FstClass *ifst1 = FstClass::Read(in1_name);
+ if (!ifst1) return 1;
+
+ FstClass *ifst2 = FstClass::Read(in2_name);
+ if (!ifst2) return 1;
+
+ if (!FLAGS_random) {
+ return s::Equivalent(*ifst1, *ifst2, FLAGS_delta) ? 0 : 2;
+ } else {
+ s::RandArcSelection ras;
+
+ if (FLAGS_select == "uniform") {
+ ras = s::UNIFORM_ARC_SELECTOR;
+ } else if (FLAGS_select == "log_prob") {
+ ras = s::LOG_PROB_ARC_SELECTOR;
+ } else if (FLAGS_select == "fast_log_prob") {
+ ras = s::FAST_LOG_PROB_ARC_SELECTOR;
+ } else {
+ LOG(ERROR) << argv[0] << ": Unknown selection type \""
+ << FLAGS_select << "\"\n";
+ return 1;
+ }
+
+ return s::RandEquivalent(
+ *ifst1, *ifst2,
+ FLAGS_seed,
+ FLAGS_npath,
+ FLAGS_delta,
+ fst::RandGenOptions<s::RandArcSelection>(
+ ras, FLAGS_max_length)) ? 0 : 2;
+ }
+}
diff --git a/src/bin/fstinfo.cc b/src/bin/fstinfo.cc
new file mode 100644
index 0000000..23816be
--- /dev/null
+++ b/src/bin/fstinfo.cc
@@ -0,0 +1,59 @@
+// fstinfo.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Prints out various information about an FST such as number of states
+// and arcs and property values (see properties.h).
+//
+
+#include <fst/script/info.h>
+
+DEFINE_string(arc_filter, "any", "Arc filter: one of :"
+ " \"any\", \"epsilon\", \"iepsilon\", \"oepsilon\"");
+DEFINE_string(info_type, "auto",
+ "Info format: one of: \"auto\", \"long\", \"short\"");
+DEFINE_bool(pipe, false, "Send info to stderr, input to stdout");
+DEFINE_bool(test_properties, true,
+ "Compute property values (if unknown to FST)");
+DEFINE_bool(fst_verify, true, "Verify FST sanity");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+
+ string usage = "Prints out information about an FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 2) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_name = (argc > 1 && (strcmp(argv[1], "-") != 0)) ? argv[1] : "";
+
+ FstClass *ifst = FstClass::Read(in_name);
+ if (!ifst) return 1;
+
+ s::PrintFstInfo(*ifst, FLAGS_test_properties, FLAGS_arc_filter,
+ FLAGS_info_type, FLAGS_fst_verify, FLAGS_pipe);
+
+ return 0;
+}
diff --git a/src/bin/fstintersect.cc b/src/bin/fstintersect.cc
new file mode 100644
index 0000000..b3558fc
--- /dev/null
+++ b/src/bin/fstintersect.cc
@@ -0,0 +1,88 @@
+// fstintersect.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Intersects two FSTs.
+//
+
+#include <fst/script/intersect.h>
+#include <fst/script/connect.h>
+
+DEFINE_string(compose_filter, "auto",
+ "Composition filter, one of: \"alt_sequence\", \"auto\", "
+ "\"match\", \"sequence\"");
+DEFINE_bool(connect, true, "Trim output");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::VectorFstClass;
+
+
+ string usage = "Intersects two FSAs.\n\n Usage: ";
+ usage += argv[0];
+ usage += " in1.fst in2.fst [out.fst]\n";
+ usage += " Flags: connect\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc < 3 || argc > 4) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in1_name = strcmp(argv[1], "-") == 0 ? "" : argv[1];
+ string in2_name = strcmp(argv[2], "-") == 0 ? "" : argv[2];
+ string out_name = argc > 3 ? argv[3] : "";
+
+ if (in1_name.empty() && in2_name.empty()) {
+ LOG(ERROR) << argv[0] << ": Can't take both inputs from standard input.";
+ return 1;
+ }
+
+ FstClass *ifst1 = FstClass::Read(in1_name);
+ if (!ifst1) return 1;
+ FstClass *ifst2 = FstClass::Read(in2_name);
+ if (!ifst2) return 1;
+
+ VectorFstClass ofst(ifst1->ArcType());
+
+ fst::ComposeFilter compose_filter;
+
+ if (FLAGS_compose_filter == "alt_sequence") {
+ compose_filter = fst::ALT_SEQUENCE_FILTER;
+ } else if (FLAGS_compose_filter == "auto") {
+ compose_filter = fst::AUTO_FILTER;
+ } else if (FLAGS_compose_filter == "match") {
+ compose_filter = fst::MATCH_FILTER;
+ } else if (FLAGS_compose_filter == "sequence") {
+ compose_filter = fst::SEQUENCE_FILTER;
+ } else {
+ LOG(ERROR) << argv[0] << "Unknown compose filter type: "
+ << FLAGS_compose_filter;
+ return 1;
+ }
+
+ fst::IntersectOptions opts(FLAGS_connect, compose_filter);
+
+ s::Intersect(*ifst1, *ifst2, &ofst, opts);
+
+ ofst.Write(out_name);
+
+ return 0;
+}
diff --git a/src/bin/fstinvert.cc b/src/bin/fstinvert.cc
new file mode 100644
index 0000000..f9b348b
--- /dev/null
+++ b/src/bin/fstinvert.cc
@@ -0,0 +1,51 @@
+// fstinvert.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Inverts a transduction.
+//
+
+#include <fst/script/invert.h>
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+
+ string usage = "Inverts a transduction.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_name = (argc > 1 && strcmp(argv[1], "-") != 0) ? argv[1] : "";
+ string out_name = argc > 2 ? argv[2] : "";
+
+ MutableFstClass *fst = MutableFstClass::Read(in_name, true);
+ if (!fst) return 1;
+
+ s::Invert(fst);
+ fst->Write(out_name);
+
+ return 0;
+}
diff --git a/src/bin/fstmap.cc b/src/bin/fstmap.cc
new file mode 100644
index 0000000..231c725
--- /dev/null
+++ b/src/bin/fstmap.cc
@@ -0,0 +1,97 @@
+// fstmap.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Applies an operation to each arc of an FST.
+//
+
+#include <string>
+
+#include <fst/script/map.h>
+
+DEFINE_double(delta, fst::kDelta, "Comparison/quantization delta");
+DEFINE_string(map_type, "identity",
+ "Map operation, one of: \"arc_sum\", \"identity\", \"invert\", "
+ "\"plus (--weight)\", \"quantize (--delta)\", \"rmweight\", "
+ "\"superfinal\", \"times (--weight)\", \"to_log\", \"to_log64\", "
+ "\"to_standard\"");
+DEFINE_string(weight, "", "Weight parameter");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+ using fst::script::VectorFstClass;
+
+ string usage = "Applies an operation to each arc of an FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_name = (argc > 1 && strcmp(argv[1], "-") != 0) ? argv[1] : "";
+ string out_name = argc > 2 ? argv[2] : "";
+
+ FstClass *ifst = FstClass::Read(in_name);
+ if (!ifst) return 1;
+
+ s::WeightClass w = !FLAGS_weight.empty() ?
+ s::WeightClass(ifst->WeightType(), FLAGS_weight) :
+ (FLAGS_map_type == "times" ?
+ s::WeightClass::One() : s::WeightClass::Zero());
+
+ s::MapType mt;
+ if (FLAGS_map_type == "arc_sum") {
+ mt = s::ARC_SUM_MAPPER;
+ } else if (FLAGS_map_type == "identity") {
+ mt = s::IDENTITY_MAPPER;
+ } else if (FLAGS_map_type == "invert") {
+ mt = s::INVERT_MAPPER;
+ } else if (FLAGS_map_type == "plus") {
+ mt = s::PLUS_MAPPER;
+ } else if (FLAGS_map_type == "quantize") {
+ mt = s::QUANTIZE_MAPPER;
+ } else if (FLAGS_map_type == "rmweight") {
+ mt = s::RMWEIGHT_MAPPER;
+ } else if (FLAGS_map_type == "superfinal") {
+ mt = s::SUPERFINAL_MAPPER;
+ } else if (FLAGS_map_type == "times") {
+ mt = s::TIMES_MAPPER;
+ } else if (FLAGS_map_type == "to_log") {
+ mt = s::TO_LOG_MAPPER;
+ } else if (FLAGS_map_type == "to_log64") {
+ mt = s::TO_LOG64_MAPPER;
+ } else if (FLAGS_map_type == "to_standard") {
+ mt = s::TO_STD_MAPPER;
+ } else {
+ LOG(ERROR) << argv[0] << ": Unknown map type \""
+ << FLAGS_map_type << "\"\n";
+ return 1;
+ }
+
+ FstClass *ofst = s::Map(*ifst, mt, FLAGS_delta, w);
+
+ ofst->Write(out_name);
+
+ return 0;
+}
diff --git a/src/bin/fstminimize.cc b/src/bin/fstminimize.cc
new file mode 100644
index 0000000..8d9d635
--- /dev/null
+++ b/src/bin/fstminimize.cc
@@ -0,0 +1,67 @@
+// fstminimize.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Minimizes a deterministic FSA.
+//
+
+#include <fst/script/minimize.h>
+
+DEFINE_double(delta, fst::kDelta, "Comparison/quantization delta");
+
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+ using fst::script::VectorFstClass;
+
+ string usage = "Minimizes a deterministic FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out1.fst [out2.fst]]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 4) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_name = (argc > 1 && strcmp(argv[1], "-") != 0) ? argv[1] : "";
+ string out1_name = (argc > 2 && strcmp(argv[2], "-") != 0) ? argv[2] : "";
+ string out2_name = (argc > 3 && strcmp(argv[3], "-") != 0) ? argv[3] : "";
+
+ if (out1_name.empty() && out2_name.empty() && argc > 3) {
+ LOG(ERROR) << "Both outputs can't be standard out.";
+ return 1;
+ }
+
+ MutableFstClass *fst1 = MutableFstClass::Read(in_name, true);
+ if (!fst1) return 1;
+
+ MutableFstClass *fst2 = argc > 3 ?
+ new VectorFstClass(fst1->ArcType()) : 0;
+
+ s::Minimize(fst1, fst2, FLAGS_delta);
+
+ fst1->Write(out1_name);
+ if (fst2)
+ fst2->Write(out2_name);
+
+ return 0;
+}
diff --git a/src/bin/fstprint.cc b/src/bin/fstprint.cc
new file mode 100644
index 0000000..b42bb7e
--- /dev/null
+++ b/src/bin/fstprint.cc
@@ -0,0 +1,105 @@
+// fstprint.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Prints out binary FSTs in simple text format used by AT&T
+// (see http://www.research.att.com/projects/mohri/fsm/doc4/fsm.5.html).
+
+#include <fst/script/print.h>
+
+DEFINE_bool(acceptor, false, "Input in acceptor format");
+DEFINE_string(isymbols, "", "Input label symbol table");
+DEFINE_string(osymbols, "", "Output label symbol table");
+DEFINE_string(ssymbols, "", "State label symbol table");
+DEFINE_bool(numeric, false, "Print numeric labels");
+DEFINE_string(save_isymbols, "", "Save input symbol table to file");
+DEFINE_string(save_osymbols, "", "Save output symbol table to file");
+DEFINE_bool(show_weight_one, false,
+ "Print/draw arc weights and final weights equal to Weight::One()");
+DEFINE_bool(allow_negative_labels, false,
+ "Allow negative labels (not recommended; may cause conflicts)");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::ostream;
+ using fst::SymbolTable;
+
+ string usage = "Prints out binary FSTs in simple text format.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [binary.fst [text.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_name = (argc > 1 && strcmp(argv[1], "-") != 0) ? argv[1] : "";
+ string out_name = argc > 2 ? argv[2] : "";
+
+ s::FstClass *fst = s::FstClass::Read(in_name);
+ if (!fst) return 1;
+
+ ostream *ostrm = &std::cout;
+ string dest = "standard output";
+ if (argc == 3) {
+ dest = argv[2];
+ ostrm = new fst::ofstream(argv[2]);
+ if (!*ostrm) {
+ LOG(ERROR) << argv[0] << ": Open failed, file = " << argv[2];
+ return 1;
+ }
+ }
+ ostrm->precision(9);
+
+ const SymbolTable *isyms = 0, *osyms = 0, *ssyms = 0;
+
+ if (!FLAGS_isymbols.empty() && !FLAGS_numeric) {
+ isyms = SymbolTable::ReadText(FLAGS_isymbols, FLAGS_allow_negative_labels);
+ if (!isyms) exit(1);
+ }
+
+ if (!FLAGS_osymbols.empty() && !FLAGS_numeric) {
+ osyms = SymbolTable::ReadText(FLAGS_osymbols, FLAGS_allow_negative_labels);
+ if (!osyms) exit(1);
+ }
+
+ if (!FLAGS_ssymbols.empty() && !FLAGS_numeric) {
+ ssyms = SymbolTable::ReadText(FLAGS_ssymbols);
+ if (!ssyms) exit(1);
+ }
+
+ if (!isyms && !FLAGS_numeric)
+ isyms = fst->InputSymbols();
+ if (!osyms && !FLAGS_numeric)
+ osyms = fst->OutputSymbols();
+
+ s::PrintFst(*fst, *ostrm, dest, isyms, osyms, ssyms,
+ FLAGS_acceptor, FLAGS_show_weight_one);
+
+ if (isyms && !FLAGS_save_isymbols.empty())
+ isyms->WriteText(FLAGS_save_isymbols);
+
+ if (osyms && !FLAGS_save_osymbols.empty())
+ osyms->WriteText(FLAGS_save_osymbols);
+
+ if (ostrm != &std::cout)
+ delete ostrm;
+ return 0;
+}
diff --git a/src/bin/fstproject.cc b/src/bin/fstproject.cc
new file mode 100644
index 0000000..a67f431
--- /dev/null
+++ b/src/bin/fstproject.cc
@@ -0,0 +1,58 @@
+// fstproject.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to work with FstClass
+//
+// \file
+// Projects a transduction onto its input or output language.
+//
+
+#include <fst/script/project.h>
+
+DEFINE_bool(project_output, false, "Project on output (vs. input)");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+
+ string usage = "Projects a transduction onto its input"
+ " or output language.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_name = (argc > 1 && strcmp(argv[1], "-") != 0) ? argv[1] : "";
+ string out_name = argc > 2 ? argv[2] : "";
+
+ MutableFstClass *fst = MutableFstClass::Read(in_name, true);
+ if (!fst) return 1;
+
+ fst::ProjectType project_type = FLAGS_project_output ?
+ fst::PROJECT_OUTPUT : fst::PROJECT_INPUT;
+
+ s::Project(fst, project_type);
+
+ fst->Write(out_name);
+
+ return 0;
+}
diff --git a/src/bin/fstprune.cc b/src/bin/fstprune.cc
new file mode 100644
index 0000000..2041b7c
--- /dev/null
+++ b/src/bin/fstprune.cc
@@ -0,0 +1,64 @@
+// fstprune.cc
+
+// 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: allauzen@google.com (Cyril Allauzen)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Prunes states and arcs of an FST w.r.t. the shortest path weight.
+//
+
+#include <fst/script/prune.h>
+
+DEFINE_double(delta, fst::kDelta, "Comparison/quantization delta");
+DEFINE_int64(nstate, fst::kNoStateId, "State number threshold");
+DEFINE_string(weight, "", "Weight threshold");
+
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+ using fst::script::WeightClass;
+
+ string usage = "Prunes states and arcs of an FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_name = (argc > 1 && strcmp(argv[1], "-") != 0) ? argv[1] : "";
+ string out_name = argc > 2 ? argv[2] : "";
+
+ MutableFstClass *fst = MutableFstClass::Read(in_name, true);
+ if (!fst) return 1;
+
+ WeightClass weight_threshold = FLAGS_weight.empty() ?
+ WeightClass::Zero() :
+ WeightClass(fst->WeightType(), FLAGS_weight);
+
+ s::PruneOptions opts(weight_threshold, FLAGS_nstate, 0, FLAGS_delta);
+
+ s::Prune(fst, opts);
+
+ fst->Write(out_name);
+
+ return 0;
+}
diff --git a/src/bin/fstpush.cc b/src/bin/fstpush.cc
new file mode 100644
index 0000000..3b849b5
--- /dev/null
+++ b/src/bin/fstpush.cc
@@ -0,0 +1,77 @@
+// fstpush.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+// \file
+// Pushes weights and/or output labels in an FST toward the initial or
+// final states.
+
+#include <fst/script/push.h>
+
+DEFINE_double(delta, fst::kDelta, "Comparison/quantization delta");
+DEFINE_bool(push_weights, false, "Push weights");
+DEFINE_bool(push_labels, false, "Push output labels");
+DEFINE_bool(remove_total_weight, false,
+ "Remove total weight when pushing weights");
+DEFINE_bool(remove_common_affix, false,
+ "Remove common prefix/suffix when pushing labels");
+DEFINE_bool(to_final, false, "Push/reweight to final (vs. to initial) states");
+
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::VectorFstClass;
+
+ string usage = "Pushes weights and/or olabels in an FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_name = (argc > 1 && strcmp(argv[1], "-") != 0) ? argv[1] : "";
+ string out_name = argc > 2 ? argv[2] : "";
+
+ FstClass *ifst = FstClass::Read(in_name);
+ if (!ifst) return 1;
+
+ uint32 flags = 0;
+ if (FLAGS_push_weights)
+ flags |= fst::kPushWeights;
+ if (FLAGS_push_labels)
+ flags |= fst::kPushLabels;
+ if (FLAGS_remove_total_weight)
+ flags |= fst::kPushRemoveTotalWeight;
+ if (FLAGS_remove_common_affix)
+ flags |= fst::kPushRemoveCommonAffix;
+
+ VectorFstClass ofst(ifst->ArcType());
+
+ if (FLAGS_to_final) {
+ s::Push(*ifst, &ofst, flags, fst::REWEIGHT_TO_FINAL, FLAGS_delta);
+ } else {
+ s::Push(*ifst, &ofst, flags, fst::REWEIGHT_TO_INITIAL, FLAGS_delta);
+ }
+
+ ofst.Write(out_name);
+
+ return 0;
+}
diff --git a/src/bin/fstrandgen.cc b/src/bin/fstrandgen.cc
new file mode 100644
index 0000000..f48d0cf
--- /dev/null
+++ b/src/bin/fstrandgen.cc
@@ -0,0 +1,82 @@
+// fstrandgen.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Generates random paths through an FST.
+
+#include <fst/script/randgen.h>
+
+DEFINE_int32(max_length, INT_MAX, "Maximum path length");
+DEFINE_int64(npath, 1, "Number of paths to generate");
+DEFINE_int32(seed, time(0), "Random seed");
+DEFINE_string(select, "uniform", "Selection type: one of: "
+ " \"uniform\", \"log_prob\" (when appropriate),"
+ " \"fast_log_prob\" (when appropriate)");
+DEFINE_bool(weighted, false,
+ "Output tree weighted by path count vs. unweighted paths");
+DEFINE_bool(remove_total_weight, false,
+ "Remove total weight when output weighted");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::VectorFstClass;
+
+ string usage = "Generates random paths through an FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ VLOG(1) << argv[0] << ": Seed = " << FLAGS_seed;
+
+ string in_name = (argc > 1 && strcmp(argv[1], "-") != 0) ? argv[1] : "";
+ string out_name = argc > 2 ? argv[2] : "";
+
+ FstClass *ifst = FstClass::Read(in_name);
+ if (!ifst) return 1;
+
+ VectorFstClass ofst(ifst->ArcType());
+
+ s::RandArcSelection ras;
+
+ if (FLAGS_select == "uniform") {
+ ras = s::UNIFORM_ARC_SELECTOR;
+ } else if (FLAGS_select == "log_prob") {
+ ras = s::LOG_PROB_ARC_SELECTOR;
+ } else if (FLAGS_select == "fast_log_prob") {
+ ras = s::FAST_LOG_PROB_ARC_SELECTOR;
+ } else {
+ LOG(ERROR) << argv[0] << ": Unknown selection type \""
+ << FLAGS_select << "\"\n";
+ return 1;
+ }
+
+ s::RandGen(*ifst, &ofst, FLAGS_seed,
+ fst::RandGenOptions<s::RandArcSelection>(
+ ras, FLAGS_max_length, FLAGS_npath,
+ FLAGS_weighted, FLAGS_remove_total_weight));
+
+ ofst.Write(out_name);
+ return 0;
+}
diff --git a/src/bin/fstrelabel.cc b/src/bin/fstrelabel.cc
new file mode 100644
index 0000000..cc86450
--- /dev/null
+++ b/src/bin/fstrelabel.cc
@@ -0,0 +1,117 @@
+// fstrelabel.cc
+
+// 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: johans@google.com (Johan Schalkwyk)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Relabel input or output space of Fst
+//
+
+#include <string>
+#include <vector>
+using std::vector;
+#include <utility>
+using std::pair; using std::make_pair;
+
+#include <fst/script/relabel.h>
+#include <fst/script/weight-class.h>
+#include <fst/util.h>
+
+DEFINE_string(isymbols, "", "Input label symbol table");
+DEFINE_string(osymbols, "", "Output label symbol table");
+DEFINE_string(relabel_isymbols, "", "Input symbol set to relabel to");
+DEFINE_string(relabel_osymbols, "", "Ouput symbol set to relabel to");
+DEFINE_string(relabel_ipairs, "", "Input relabel pairs (numeric)");
+DEFINE_string(relabel_opairs, "", "Output relabel pairs (numeric)");
+
+DEFINE_bool(allow_negative_labels, false,
+ "Allow negative labels (not recommended; may cause conflicts)");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::SymbolTable;
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+
+ string usage = "Relabels the input and/or the output labels of the FST.\n\n"
+ " Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+ usage += " Using SymbolTables flags:\n";
+ usage += " -relabel_isymbols isyms.txt\n";
+ usage += " -relabel_osymbols osyms.txt\n";
+ usage += " Using numeric labels flags:\n";
+ usage += " -relabel_ipairs ipairs.txt\n";
+ usage += " -relabel_opairs opairs.txts\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_name = (argc > 1 && (strcmp(argv[1], "-") != 0)) ? argv[1] : "";
+ string out_name = argc > 2 ? argv[2] : "";
+
+ MutableFstClass *fst = MutableFstClass::Read(in_name, true);
+ if (!fst) return 1;
+
+ // Relabel with symbol tables
+ if (!FLAGS_relabel_isymbols.empty() || !FLAGS_relabel_osymbols.empty()) {
+ bool attach_new_isymbols = (fst->InputSymbols() != 0);
+ const SymbolTable* old_isymbols = FLAGS_isymbols.empty()
+ ? fst->InputSymbols()
+ : SymbolTable::ReadText(FLAGS_isymbols, FLAGS_allow_negative_labels);
+ const SymbolTable* relabel_isymbols = FLAGS_relabel_isymbols.empty()
+ ? NULL
+ : SymbolTable::ReadText(FLAGS_relabel_isymbols,
+ FLAGS_allow_negative_labels);
+
+ bool attach_new_osymbols = (fst->OutputSymbols() != 0);
+ const SymbolTable* old_osymbols = FLAGS_osymbols.empty()
+ ? fst->OutputSymbols()
+ : SymbolTable::ReadText(FLAGS_osymbols, FLAGS_allow_negative_labels);
+ const SymbolTable* relabel_osymbols = FLAGS_relabel_osymbols.empty()
+ ? NULL
+ : SymbolTable::ReadText(FLAGS_relabel_osymbols,
+ FLAGS_allow_negative_labels);
+
+ s::Relabel(fst,
+ old_isymbols, relabel_isymbols, attach_new_isymbols,
+ old_osymbols, relabel_osymbols, attach_new_osymbols);
+ } else {
+ // read in relabel pairs and parse
+ typedef int64 Label;
+ vector<pair<Label, Label> > ipairs;
+ vector<pair<Label, Label> > opairs;
+ if (!FLAGS_relabel_ipairs.empty()) {
+ if(!fst::ReadLabelPairs(FLAGS_relabel_ipairs, &ipairs,
+ FLAGS_allow_negative_labels))
+ return 1;
+ }
+ if (!FLAGS_relabel_opairs.empty()) {
+ if (!fst::ReadLabelPairs(FLAGS_relabel_opairs, &opairs,
+ FLAGS_allow_negative_labels))
+ return 1;
+ }
+ s::Relabel(fst, ipairs, opairs);
+ }
+
+ fst->Write(out_name);
+
+ return 0;
+}
diff --git a/src/bin/fstreplace.cc b/src/bin/fstreplace.cc
new file mode 100644
index 0000000..5d1d770
--- /dev/null
+++ b/src/bin/fstreplace.cc
@@ -0,0 +1,65 @@
+
+// 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: johans@google.com (Johan Schalkwyk)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+
+#include <fst/script/replace.h>
+
+DEFINE_bool(epsilon_on_replace, false, "Create an espilon arc when recursing");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::VectorFstClass;
+
+ string usage = "Recursively replaces FST arcs with other FST(s).\n\n"
+ " Usage: ";
+ usage += argv[0];
+ usage += " root.fst rootlabel [rule1.fst label1 ...] [out.fst]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc < 4) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_fname = argv[1];
+ string out_fname = argc % 2 == 0 ? argv[argc - 1] : "";
+
+ FstClass *ifst = FstClass::Read(in_fname);
+ if (!ifst) return 1;
+
+ typedef int64 Label;
+ typedef pair<Label, const s::FstClass* > FstTuple;
+ vector<FstTuple> fst_tuples;
+ Label root = atoll(argv[2]);
+ fst_tuples.push_back(make_pair(root, ifst));
+
+ for (size_t i = 3; i < argc - 1; i += 2) {
+ ifst = s::FstClass::Read(argv[i]);
+ if (!ifst) return 1;
+ Label lab = atoll(argv[i + 1]);
+ fst_tuples.push_back(make_pair(lab, ifst));
+ }
+
+ VectorFstClass ofst(ifst->ArcType());
+ Replace(fst_tuples, &ofst, root, FLAGS_epsilon_on_replace);
+
+ ofst.Write(out_fname);
+
+ return 0;
+}
diff --git a/src/bin/fstreverse.cc b/src/bin/fstreverse.cc
new file mode 100644
index 0000000..7507ffa
--- /dev/null
+++ b/src/bin/fstreverse.cc
@@ -0,0 +1,59 @@
+// fstreverse.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) Changed to use FstClass
+//
+// \file
+// Reverses the paths in an FST.
+//
+
+#include <string>
+
+#include <fst/script/reverse.h>
+#include <fst/script/fst-class.h>
+#include <iostream>
+#include <fstream>
+
+int main(int argc, char **argv) {
+ using fst::script::FstClass;
+ using fst::script::VectorFstClass;
+ using fst::script::Reverse;
+
+ string usage = "Reverses the paths in an FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_name = (argc > 1 && (strcmp(argv[1], "-") != 0)) ? argv[1] : "";
+ string out_name = argc > 2 ? argv[2] : "";
+
+ FstClass *ifst = FstClass::Read(in_name);
+ if (!ifst) return 1;
+
+ VectorFstClass *out = new VectorFstClass(ifst->ArcType());
+
+ Reverse(*ifst, out);
+
+ out->Write(out_name);
+
+ return 0;
+}
diff --git a/src/bin/fstreweight.cc b/src/bin/fstreweight.cc
new file mode 100644
index 0000000..3913a6d
--- /dev/null
+++ b/src/bin/fstreweight.cc
@@ -0,0 +1,63 @@
+// fstreweight.cc
+
+// 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: allauzen@google.com (Cyril Allauzen)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Reweights an FST.
+//
+
+#include <fst/script/reweight.h>
+#include <fst/script/text-io.h>
+
+DEFINE_bool(to_final, false, "Push/reweight to final (vs. to initial) states");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+
+ string usage = "Reweights an FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " in.fst potential.txt [out.fst]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc < 3 || argc > 4) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_fname = argv[1];
+ string potentials_fname = argv[2];
+ string out_fname = argc > 3 ? argv[3] : "";
+
+ MutableFstClass *fst = MutableFstClass::Read(in_fname, true);
+ if (!fst) return 1;
+
+ vector<s::WeightClass> potential;
+ if (!s::ReadPotentials(fst->WeightType(), potentials_fname, &potential))
+ return 1;
+
+ fst::ReweightType reweight_type = FLAGS_to_final ?
+ fst::REWEIGHT_TO_FINAL :
+ fst::REWEIGHT_TO_INITIAL;
+
+ s::Reweight(fst, potential, reweight_type);
+ fst->Write(out_fname);
+
+ return 0;
+}
diff --git a/src/bin/fstrmepsilon.cc b/src/bin/fstrmepsilon.cc
new file mode 100644
index 0000000..63a80b8
--- /dev/null
+++ b/src/bin/fstrmepsilon.cc
@@ -0,0 +1,89 @@
+// fstrmepsilon.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Removes epsilons from an FST.
+//
+
+#include <fst/script/rmepsilon.h>
+
+DEFINE_bool(connect, true, "Trim output");
+DEFINE_double(delta, fst::kDelta, "Comparison/quantization delta");
+DEFINE_int64(nstate, fst::kNoStateId, "State number threshold");
+DEFINE_bool(reverse, false, "Perform in the reverse direction");
+DEFINE_string(weight, "", "Weight threshold");
+DEFINE_string(queue_type, "auto", "Queue type: one of: \"auto\", "
+ "\"fifo\", \"lifo\", \"shortest\", \"state\", \"top\"");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+ using fst::script::VectorFstClass;
+ using fst::script::WeightClass;
+
+ string usage = "Removes epsilons from an FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_fname = (argc > 1 && strcmp(argv[1], "-") != 0) ? argv[1] : "";
+ string out_fname = argc > 2 ? argv[2] : "";
+
+ FstClass *ifst = FstClass::Read(in_fname);
+ if (!ifst) return 1;
+
+ WeightClass weight_threshold = FLAGS_weight.empty() ?
+ WeightClass::Zero() :
+ WeightClass(ifst->WeightType(), FLAGS_weight);
+
+ fst::QueueType qt;
+
+ if (FLAGS_queue_type == "auto") {
+ qt = fst::AUTO_QUEUE;
+ } else if (FLAGS_queue_type == "fifo") {
+ qt = fst::FIFO_QUEUE;
+ } else if (FLAGS_queue_type == "lifo") {
+ qt = fst::LIFO_QUEUE;
+ } else if (FLAGS_queue_type == "shortest") {
+ qt = fst::SHORTEST_FIRST_QUEUE;
+ } else if (FLAGS_queue_type == "state") {
+ qt = fst::STATE_ORDER_QUEUE;
+ } else if (FLAGS_queue_type == "top") {
+ qt = fst::TOP_ORDER_QUEUE;
+ } else {
+ LOG(ERROR) << "Unknown or unsupported queue type: " << FLAGS_queue_type;
+ return 1;
+ }
+
+ s::RmEpsilonOptions opts(qt, FLAGS_delta, FLAGS_connect,
+ weight_threshold, FLAGS_nstate);
+
+ MutableFstClass *ofst = new VectorFstClass(ifst->ArcType());
+ s::RmEpsilon(*ifst, ofst, FLAGS_reverse, opts);
+
+ ofst->Write(out_fname);
+
+ return 0;
+}
diff --git a/src/bin/fstshortestdistance.cc b/src/bin/fstshortestdistance.cc
new file mode 100644
index 0000000..01f5617
--- /dev/null
+++ b/src/bin/fstshortestdistance.cc
@@ -0,0 +1,93 @@
+// fstshortestdistance.cc
+
+// 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: allauzen@google.com (Cyril Allauzen)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Find shortest distances in an FST.
+
+#include <string>
+#include <vector>
+using std::vector;
+
+#include <fst/script/shortest-distance.h>
+#include <fst/script/text-io.h>
+
+DEFINE_bool(reverse, false, "Perform in the reverse direction");
+DEFINE_double(delta, fst::kDelta, "Comparison/quantization delta");
+DEFINE_int64(nstate, fst::kNoStateId, "State number threhold");
+DEFINE_string(queue_type, "auto", "Queue type: one of: \"auto\", "
+ "\"fifo\", \"lifo\", \"shortest\", \"state\", \"top\"");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+
+ string usage = "Finds shortest distance(s) in an FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [distance.txt]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_fname = (argc > 1 && (strcmp(argv[1], "-") != 0)) ? argv[1] : "";
+ string out_fname = argc > 2 ? argv[2] : "";
+
+ FstClass *ifst = FstClass::Read(in_fname);
+ if (!ifst) return 1;
+
+ vector<s::WeightClass> distance;
+
+ fst::QueueType qt;
+
+ if (FLAGS_queue_type == "auto") {
+ qt = fst::AUTO_QUEUE;
+ } else if (FLAGS_queue_type == "fifo") {
+ qt = fst::FIFO_QUEUE;
+ } else if (FLAGS_queue_type == "lifo") {
+ qt = fst::LIFO_QUEUE;
+ } else if (FLAGS_queue_type == "shortest") {
+ qt = fst::SHORTEST_FIRST_QUEUE;
+ } else if (FLAGS_queue_type == "state") {
+ qt = fst::STATE_ORDER_QUEUE;
+ } else if (FLAGS_queue_type == "top") {
+ qt = fst::TOP_ORDER_QUEUE;
+ } else {
+ LOG(ERROR) << "Unknown or unsupported queue type: " << FLAGS_queue_type;
+ return 1;
+ }
+
+ if (FLAGS_reverse && qt != fst::AUTO_QUEUE) {
+ LOG(ERROR) << "Specifying a non-default queue with reverse not supported.";
+ return 1;
+ }
+
+ if (FLAGS_reverse) {
+ s::ShortestDistance(*ifst, &distance, FLAGS_reverse, FLAGS_delta);
+ } else {
+ s::ShortestDistanceOptions opts(qt, s::ANY_ARC_FILTER,
+ FLAGS_nstate, FLAGS_delta);
+ s::ShortestDistance(*ifst, &distance, opts);
+ }
+
+ s::WritePotentials(out_fname, distance);
+
+ return 0;
+}
diff --git a/src/bin/fstshortestpath.cc b/src/bin/fstshortestpath.cc
new file mode 100644
index 0000000..4a9e720
--- /dev/null
+++ b/src/bin/fstshortestpath.cc
@@ -0,0 +1,92 @@
+// fstshortestpath.cc
+
+// 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: allauzen@google.com (Cyril Allauzen)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Find shortest path(s) in an FST.
+
+#include <fst/script/shortest-path.h>
+
+DEFINE_double(delta, fst::kDelta, "Comparison/quantization delta");
+DEFINE_int64(nshortest, 1, "Return N-shortest paths");
+DEFINE_bool(unique, false, "Return unique strings");
+DEFINE_string(weight, "", "Weight threshold");
+DEFINE_int64(nstate, fst::kNoStateId, "State number threshold");
+DEFINE_string(queue_type, "auto", "Queue type: one of \"auto\", "
+ "\"fifo\", \"lifo\", \"shortest\', \"state\", \"top\"");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+ using fst::script::VectorFstClass;
+ using fst::script::WeightClass;
+
+ string usage = "Finds shortest path(s) in an FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_fname = (argc > 1 && (strcmp(argv[1], "-") != 0)) ? argv[1] : "";
+ string out_fname = argc > 2 ? argv[2] : "";
+
+ FstClass *ifst = FstClass::Read(in_fname);
+ if (!ifst) return 1;
+
+ WeightClass weight_threshold = FLAGS_weight.empty() ?
+ WeightClass::Zero() :
+ WeightClass(ifst->WeightType(), FLAGS_weight);
+
+ VectorFstClass ofst(ifst->ArcType());
+ vector<WeightClass> distance;
+
+ fst::QueueType qt;
+
+ if (FLAGS_queue_type == "auto") {
+ qt = fst::AUTO_QUEUE;
+ } else if (FLAGS_queue_type == "fifo") {
+ qt = fst::FIFO_QUEUE;
+ } else if (FLAGS_queue_type == "lifo") {
+ qt = fst::LIFO_QUEUE;
+ } else if (FLAGS_queue_type == "shortest") {
+ qt = fst::SHORTEST_FIRST_QUEUE;
+ } else if (FLAGS_queue_type == "state") {
+ qt = fst::STATE_ORDER_QUEUE;
+ } else if (FLAGS_queue_type == "top") {
+ qt = fst::TOP_ORDER_QUEUE;
+ } else {
+ LOG(ERROR) << "Unknown or unsupported queue type: " << FLAGS_queue_type;
+ return 1;
+ }
+
+ s::ShortestPathOptions opts(
+ qt, FLAGS_nshortest, FLAGS_unique, false, FLAGS_delta,
+ false, weight_threshold, FLAGS_nstate);
+
+ s::ShortestPath(*ifst, &ofst, &distance, opts);
+
+ ofst.Write(out_fname);
+
+ return 0;
+}
diff --git a/src/bin/fstsymbols.cc b/src/bin/fstsymbols.cc
new file mode 100644
index 0000000..c07f1be
--- /dev/null
+++ b/src/bin/fstsymbols.cc
@@ -0,0 +1,117 @@
+// fstsymbols.cc
+
+// 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: allauzen@google.com (Cyril Allauzen)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Performs operations (set, clear, relabel) on the symbols table
+// attached to the input Fst.
+//
+
+#include <fst/script/fst-class.h>
+#include <fst/script/script-impl.h>
+#include <fst/script/verify.h>
+#include <fst/util.h>
+
+DEFINE_string(isymbols, "", "Input label symbol table");
+DEFINE_string(osymbols, "", "Output label symbol table");
+DEFINE_bool(clear_isymbols, false, "Clear input symbol table");
+DEFINE_bool(clear_osymbols, false, "Clear output symbol table");
+DEFINE_string(relabel_ipairs, "", "Input relabel pairs (numeric)");
+DEFINE_string(relabel_opairs, "", "Output relabel pairs (numeric)");
+DEFINE_string(save_isymbols, "", "Save fst file's input symbol table to file");
+DEFINE_string(save_osymbols, "", "Save fst file's output symbol table to file");
+DEFINE_bool(allow_negative_labels, false,
+ "Allow negative labels (not recommended; may cause conflicts)");
+DEFINE_bool(verify, false, "Verify fst properities before saving");
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::SymbolTable;
+
+ string usage = "Performs operations (set, clear, relabel) on the symbol"
+ " tables attached to an FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_fname = argc > 1 && strcmp(argv[1], "-") != 0 ? argv[1] : "";
+ string out_fname = argc > 2 ? argv[2] : "";
+
+ s::MutableFstClass *fst = s::MutableFstClass::Read(in_fname, true);
+ if (!fst) return 1;
+
+ if (!FLAGS_save_isymbols.empty()) {
+ const SymbolTable *isyms = fst->InputSymbols();
+ if (isyms) {
+ isyms->WriteText(FLAGS_save_isymbols);
+ } else {
+ LOG(ERROR) << "save isymbols requested but there are no input symbols.";
+ }
+ }
+
+ if (!FLAGS_save_osymbols.empty()) {
+ const SymbolTable *osyms = fst->OutputSymbols();
+ if (osyms) {
+ osyms->WriteText(FLAGS_save_osymbols);
+ } else {
+ LOG(ERROR) << "save osymbols requested but there are no output symbols.";
+ }
+ }
+
+ if (FLAGS_clear_isymbols)
+ fst->SetInputSymbols(0);
+ else if (!FLAGS_isymbols.empty())
+ fst->SetInputSymbols(
+ SymbolTable::ReadText(FLAGS_isymbols, FLAGS_allow_negative_labels));
+
+ if (FLAGS_clear_osymbols)
+ fst->SetOutputSymbols(0);
+ else if (!FLAGS_osymbols.empty())
+ fst->SetOutputSymbols(
+ SymbolTable::ReadText(FLAGS_osymbols, FLAGS_allow_negative_labels));
+
+ if (!FLAGS_relabel_ipairs.empty()) {
+ typedef int64 Label;
+ vector<pair<Label, Label> > ipairs;
+ fst::ReadLabelPairs(FLAGS_relabel_ipairs, &ipairs,
+ FLAGS_allow_negative_labels);
+ SymbolTable *isyms = RelabelSymbolTable(fst->InputSymbols(), ipairs);
+ fst->SetInputSymbols(isyms);
+ delete isyms;
+ }
+
+ if (!FLAGS_relabel_opairs.empty()) {
+ typedef int64 Label;
+ vector<pair<Label, Label> > opairs;
+ fst::ReadLabelPairs(FLAGS_relabel_opairs, &opairs,
+ FLAGS_allow_negative_labels);
+ SymbolTable *osyms = RelabelSymbolTable(fst->OutputSymbols(), opairs);
+ fst->SetOutputSymbols(osyms);
+ delete osyms;
+ }
+
+ if (FLAGS_verify && !s::Verify(*fst))
+ return 1;
+ fst->Write(out_fname);
+ return 0;
+}
diff --git a/src/bin/fstsynchronize.cc b/src/bin/fstsynchronize.cc
new file mode 100644
index 0000000..7137504
--- /dev/null
+++ b/src/bin/fstsynchronize.cc
@@ -0,0 +1,54 @@
+// fstsynchronize.cc
+
+// 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: allauzen@google.com (Cyril Allauzen)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Synchronizes an FST.
+//
+
+#include <fst/script/synchronize.h>
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::VectorFstClass;
+
+ string usage = "Synchronizes an FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_name = (argc > 1 && strcmp(argv[1], "-") != 0) ? argv[1] : "";
+ string out_name = argc > 2 ? argv[2] : "";
+
+ FstClass *ifst = FstClass::Read(in_name);
+ if (!ifst) return 1;
+
+ VectorFstClass ofst(ifst->ArcType());
+
+ s::Synchronize(*ifst, &ofst);
+
+ ofst.Write(out_name);
+
+ return 0;
+}
diff --git a/src/bin/fsttopsort.cc b/src/bin/fsttopsort.cc
new file mode 100644
index 0000000..6f04215
--- /dev/null
+++ b/src/bin/fsttopsort.cc
@@ -0,0 +1,53 @@
+// fsttopsort.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass
+//
+// \file
+// Topologically sorts an FST.
+//
+
+#include <fst/script/topsort.h>
+
+int main(int argc, char **argv) {
+ namespace s = fst::script;
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+
+ string usage = "Topologically sorts an FST.\n\n Usage: ";
+ usage += argv[0];
+ usage += " [in.fst [out.fst]]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc > 3) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in_fname = argc > 1 && strcmp(argv[1], "-") != 0 ? argv[1] : "";
+ string out_fname = argc > 2 ? argv[2] : "";
+
+ MutableFstClass *fst = MutableFstClass::Read(in_fname, true);
+ if (!fst) return 1;
+
+ bool acyclic = TopSort(fst);
+ if (!acyclic)
+ LOG(WARNING) << argv[0] << ": Input FST is cyclic";
+ fst->Write(out_fname);
+
+ return 0;
+}
diff --git a/src/bin/fstunion.cc b/src/bin/fstunion.cc
new file mode 100644
index 0000000..41c4f83
--- /dev/null
+++ b/src/bin/fstunion.cc
@@ -0,0 +1,67 @@
+// fstunion.cc
+
+// 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: riley@google.com (Michael Riley)
+// Modified: jpr@google.com (Jake Ratkiewicz) - to use FstClass
+//
+// \file
+// Creates the union of two FSTs.
+//
+
+#include <string>
+
+#include <fst/script/union.h>
+#include <iostream>
+#include <fstream>
+
+int main(int argc, char **argv) {
+ using fst::script::FstClass;
+ using fst::script::MutableFstClass;
+ using fst::script::Union;
+
+ string usage = "Creates the union of two FSTs.\n\n Usage: ";
+ usage += argv[0];
+ usage += " in1.fst in2.fst [out.fst]\n";
+
+ std::set_new_handler(FailedNewHandler);
+ SetFlags(usage.c_str(), &argc, &argv, true);
+ if (argc < 3 || argc > 4) {
+ ShowUsage();
+ return 1;
+ }
+
+ string in1_name = strcmp(argv[1], "-") != 0 ? argv[1] : "";
+ string in2_name = strcmp(argv[2], "-") != 0 ? argv[2] : "";
+ string out_name = argc > 3 ? argv[3] : "";
+
+ if (in1_name == "" && in2_name == "") {
+ LOG(ERROR) << argv[0]
+ << ": Can't use standard i/o for both inputs.";
+ return 1;
+ }
+
+ MutableFstClass *fst1 = MutableFstClass::Read(in1_name, true);
+ if (!fst1) return 1;
+
+ FstClass *fst2 = FstClass::Read(in2_name);
+ if (!fst2) {
+ return 1;
+ }
+
+ Union(fst1, *fst2);
+ fst1->Write(out_name);
+
+ return 0;
+}