Commit 21555b2a authored by Giulio Paci's avatar Giulio Paci

Imported Upstream version 1.2

parent 18a44841
......@@ -6,8 +6,11 @@ Michael Riley <riley@google.com>
Contributors:
Boulos Harb <harb@google.com>
Dan Bikel <dbikel@google.com
Jacob Ratkiewicz <jpr@cs.indiana.edu>
Johan Schalkwyk <johans@google.com>
Masha Shugrina <shumash@google.com>
Mehryar Mohri <mohri@cs.nyu.edu>
Richard Sproat <rws@uiuc.edu>
Richard Sproat <rws@cslu.ogi.edu>
Terry Tai <ttai@google.com>
Wojtek Skut <wojciech@google.com>
......@@ -9,3 +9,5 @@ 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.
SUBDIRS = src
ACLOCAL_AMFLAGS = -I m4
......@@ -39,7 +39,8 @@ DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
INSTALL NEWS config.guess config.sub depcomp install-sh \
ltmain.sh missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_icu.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
......@@ -101,6 +102,11 @@ EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
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@
......@@ -164,6 +170,7 @@ infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
libfstdir = @libfstdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
......@@ -181,6 +188,7 @@ target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = src
ACLOCAL_AMFLAGS = -I m4
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
......
OpenFst - Release 1.2
* Added lookahead matching and filtering for faster composition
* Added EditFst for mutation of o.w. immutable FSTs
* Added script sub-namespace defining type FstClass - a non-templated Fst<Arc>
to hold the arc template type internally. This and FST operations on
it allow easier I/O and scripting at the cost of some runtime
dispatching.
* Added per-arc-iterator control of Fst caching.
* Added PowerWeight and Power Arc.
* Added fstsymbols shell-level command
* Added total weight removal option to pushing
* Changed methods for symbol table mutation
* Numerous efficiency improvements esp in composition, replace, and caching
* Fixed numerous bugs including:
- improper types of some approximation deltas
- sub-optimal hashing functions
- issues in internal reuse of shortest distance
- hashing bug in FloatWeight
- bug in shortest path queue
- symbol table checksumming issues
- various C++ standards issues
- Visit() behavior when visitation aborted
* Added extensions directories including:
- finite-state archive (FAR) utilities
- compact fsts
- lookahead fsts
- pushdown transducers
OpenFst - Release 1.1
* Added compat.h to src/include/fst to fix missing defines
......
OpenFst - Release 1.1
OpenFst - Release 1.2
OpenFst is a library for constructing, combining, optimizing, and
searching weighted finite-state transducers (FSTs).
......@@ -12,6 +12,14 @@ REQUIREMENTS:
INSTALLATION:
Follow the generic GNU build system instructions in ./INSTALL.
Optional features:
--enable-compact-fsts Enable all CompactFst classes as shared objects
--enable-const-fsts Enable all ConstFst classes as shared objects
--enable-far Enable FAR (FST Archive) extension
--enable-lookahead-fsts Enable LookAheadFST classes as shared objects
--enable-pdt Experimental push-down transducer extensions
--with-icu Use ICU to provide unicode support
(Compiling with '-Wall -Wno-sign-compare' under g++ should give no
warnings from this library).
......@@ -22,7 +30,8 @@ USAGE:
Link against /usr/local/lib/libfst.so and -ldl. Set your
LD_LIBRARY_PATH (or equivalent) to contain /usr/local/lib. The
linking is, by default, dynamic so that the Fst and Arc type DSO
extensions can be used correctly if desired.
extensions can be used correctly if desired. Any extensions will
be found under /usr/local/include/fst/extensions and /usr/local/lib/fst.
DOCUMENTATION:
See www.openfst.org for general documentation.
......
......@@ -7518,3 +7518,4 @@ AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR
m4_include([m4/ax_check_icu.m4])
......@@ -3,6 +3,9 @@
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the ICU library. */
#undef HAVE_ICU
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
......
This diff is collapsed.
AC_INIT([OpenFst], [1.1], [help@www.openfst.org])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_INIT([OpenFst], [1.2], [help@www.openfst.org])
AM_INIT_AUTOMAKE([foreign nostdinc -Wall -Werror])
AC_PROG_CXX
AC_PROG_LIBTOOL
AC_CONFIG_HEADERS([config.h src/include/fst/config.h])
AC_CONFIG_SRCDIR([src/lib/fst.cc])
AC_CONFIG_FILES([
......@@ -11,10 +13,70 @@ AC_CONFIG_FILES([
src/lib/Makefile
src/bin/Makefile
src/test/Makefile
src/extensions/Makefile
src/extensions/compact/Makefile
src/extensions/const/Makefile
src/extensions/far/Makefile
src/extensions/lookahead/Makefile
src/extensions/pdt/Makefile
src/script/Makefile
])
AC_CONFIG_MACRO_DIR([m4])
AC_LANG([C++])
AC_CHECK_TYPES([std::tr1::hash<long long unsigned>], [], [],
AC_CHECK_TYPES([std::tr1::hash<long long unsigned>], [], [],
[[#include <tr1/unordered_map>]])
AC_CHECK_TYPES([__gnu_cxx::slist<int>], [], [],
AC_CHECK_TYPES([__gnu_cxx::slist<int>], [], [],
[[#include <ext/slist>]])
AC_ARG_ENABLE(
[compact-fsts],
[AS_HELP_STRING(
[--enable-compact-fsts],
[enable all CompactFst extensions])],
[],
[enable_compact_fsts=no])
AM_CONDITIONAL([HAVE_COMPACT], [test "x$enable_compact_fsts" != xno])
AC_ARG_ENABLE(
[const-fsts],
[AS_HELP_STRING(
[--enable-const-fsts],
[enable all ConstFst extensions])],
[],
[enable_const_fsts=no])
AM_CONDITIONAL([HAVE_CONST], [test "x$enable_const_fsts" != xno])
AC_ARG_ENABLE([far], [AS_HELP_STRING([--enable-far], [enable FAR extensions])],
[], [enable_far=no])
AM_CONDITIONAL([HAVE_FAR], [test "x$enable_far" != xno])
AC_ARG_ENABLE(
[lookahead-fsts],
[AS_HELP_STRING(
[--enable-lookahead-fsts],
[enable LookAheadFst extensions])],
[],
[enable_lookahead_fsts=no])
AM_CONDITIONAL([HAVE_LOOKAHEAD], [test "x$enable_lookahead_fsts" != xno])
AC_ARG_ENABLE([pdt], [AS_HELP_STRING([--enable-pdt], [enable PDT extensions])],
[], [enable_pdt=no])
AM_CONDITIONAL([HAVE_PDT], [test "x$enable_pdt" != xno])
AC_ARG_WITH([icu],
[AS_HELP_STRING([--with-icu],
[enable UTF8 support using the ICU Library])],
[],
[with_icu=no])
AS_IF([test "x$with_icu" != xno],
[AC_CHECK_ICU(
[4.2],
[AC_DEFINE([HAVE_ICU],
[1],
[Define to 1 if you have the ICU library.])],
[AC_MSG_FAILURE([--with-icu was given, but ICU Library not found])])])
AC_SUBST([libfstdir], [${libdir}/fst])
AC_OUTPUT
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_icu.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_ICU(version, action-if, action-if-not)
#
# DESCRIPTION
#
# Defines ICU_LIBS, ICU_CFLAGS, ICU_CXXFLAGS. See icu-config(1) man page.
#
# LICENSE
#
# Copyright (c) 2008 Akos Maroy <darkeye@tyrell.hu>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 6
AU_ALIAS([AC_CHECK_ICU], [AX_CHECK_ICU])
AC_DEFUN([AX_CHECK_ICU], [
succeeded=no
if test -z "$ICU_CONFIG"; then
AC_PATH_PROG(ICU_CONFIG, icu-config, no)
fi
if test "$ICU_CONFIG" = "no" ; then
echo "*** The icu-config script could not be found. Make sure it is"
echo "*** in your path, and that taglib is properly installed."
echo "*** Or see http://ibm.com/software/globalization/icu/"
else
ICU_VERSION=`$ICU_CONFIG --version`
AC_MSG_CHECKING(for ICU >= $1)
VERSION_CHECK=`expr $ICU_VERSION \>\= $1`
if test "$VERSION_CHECK" = "1" ; then
AC_MSG_RESULT(yes)
succeeded=yes
AC_MSG_CHECKING(ICU_CPPFLAGS)
ICU_CPPFLAGS=`$ICU_CONFIG --cppflags`
AC_MSG_RESULT($ICU_CPPFLAGS)
AC_MSG_CHECKING(ICU_CFLAGS)
ICU_CFLAGS=`$ICU_CONFIG --cflags`
AC_MSG_RESULT($ICU_CFLAGS)
AC_MSG_CHECKING(ICU_CXXFLAGS)
ICU_CXXFLAGS=`$ICU_CONFIG --cxxflags`
AC_MSG_RESULT($ICU_CXXFLAGS)
AC_MSG_CHECKING(ICU_LIBS)
ICU_LIBS=`$ICU_CONFIG --ldflags`
AC_MSG_RESULT($ICU_LIBS)
else
ICU_CPPFLAGS=""
ICU_CFLAGS=""
ICU_CXXFLAGS=""
ICU_LIBS=""
## If we have a custom action on failure, don't print errors, but
## do set a variable so people can do so.
ifelse([$3], ,echo "can't find ICU >= $1",)
fi
AC_SUBST(ICU_CPPFLAGS)
AC_SUBST(ICU_CFLAGS)
AC_SUBST(ICU_CXXFLAGS)
AC_SUBST(ICU_LIBS)
fi
if test $succeeded = yes; then
ifelse([$2], , :, [$2])
else
ifelse([$3], , AC_MSG_ERROR([Library requirements (ICU) not met.]), [$3])
fi
])
SUBDIRS = include lib bin test
SUBDIRS = include lib script bin test extensions
......@@ -34,7 +34,8 @@ host_triplet = @host@
subdir = src
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_icu.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
......@@ -85,6 +86,11 @@ EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
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@
......@@ -148,6 +154,7 @@ infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
libfstdir = @libfstdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
......@@ -164,7 +171,7 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = include lib bin test
SUBDIRS = include lib script bin test extensions
all: all-recursive
.SUFFIXES:
......
AM_CPPFLAGS = -I$(srcdir)/../include
AM_CPPFLAGS = -I$(srcdir)/../include -I$(srcdir)/../script $(ICU_FLAGS)
AM_LDFLAGS = -lm -ldl
lib_LTLIBRARIES = libfstmain.la
libfstmain_la_SOURCES = main.cc
libfstmain_la_LDFLAGS = -version-info 0:0:0
bin_PROGRAMS = fstarcsort fstclosure fstcompile fstcompose fstconcat \
fstconnect fstconvert fstdeterminize fstdifference fstdraw fstencode \
fstepsnormalize fstequal fstequivalent fstinfo fstintersect fstinvert \
......@@ -12,104 +8,104 @@ fstmap fstminimize fstprint fstproject fstprune fstpush fstrandgen \
fstrelabel fstreplace fstreverse fstreweight fstrmepsilon \
fstshortestdistance fstshortestpath fstsynchronize fsttopsort fstunion
fstarcsort_SOURCES = fstarcsort.cc arcsort-main.h
fstarcsort_LDADD = ../lib/libfst.la libfstmain.la
fstarcsort_SOURCES = fstarcsort.cc
fstarcsort_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstclosure_SOURCES = fstclosure.cc closure-main.h
fstclosure_LDADD = ../lib/libfst.la libfstmain.la
fstclosure_SOURCES = fstclosure.cc
fstclosure_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstcompile_SOURCES = fstcompile.cc compile-main.h
fstcompile_LDADD = ../lib/libfst.la libfstmain.la
fstcompile_SOURCES = fstcompile.cc
fstcompile_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstcompose_SOURCES = fstcompose.cc compose-main.h
fstcompose_LDADD = ../lib/libfst.la libfstmain.la
fstcompose_SOURCES = fstcompose.cc
fstcompose_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstconcat_SOURCES = fstconcat.cc concat-main.h
fstconcat_LDADD = ../lib/libfst.la libfstmain.la
fstconcat_SOURCES = fstconcat.cc
fstconcat_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstconnect_SOURCES = fstconnect.cc connect-main.h
fstconnect_LDADD = ../lib/libfst.la libfstmain.la
fstconnect_SOURCES = fstconnect.cc
fstconnect_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstconvert_SOURCES = fstconvert.cc convert-main.h
fstconvert_LDADD = ../lib/libfst.la libfstmain.la
fstconvert_SOURCES = fstconvert.cc
fstconvert_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstdeterminize_SOURCES = fstdeterminize.cc determinize-main.h
fstdeterminize_LDADD = ../lib/libfst.la libfstmain.la
fstdeterminize_SOURCES = fstdeterminize.cc
fstdeterminize_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstdifference_SOURCES = fstdifference.cc difference-main.h
fstdifference_LDADD = ../lib/libfst.la libfstmain.la
fstdifference_SOURCES = fstdifference.cc
fstdifference_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstdraw_SOURCES = fstdraw.cc draw-main.h
fstdraw_LDADD = ../lib/libfst.la libfstmain.la
fstdraw_SOURCES = fstdraw.cc
fstdraw_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstencode_SOURCES = fstencode.cc encode-main.h
fstencode_LDADD = ../lib/libfst.la libfstmain.la
fstencode_SOURCES = fstencode.cc
fstencode_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstepsnormalize_SOURCES = fstepsnormalize.cc epsnormalize-main.h
fstepsnormalize_LDADD = ../lib/libfst.la libfstmain.la
fstepsnormalize_SOURCES = fstepsnormalize.cc
fstepsnormalize_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstequal_SOURCES = fstequal.cc equal-main.h
fstequal_LDADD = ../lib/libfst.la libfstmain.la
fstequal_SOURCES = fstequal.cc
fstequal_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstequivalent_SOURCES = fstequivalent.cc equivalent-main.h
fstequivalent_LDADD = ../lib/libfst.la libfstmain.la
fstequivalent_SOURCES = fstequivalent.cc
fstequivalent_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstinfo_SOURCES = fstinfo.cc info-main.h
fstinfo_LDADD = ../lib/libfst.la libfstmain.la
fstinfo_SOURCES = fstinfo.cc
fstinfo_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstintersect_SOURCES = fstintersect.cc intersect-main.h
fstintersect_LDADD = ../lib/libfst.la libfstmain.la
fstintersect_SOURCES = fstintersect.cc
fstintersect_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstinvert_SOURCES = fstinvert.cc invert-main.h
fstinvert_LDADD = ../lib/libfst.la libfstmain.la
fstinvert_SOURCES = fstinvert.cc
fstinvert_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstmap_SOURCES = fstmap.cc map-main.h
fstmap_LDADD = ../lib/libfst.la libfstmain.la
fstmap_SOURCES = fstmap.cc
fstmap_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstminimize_SOURCES = fstminimize.cc minimize-main.h
fstminimize_LDADD = ../lib/libfst.la libfstmain.la
fstminimize_SOURCES = fstminimize.cc
fstminimize_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstprint_SOURCES = fstprint.cc print-main.h
fstprint_LDADD = ../lib/libfst.la libfstmain.la
fstprint_SOURCES = fstprint.cc
fstprint_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstproject_SOURCES = fstproject.cc project-main.h
fstproject_LDADD = ../lib/libfst.la libfstmain.la
fstproject_SOURCES = fstproject.cc
fstproject_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstprune_SOURCES = fstprune.cc prune-main.h
fstprune_LDADD = ../lib/libfst.la libfstmain.la
fstprune_SOURCES = fstprune.cc
fstprune_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstpush_SOURCES = fstpush.cc push-main.h
fstpush_LDADD = ../lib/libfst.la libfstmain.la
fstpush_SOURCES = fstpush.cc
fstpush_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstrandgen_SOURCES = fstrandgen.cc randgen-main.h
fstrandgen_LDADD = ../lib/libfst.la libfstmain.la
fstrandgen_SOURCES = fstrandgen.cc
fstrandgen_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstrelabel_SOURCES = fstrelabel.cc relabel-main.h
fstrelabel_LDADD = ../lib/libfst.la libfstmain.la
fstrelabel_SOURCES = fstrelabel.cc
fstrelabel_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstreplace_SOURCES = fstreplace.cc replace-main.h
fstreplace_LDADD = ../lib/libfst.la libfstmain.la
fstreplace_SOURCES = fstreplace.cc
fstreplace_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstreverse_SOURCES = fstreverse.cc reverse-main.h
fstreverse_LDADD = ../lib/libfst.la libfstmain.la
fstreverse_SOURCES = fstreverse.cc
fstreverse_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstreweight_SOURCES = fstreweight.cc reweight-main.h
fstreweight_LDADD = ../lib/libfst.la libfstmain.la
fstreweight_SOURCES = fstreweight.cc
fstreweight_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstrmepsilon_SOURCES = fstrmepsilon.cc rmepsilon-main.h
fstrmepsilon_LDADD = ../lib/libfst.la libfstmain.la
fstrmepsilon_SOURCES = fstrmepsilon.cc
fstrmepsilon_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstshortestdistance_SOURCES = fstshortestdistance.cc shortest-distance-main.h
fstshortestdistance_LDADD = ../lib/libfst.la libfstmain.la
fstshortestdistance_SOURCES = fstshortestdistance.cc
fstshortestdistance_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstshortestpath_SOURCES = fstshortestpath.cc shortest-path-main.h
fstshortestpath_LDADD = ../lib/libfst.la libfstmain.la
fstshortestpath_SOURCES = fstshortestpath.cc
fstshortestpath_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstsynchronize_SOURCES = fstsynchronize.cc synchronize-main.h
fstsynchronize_LDADD = ../lib/libfst.la libfstmain.la
fstsynchronize_SOURCES = fstsynchronize.cc
fstsynchronize_LDADD = ../lib/libfst.la ../script/libfstscript.la
fsttopsort_SOURCES = fsttopsort.cc topsort-main.h
fsttopsort_LDADD = ../lib/libfst.la libfstmain.la
fsttopsort_SOURCES = fsttopsort.cc
fsttopsort_LDADD = ../lib/libfst.la ../script/libfstscript.la
fstunion_SOURCES = fstunion.cc union-main.h
fstunion_LDADD = ../lib/libfst.la libfstmain.la
fstunion_SOURCES = fstunion.cc
fstunion_LDADD = ../lib/libfst.la ../script/libfstscript.la
This diff is collapsed.
// compose-main.h
// 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.
//
// Author: riley@google.com (Michael Riley)
//
// \file
// Composes two FSTs. Includes helper function for fstcompose.cc
// that templates the main on the arc type to support multiple and
// extensible arc types.
//
#ifndef FST_COMPOSE_MAIN_H__
#define FST_COMPOSE_MAIN_H__
#include <fst/compose.h>
#include <fst/main.h>
#include <fst/vector-fst.h>
DECLARE_bool(connect);
DECLARE_string(compose_filter);
namespace fst {
// Main function for fstcompose templated on the arc type.
// Call only with 'return CALL_FST_MAIN' in main().
template <class Arc>
int ComposeMain(int argc, char **argv, istream &strm,
const FstReadOptions &opts) {
Fst<Arc> *ifst1 = Fst<Arc>::Read(strm, opts);
if (!ifst1) return 1;
if ((opts.source == "standard input" && strcmp(argv[2], "-") == 0)
|| strcmp(argv[2], "") == 0) {
LOG(ERROR) << argv[0] << ": Can't open file: " << argv[2];
return 1;
}
Fst<Arc> *ifst2 = Fst<Arc>::Read(strcmp(argv[2], "-") != 0 ? argv[2] : "");
if (!ifst2) return 1;
VectorFst<Arc> ofst;
if (FLAGS_compose_filter == "sequence") {
ComposeFstOptions<Arc> copts;
copts.gc_limit = 0; // Cache only the last state for fastest copy.
ofst = ComposeFst<Arc>(*ifst1, *ifst2, copts);
} else if (FLAGS_compose_filter == "alt_sequence") {
ComposeFstOptions<Arc, Matcher<Fst<Arc> >,
AltSequenceComposeFilter<Arc> > copts;
copts.gc_limit = 0; // Cache only the last state for fastest copy.
ofst = ComposeFst<Arc>(*ifst1, *ifst2, copts);
} else if (FLAGS_compose_filter == "match") {
ComposeFstOptions<Arc, Matcher<Fst<Arc> >,
MatchComposeFilter<Arc> > copts;
copts.gc_limit = 0; // Cache only the last state for fastest copy.
ofst = ComposeFst<Arc>(*ifst1, *ifst2, copts);
} else {
LOG(ERROR) << argv[0] << ": Bad filter type \""
<< FLAGS_compose_filter << "\"";
}
if (FLAGS_connect)
Connect(&ofst);
ofst.Write(argc > 3 ? argv[3] : "");
return 0;
}
} // namespace fst
#endif // FST_COMPOSE_MAIN_H__
// determinize-main.h
// 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