18 #include <boost/multiprecision/cpp_int.hpp> 24 std::vector<IntegerT> counts;
25 IntegerT cumcounts = 0;
26 counts.assign (myfst.NumStates(), 0);
28 typedef typename Arc::StateId StateId;
29 for (fst::StateIterator< fst::VectorFst<Arc> > si (myfst);
32 typename Arc::StateId state_id = si.Value();
33 if (myfst.Final (state_id) != Arc::Weight::Zero() ) {
34 cumcounts += counts[state_id];
36 for (fst::MutableArcIterator< fst::MutableFst<Arc> > ai (&myfst, si.Value() );
40 counts[arc.nextstate] += counts[state_id];
57 fst::VectorFst<Arc> *mfst = fst::VectorFstRead<Arc> (pi (
60 LERROR(
"Could not read file:" << ir->get());
64 boost::multiprecision::uint128_t j =
65 countstrings<Arc, boost::multiprecision::uint128_t> (*mfst);
69 o << ss.str() << std::endl;
70 LINFO ( pi (ir->get() ) <<
":" << ss.str() ) ;
77 int main (
int argc,
const char* argv[] ) {
81 FORCELINFO ( rg.
dump (
"CONFIG parameters:\n=====================",
82 "=====================" ) ) ;
86 run<fst::StdArc> (rg);
88 run<fst::LexStdArc> (rg);
92 LERROR (
"Sorry, semiring option not correctly defined");
Wrapper stream class that writes to pipes, text files or gzipped files.
std::string const kHifstSemiring
void run(ucam::util::RegistryPO const &rg)
class that expands a wildcard into its actual value. This is useful e.g. for filenames ranging severa...
T get(const std::string &key) const
Returns parsed value associated to key.
void initLogger(int argc, const char *argv[])
Inits logger, parses param options checking for –logger.verbose.
IntegerT countstrings(fst::VectorFst< Arc > &myfst)
boost::scoped_ptr< NumberRangeInterface< unsigned > > IntRangePtr
std::string const kOutput
std::string const kHifstSemiringLexStdArc
std::string const kHifstSemiringStdArc
Static variables for logger. Include only once from main file.
std::string const kHifstSemiringTupleArc
std::string dump(const std::string &decorator_start="", const std::string &decorator_end="")
Dumps all configuration parameters into a string with a reasonably pretty format. ...
Included headers for all the binary should be defined here. This file should be included only once...
int main(int argc, const char *argv[])
const std::string kRangeOne
Static variable for custom_assert. Include only once from main file.
void close()
Closes the file.