diff options
Diffstat (limited to 'src/extensions/pdt')
-rw-r--r-- | src/extensions/pdt/Makefile.am | 29 | ||||
-rw-r--r-- | src/extensions/pdt/Makefile.in | 663 | ||||
-rw-r--r-- | src/extensions/pdt/pdtcompose.cc | 82 | ||||
-rw-r--r-- | src/extensions/pdt/pdtexpand.cc | 71 | ||||
-rw-r--r-- | src/extensions/pdt/pdtinfo.cc | 59 | ||||
-rw-r--r-- | src/extensions/pdt/pdtreplace.cc | 73 | ||||
-rw-r--r-- | src/extensions/pdt/pdtreverse.cc | 61 | ||||
-rw-r--r-- | src/extensions/pdt/pdtscript.cc | 115 | ||||
-rw-r--r-- | src/extensions/pdt/pdtshortestpath.cc | 81 |
9 files changed, 1234 insertions, 0 deletions
diff --git a/src/extensions/pdt/Makefile.am b/src/extensions/pdt/Makefile.am new file mode 100644 index 0000000..9936b52 --- /dev/null +++ b/src/extensions/pdt/Makefile.am @@ -0,0 +1,29 @@ +AM_CPPFLAGS = -I$(srcdir)/../../include $(ICU_CPPFLAGS) + +if HAVE_BIN +bin_PROGRAMS = pdtcompose pdtexpand pdtinfo pdtreplace pdtreverse \ + pdtshortestpath + +LDADD = libfstpdtscript.la ../../script/libfstscript.la \ + ../../lib/libfst.la -lm -ldl + +pdtcompose_SOURCES = pdtcompose.cc + +pdtexpand_SOURCES = pdtexpand.cc + +pdtinfo_SOURCES = pdtinfo.cc + +pdtreplace_SOURCES = pdtreplace.cc + +pdtreverse_SOURCES = pdtreverse.cc + +pdtshortestpath_SOURCES = pdtshortestpath.cc +endif + +libfstdir = @libfstdir@ + +if HAVE_SCRIPT +libfst_LTLIBRARIES = libfstpdtscript.la +libfstpdtscript_la_SOURCES = pdtscript.cc +libfstpdtscript_la_LDFLAGS = -version-info 0:0:0 +endif diff --git a/src/extensions/pdt/Makefile.in b/src/extensions/pdt/Makefile.in new file mode 100644 index 0000000..018f344 --- /dev/null +++ b/src/extensions/pdt/Makefile.in @@ -0,0 +1,663 @@ +# 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 = pdtcompose$(EXEEXT) pdtexpand$(EXEEXT) \ +@HAVE_BIN_TRUE@ pdtinfo$(EXEEXT) pdtreplace$(EXEEXT) \ +@HAVE_BIN_TRUE@ pdtreverse$(EXEEXT) pdtshortestpath$(EXEEXT) +subdir = src/extensions/pdt +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_icu.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/src/include/fst/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__installdirs = "$(DESTDIR)$(libfstdir)" "$(DESTDIR)$(bindir)" +LTLIBRARIES = $(libfst_LTLIBRARIES) +libfstpdtscript_la_LIBADD = +am__libfstpdtscript_la_SOURCES_DIST = pdtscript.cc +@HAVE_SCRIPT_TRUE@am_libfstpdtscript_la_OBJECTS = pdtscript.lo +libfstpdtscript_la_OBJECTS = $(am_libfstpdtscript_la_OBJECTS) +libfstpdtscript_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(libfstpdtscript_la_LDFLAGS) $(LDFLAGS) -o $@ +@HAVE_SCRIPT_TRUE@am_libfstpdtscript_la_rpath = -rpath $(libfstdir) +PROGRAMS = $(bin_PROGRAMS) +am__pdtcompose_SOURCES_DIST = pdtcompose.cc +@HAVE_BIN_TRUE@am_pdtcompose_OBJECTS = pdtcompose.$(OBJEXT) +pdtcompose_OBJECTS = $(am_pdtcompose_OBJECTS) +pdtcompose_LDADD = $(LDADD) +@HAVE_BIN_TRUE@pdtcompose_DEPENDENCIES = libfstpdtscript.la \ +@HAVE_BIN_TRUE@ ../../script/libfstscript.la \ +@HAVE_BIN_TRUE@ ../../lib/libfst.la +am__pdtexpand_SOURCES_DIST = pdtexpand.cc +@HAVE_BIN_TRUE@am_pdtexpand_OBJECTS = pdtexpand.$(OBJEXT) +pdtexpand_OBJECTS = $(am_pdtexpand_OBJECTS) +pdtexpand_LDADD = $(LDADD) +@HAVE_BIN_TRUE@pdtexpand_DEPENDENCIES = libfstpdtscript.la \ +@HAVE_BIN_TRUE@ ../../script/libfstscript.la \ +@HAVE_BIN_TRUE@ ../../lib/libfst.la +am__pdtinfo_SOURCES_DIST = pdtinfo.cc +@HAVE_BIN_TRUE@am_pdtinfo_OBJECTS = pdtinfo.$(OBJEXT) +pdtinfo_OBJECTS = $(am_pdtinfo_OBJECTS) +pdtinfo_LDADD = $(LDADD) +@HAVE_BIN_TRUE@pdtinfo_DEPENDENCIES = libfstpdtscript.la \ +@HAVE_BIN_TRUE@ ../../script/libfstscript.la \ +@HAVE_BIN_TRUE@ ../../lib/libfst.la +am__pdtreplace_SOURCES_DIST = pdtreplace.cc +@HAVE_BIN_TRUE@am_pdtreplace_OBJECTS = pdtreplace.$(OBJEXT) +pdtreplace_OBJECTS = $(am_pdtreplace_OBJECTS) +pdtreplace_LDADD = $(LDADD) +@HAVE_BIN_TRUE@pdtreplace_DEPENDENCIES = libfstpdtscript.la \ +@HAVE_BIN_TRUE@ ../../script/libfstscript.la \ +@HAVE_BIN_TRUE@ ../../lib/libfst.la +am__pdtreverse_SOURCES_DIST = pdtreverse.cc +@HAVE_BIN_TRUE@am_pdtreverse_OBJECTS = pdtreverse.$(OBJEXT) +pdtreverse_OBJECTS = $(am_pdtreverse_OBJECTS) +pdtreverse_LDADD = $(LDADD) +@HAVE_BIN_TRUE@pdtreverse_DEPENDENCIES = libfstpdtscript.la \ +@HAVE_BIN_TRUE@ ../../script/libfstscript.la \ +@HAVE_BIN_TRUE@ ../../lib/libfst.la +am__pdtshortestpath_SOURCES_DIST = pdtshortestpath.cc +@HAVE_BIN_TRUE@am_pdtshortestpath_OBJECTS = pdtshortestpath.$(OBJEXT) +pdtshortestpath_OBJECTS = $(am_pdtshortestpath_OBJECTS) +pdtshortestpath_LDADD = $(LDADD) +@HAVE_BIN_TRUE@pdtshortestpath_DEPENDENCIES = libfstpdtscript.la \ +@HAVE_BIN_TRUE@ ../../script/libfstscript.la \ +@HAVE_BIN_TRUE@ ../../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 = $(libfstpdtscript_la_SOURCES) $(pdtcompose_SOURCES) \ + $(pdtexpand_SOURCES) $(pdtinfo_SOURCES) $(pdtreplace_SOURCES) \ + $(pdtreverse_SOURCES) $(pdtshortestpath_SOURCES) +DIST_SOURCES = $(am__libfstpdtscript_la_SOURCES_DIST) \ + $(am__pdtcompose_SOURCES_DIST) $(am__pdtexpand_SOURCES_DIST) \ + $(am__pdtinfo_SOURCES_DIST) $(am__pdtreplace_SOURCES_DIST) \ + $(am__pdtreverse_SOURCES_DIST) \ + $(am__pdtshortestpath_SOURCES_DIST) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +ICU_CFLAGS = @ICU_CFLAGS@ +ICU_CONFIG = @ICU_CONFIG@ +ICU_CPPFLAGS = @ICU_CPPFLAGS@ +ICU_CXXFLAGS = @ICU_CXXFLAGS@ +ICU_LIBS = @ICU_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +libfstdir = @libfstdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AM_CPPFLAGS = -I$(srcdir)/../../include $(ICU_CPPFLAGS) +@HAVE_BIN_TRUE@LDADD = libfstpdtscript.la ../../script/libfstscript.la \ +@HAVE_BIN_TRUE@ ../../lib/libfst.la -lm -ldl + +@HAVE_BIN_TRUE@pdtcompose_SOURCES = pdtcompose.cc +@HAVE_BIN_TRUE@pdtexpand_SOURCES = pdtexpand.cc +@HAVE_BIN_TRUE@pdtinfo_SOURCES = pdtinfo.cc +@HAVE_BIN_TRUE@pdtreplace_SOURCES = pdtreplace.cc +@HAVE_BIN_TRUE@pdtreverse_SOURCES = pdtreverse.cc +@HAVE_BIN_TRUE@pdtshortestpath_SOURCES = pdtshortestpath.cc +@HAVE_SCRIPT_TRUE@libfst_LTLIBRARIES = libfstpdtscript.la +@HAVE_SCRIPT_TRUE@libfstpdtscript_la_SOURCES = pdtscript.cc +@HAVE_SCRIPT_TRUE@libfstpdtscript_la_LDFLAGS = -version-info 0:0:0 +all: all-am + +.SUFFIXES: +.SUFFIXES: .cc .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/extensions/pdt/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/extensions/pdt/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-libfstLTLIBRARIES: $(libfst_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libfstdir)" || $(MKDIR_P) "$(DESTDIR)$(libfstdir)" + @list='$(libfst_LTLIBRARIES)'; test -n "$(libfstdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libfstdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libfstdir)"; \ + } + +uninstall-libfstLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(libfst_LTLIBRARIES)'; test -n "$(libfstdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libfstdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libfstdir)/$$f"; \ + done + +clean-libfstLTLIBRARIES: + -test -z "$(libfst_LTLIBRARIES)" || rm -f $(libfst_LTLIBRARIES) + @list='$(libfst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libfstpdtscript.la: $(libfstpdtscript_la_OBJECTS) $(libfstpdtscript_la_DEPENDENCIES) + $(libfstpdtscript_la_LINK) $(am_libfstpdtscript_la_rpath) $(libfstpdtscript_la_OBJECTS) $(libfstpdtscript_la_LIBADD) $(LIBS) +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 +pdtcompose$(EXEEXT): $(pdtcompose_OBJECTS) $(pdtcompose_DEPENDENCIES) + @rm -f pdtcompose$(EXEEXT) + $(CXXLINK) $(pdtcompose_OBJECTS) $(pdtcompose_LDADD) $(LIBS) +pdtexpand$(EXEEXT): $(pdtexpand_OBJECTS) $(pdtexpand_DEPENDENCIES) + @rm -f pdtexpand$(EXEEXT) + $(CXXLINK) $(pdtexpand_OBJECTS) $(pdtexpand_LDADD) $(LIBS) +pdtinfo$(EXEEXT): $(pdtinfo_OBJECTS) $(pdtinfo_DEPENDENCIES) + @rm -f pdtinfo$(EXEEXT) + $(CXXLINK) $(pdtinfo_OBJECTS) $(pdtinfo_LDADD) $(LIBS) +pdtreplace$(EXEEXT): $(pdtreplace_OBJECTS) $(pdtreplace_DEPENDENCIES) + @rm -f pdtreplace$(EXEEXT) + $(CXXLINK) $(pdtreplace_OBJECTS) $(pdtreplace_LDADD) $(LIBS) +pdtreverse$(EXEEXT): $(pdtreverse_OBJECTS) $(pdtreverse_DEPENDENCIES) + @rm -f pdtreverse$(EXEEXT) + $(CXXLINK) $(pdtreverse_OBJECTS) $(pdtreverse_LDADD) $(LIBS) +pdtshortestpath$(EXEEXT): $(pdtshortestpath_OBJECTS) $(pdtshortestpath_DEPENDENCIES) + @rm -f pdtshortestpath$(EXEEXT) + $(CXXLINK) $(pdtshortestpath_OBJECTS) $(pdtshortestpath_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdtcompose.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdtexpand.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdtinfo.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdtreplace.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdtreverse.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdtscript.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdtshortestpath.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 $(LTLIBRARIES) $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(libfstdir)" "$(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-libfstLTLIBRARIES \ + 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-libfstLTLIBRARIES + +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 uninstall-libfstLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libfstLTLIBRARIES 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-libfstLTLIBRARIES \ + 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 uninstall-libfstLTLIBRARIES + + +# 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/extensions/pdt/pdtcompose.cc b/src/extensions/pdt/pdtcompose.cc new file mode 100644 index 0000000..0bab405 --- /dev/null +++ b/src/extensions/pdt/pdtcompose.cc @@ -0,0 +1,82 @@ +// pdtcompose.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) +// +// \file +// Composes a PDT and an FST. +// + +#include <vector> +using std::vector; +#include <utility> +using std::pair; using std::make_pair; + +#include <fst/util.h> +#include <fst/extensions/pdt/pdtscript.h> +#include <fst/script/connect.h> + +DEFINE_string(pdt_parentheses, "", "PDT parenthesis label pairs."); +DEFINE_bool(left_pdt, true, "1st arg is PDT (o.w. 2nd arg)."); +DEFINE_bool(connect, true, "Trim output"); + +int main(int argc, char **argv) { + namespace s = fst::script; + + string usage = "Compose a PDT and an FST.\n\n Usage: "; + usage += argv[0]; + usage += " in.pdt in.fst [out.pdt]\n"; + usage += " in.fst in.pdt [out.pdt]\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; + } + + s::FstClass *ifst1 = s::FstClass::Read(in1_name); + if (!ifst1) return 1; + s::FstClass *ifst2 = s::FstClass::Read(in2_name); + if (!ifst2) return 1; + + if (FLAGS_pdt_parentheses.empty()) { + LOG(ERROR) << argv[0] << ": No PDT parenthesis label pairs provided"; + return 1; + } + + vector<pair<int64, int64> > parens; + fst::ReadLabelPairs(FLAGS_pdt_parentheses, &parens, false); + + s::VectorFstClass ofst(ifst1->ArcType()); + fst::ComposeOptions copts(false); + + s::PdtCompose(*ifst1, *ifst2, parens, &ofst, copts, FLAGS_left_pdt); + + if (FLAGS_connect) + s::Connect(&ofst); + ofst.Write(out_name); + + return 0; +} diff --git a/src/extensions/pdt/pdtexpand.cc b/src/extensions/pdt/pdtexpand.cc new file mode 100644 index 0000000..2134932 --- /dev/null +++ b/src/extensions/pdt/pdtexpand.cc @@ -0,0 +1,71 @@ +// pdtexpand.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 +// Expands a PDT and an FST. +// + +#include <fst/extensions/pdt/pdtscript.h> +#include <fst/util.h> + +DEFINE_string(pdt_parentheses, "", "PDT parenthesis label pairs."); +DEFINE_bool(connect, true, "Trim output"); +DEFINE_bool(keep_parentheses, false, "Keep PDT parentheses in result."); +DEFINE_string(weight, "", "Weight threshold"); + + +int main(int argc, char **argv) { + namespace s = fst::script; + + string usage = "Expand a PDT and an FST.\n\n Usage: "; + usage += argv[0]; + usage += " in.pdt [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] : ""; + + s::FstClass *ifst = s::FstClass::Read(in_name); + if (!ifst) return 1; + + if (FLAGS_pdt_parentheses.empty()) { + LOG(ERROR) << argv[0] << ": No PDT parenthesis label pairs provided"; + return 1; + } + + vector<pair<int64, int64> > parens; + fst::ReadLabelPairs(FLAGS_pdt_parentheses, &parens, false); + + s::WeightClass weight_threshold = FLAGS_weight.empty() ? + s::WeightClass::Zero() : + s::WeightClass(ifst->WeightType(), FLAGS_weight); + + s::VectorFstClass ofst(ifst->ArcType()); + s::PdtExpand(*ifst, parens, &ofst, s::PdtExpandOptions( + FLAGS_connect, FLAGS_keep_parentheses, weight_threshold)); + + ofst.Write(out_name); + + return 0; +} diff --git a/src/extensions/pdt/pdtinfo.cc b/src/extensions/pdt/pdtinfo.cc new file mode 100644 index 0000000..89227d3 --- /dev/null +++ b/src/extensions/pdt/pdtinfo.cc @@ -0,0 +1,59 @@ +// pdtinfo.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) +// +// \file +// Prints out various information about a PDT such as number of +// states, arcs and parentheses. +// + +#include <fst/extensions/pdt/pdtscript.h> +#include <fst/util.h> + +DEFINE_string(pdt_parentheses, "", "PDT parenthesis label pairs."); + +int main(int argc, char **argv) { + namespace s = fst::script; + + string usage = "Prints out information about a PDT.\n\n Usage: "; + usage += argv[0]; + usage += " in.pdt\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] : ""; + + s::FstClass *ifst = s::FstClass::Read(in_name); + if (!ifst) return 1; + + if (FLAGS_pdt_parentheses.empty()) { + LOG(ERROR) << argv[0] << ": No PDT parenthesis label pairs provided"; + return 1; + } + + vector<pair<int64, int64> > parens; + fst::ReadLabelPairs(FLAGS_pdt_parentheses, &parens, false); + + s::PrintPdtInfo(*ifst, parens); + + return 0; +} diff --git a/src/extensions/pdt/pdtreplace.cc b/src/extensions/pdt/pdtreplace.cc new file mode 100644 index 0000000..543b6ea --- /dev/null +++ b/src/extensions/pdt/pdtreplace.cc @@ -0,0 +1,73 @@ +// pdtreplace.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) +// + +#include <utility> +using std::pair; using std::make_pair; +#include <vector> +using std::vector; +#include <fst/extensions/pdt/pdtscript.h> +#include <fst/vector-fst.h> +#include <fst/util.h> + +DEFINE_string(pdt_parentheses, "", "PDT parenthesis label pairs."); + +int main(int argc, char **argv) { + namespace s = fst::script; + + string usage = "Recursively replace Fst arcs with other Fst(s).\n"; + usage += " 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] : ""; + + s::FstClass *ifst = s::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)); + } + + s::VectorFstClass ofst(ifst->ArcType()); + vector<pair<int64, int64> > parens; + s::PdtReplace(fst_tuples, &ofst, &parens, root); + + if (!FLAGS_pdt_parentheses.empty()) + fst::WriteLabelPairs(FLAGS_pdt_parentheses, parens); + + ofst.Write(out_fname); + + return 0; +} diff --git a/src/extensions/pdt/pdtreverse.cc b/src/extensions/pdt/pdtreverse.cc new file mode 100644 index 0000000..e79cd7f --- /dev/null +++ b/src/extensions/pdt/pdtreverse.cc @@ -0,0 +1,61 @@ +// pdtreverse.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) +// +// \file +// Reverse a PDT. +// + +#include <fst/extensions/pdt/pdtscript.h> +#include <fst/util.h> + +DEFINE_string(pdt_parentheses, "", "PDT parenthesis label pairs."); + +int main(int argc, char **argv) { + namespace s = fst::script; + + string usage = "Reverse a PDT.\n\n Usage: "; + usage += argv[0]; + usage += " in.pdt [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] : ""; + + s::FstClass *ifst = s::FstClass::Read(in_name); + if (!ifst) return 1; + + if (FLAGS_pdt_parentheses.empty()) { + LOG(ERROR) << argv[0] << ": No PDT parenthesis label pairs provided"; + return 1; + } + + vector<pair<int64, int64> > parens, rparens; + fst::ReadLabelPairs(FLAGS_pdt_parentheses, &parens, false); + + s::VectorFstClass ofst(ifst->ArcType()); + s::PdtReverse(*ifst, parens, &ofst); + + ofst.Write(out_name); + + return 0; +} diff --git a/src/extensions/pdt/pdtscript.cc b/src/extensions/pdt/pdtscript.cc new file mode 100644 index 0000000..33e29ce --- /dev/null +++ b/src/extensions/pdt/pdtscript.cc @@ -0,0 +1,115 @@ + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright 2005-2010 Google, Inc. +// Author: jpr@google.com (Jake Ratkiewicz) + +// Definitions of 'scriptable' versions of pdt operations, that is, +// those that can be called with FstClass-type arguments. + +// See comments in nlp/fst/script/script-impl.h for how the registration +// mechanism allows these to work with various arc types. + +#include <vector> +using std::vector; +#include <utility> +using std::pair; using std::make_pair; + + +#include <fst/extensions/pdt/compose.h> +#include <fst/extensions/pdt/expand.h> +#include <fst/extensions/pdt/pdtscript.h> +#include <fst/extensions/pdt/replace.h> +#include <fst/extensions/pdt/reverse.h> +#include <fst/extensions/pdt/shortest-path.h> +#include <fst/script/script-impl.h> + +namespace fst { +namespace script { + +void PdtCompose(const FstClass &ifst1, + const FstClass &ifst2, + const vector<pair<int64, int64> > &parens, + MutableFstClass *ofst, + const ComposeOptions &copts, + bool left_pdt) { + if (!ArcTypesMatch(ifst1, ifst2, "PdtCompose") || + !ArcTypesMatch(ifst1, *ofst, "PdtCompose")) return; + + PdtComposeArgs args(ifst1, ifst2, parens, ofst, copts, left_pdt); + + Apply<Operation<PdtComposeArgs> >("PdtCompose", ifst1.ArcType(), &args); +} + +void PdtExpand(const FstClass &ifst, + const vector<pair<int64, int64> > &parens, + MutableFstClass *ofst, const PdtExpandOptions &opts) { + PdtExpandArgs args(ifst, parens, ofst, opts); + + Apply<Operation<PdtExpandArgs> >("PdtExpand", ifst.ArcType(), &args); +} + +void PdtExpand(const FstClass &ifst, + const vector<pair<int64, int64> > &parens, + MutableFstClass *ofst, bool connect) { + PdtExpand(ifst, parens, ofst, PdtExpandOptions(connect)); +} + +void PdtReplace(const vector<pair<int64, const FstClass*> > &fst_tuples, + MutableFstClass *ofst, + vector<pair<int64, int64> > *parens, + const int64 &root) { + for (unsigned i = 0; i < fst_tuples.size() - 1; ++i) { + if (!ArcTypesMatch(*(fst_tuples[i].second), + *(fst_tuples[i+1].second), "PdtReplace")) return; + } + + if (!ArcTypesMatch((*fst_tuples[0].second), *ofst, "PdtReplace")) return; + + PdtReplaceArgs args(fst_tuples, ofst, parens, root); + + Apply<Operation<PdtReplaceArgs> >("PdtReplace", ofst->ArcType(), &args); +} + +void PdtReverse(const FstClass &ifst, + const vector<pair<int64, int64> > &parens, + MutableFstClass *ofst) { + PdtReverseArgs args(ifst, parens, ofst); + + Apply<Operation<PdtReverseArgs> >("PdtReverse", ifst.ArcType(), &args); +} + +void PdtShortestPath(const FstClass &ifst, + const vector<pair<int64, int64> > &parens, + MutableFstClass *ofst, + const PdtShortestPathOptions &opts) { + PdtShortestPathArgs args(ifst, parens, ofst, opts); + + Apply<Operation<PdtShortestPathArgs> >("PdtShortestPath", + ifst.ArcType(), &args); +} + +void PrintPdtInfo(const FstClass &ifst, + const vector<pair<int64, int64> > &parens) { + PrintPdtInfoArgs args(ifst, parens); + Apply<Operation<PrintPdtInfoArgs> >("PrintPdtInfo", ifst.ArcType(), &args); +} + +// Register operations for common arc types. + +REGISTER_FST_PDT_OPERATIONS(StdArc); +REGISTER_FST_PDT_OPERATIONS(LogArc); +REGISTER_FST_PDT_OPERATIONS(Log64Arc); + +} // namespace script +} // namespace fst diff --git a/src/extensions/pdt/pdtshortestpath.cc b/src/extensions/pdt/pdtshortestpath.cc new file mode 100644 index 0000000..ad67969 --- /dev/null +++ b/src/extensions/pdt/pdtshortestpath.cc @@ -0,0 +1,81 @@ +// pdtshortestpath.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 +// Return the shortest path in a PDT. +// + +#include <fst/extensions/pdt/pdtscript.h> +#include <fst/util.h> + + +DEFINE_bool(keep_parentheses, false, "Keep PDT parentheses in result."); +DEFINE_string(queue_type, "fifo", "Queue type: one of: " + "\"fifo\", \"lifo\", \"state\""); +DEFINE_bool(path_gc, true, "Garbage collect shortest path data"); +DEFINE_string(pdt_parentheses, "", "PDT parenthesis label pairs."); + +int main(int argc, char **argv) { + namespace s = fst::script; + + string usage = "Shortest path in a PDT.\n\n Usage: "; + usage += argv[0]; + usage += " in.pdt [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] : ""; + + s::FstClass *ifst = s::FstClass::Read(in_name); + if (!ifst) return 1; + + if (FLAGS_pdt_parentheses.empty()) { + LOG(ERROR) << argv[0] << ": No PDT parenthesis label pairs provided"; + return 1; + } + + vector<pair<int64, int64> > parens, rparens; + fst::ReadLabelPairs(FLAGS_pdt_parentheses, &parens, false); + + s::VectorFstClass ofst(ifst->ArcType()); + + fst::QueueType qt; + + if (FLAGS_queue_type == "fifo") { + qt = fst::FIFO_QUEUE; + } else if (FLAGS_queue_type == "lifo") { + qt = fst::LIFO_QUEUE; + } else if (FLAGS_queue_type == "state") { + qt = fst::STATE_ORDER_QUEUE; + } else { + LOG(ERROR) << "Unknown or unsupported queue type: " << FLAGS_queue_type; + return 1; + } + + s::PdtShortestPathOptions opts(qt, FLAGS_keep_parentheses, FLAGS_path_gc); + s::PdtShortestPath(*ifst, parens, &ofst, opts); + ofst.Write(out_name); + + return 0; +} |