- OpenFst Forum 2013 Archive
- Infinity weight in compiled fst
- Why do I get Infinity weight in final state?
- error in ubuntu 13.10
- fstequal command
- Visual Studio OpenFST 1.3.4
- Compiling errors on Mac Mavericks 10.9
- Availability of linear classifier/tagger FST extension
- How to compile on 64 bit machine
- kPosInfinity in old version of fst
- Probably, bug: arc-map.h, ArcMap(), case MAP_REQUIRE_SUPERFINAL
- Optimization issue: functions Times and Divide on logartithmic and tropical weights
- Which optimization is applied to OpenFst 1.3.3 ?
- Can I get OpenFst 1.3.3 Visual Studio Project
- Merging symbol tables
- I/O error for large FSTs
- Making an FST with C++: How to define strings as labels?
- GenericRegister::GetEntry : lookup failed in shared object
- how to use fstreplace tool
- Regex to FST
- Coordinate Descent Solution for Rational Kernels
- “FATAL: StringWeight::Plus: unequal arguments” when running fstdeterminize.
- Composition result too large: how to make smaller?
- Double delete bug in fst far reader
- Get the Arcs whose nextstate is equal to a given q
- Testing an FST for epsilon cycles
- Example of k-closed semiring that is non-idempotent
- Comments

The number of accessible and coaccessible states is not same.

arc type standard

input symbol table none

output symbol table none

# of states 425041220

# of arcs 1230392842

initial state 0

# of final states 0

# of input/output epsilons 425041217

# of input epsilons 425041217

# of output epsilons 425041217

# of accessible states 425041220

# of coaccessible states 0

# of connected states 0

# of connected components 1

# of strongly conn components 43672597

I find there are two end states in input fsm "infsm". It is unexpected. I will check the error firstly.

the openfst-1.3.4 compile error in ubuntu.How can I solve it?

1. sudo apt-get install gcc-4.4 g++-4.4

2. Temporarily link gcc to gcc-4.4 (and g++ ...) or replace all occurences of gcc and g++ in Makefiles to 4.4 version. Maybe it is not all necessary, but I did it and it worked.

My src/bin/Makefile.am only has one line with "LD" in it: LDADD = ../script/libfstscript.la ../lib/libfst.la -lm -ldl

putting the -lm & -ldl switches in the middle or end doesn't matter:

libtool: link: g++ -O2 -o .libs/fstarcsort fstarcsort.o -lm -ldl ../script/.libs/libfstscript.so ../lib/.libs/libfst.so ../script/.libs/libfstscript.so: undefined reference to `dlopen' ../script/.libs/libfstscript.so: undefined reference to `dlerror' collect2: error: ld returned 1 exit status

libtool: link: g++ -O2 -o .libs/fstarcsort fstarcsort.o ../script/.libs/libfstscript.so ../lib/.libs/libfst.so -lm -ldl ../script/.libs/libfstscript.so: undefined reference to `dlopen' ../script/.libs/libfstscript.so: undefined reference to `dlerror' collect2: error: ld returned 1 exit status

Has anyone else found a way to work through this using gcc/++ tools of v4.7 or later?

-LDADD = ../script/libfstscript.la ../lib/libfst.la -lm -ldl

+LDADD = ../script/libfstscript.la ../lib/libfst.la

+AM_LDFLAGS = -Wl,-no-as-needed -lm -ldl

Second, editing the relevant Makefile.ac files and making this change does in fact result in a successful compilation on modern Ubuntu/GCC combinations, but the resulting binaries ("fstinfo", etc.) still aren't being linked properly against libfst and libfstscript. So, the result of running "make install" is a bunch of broken binaries.

I've poked at it for a while and not had any luck fixing the problem; somebody with stronger automaker-fu than myself might have more luck.

First you have to modify the relevant Makefile.am files as described above by YendaTrmal (taking into account the typo I identified in my previous comment vis-a-vis double-dashed arguments).

Second, you need to re-generate all of the automake-related files. I did this by running "autoreconf --force --install", which might be more than was needed- see my earlier comments about my lack of automake-fu. *Before you can do this*, however, you'll need to modify configure.ac in the top-level distribution directory; the AM_INIT_AUTOMAKE directive has a flag that treats all warnings as errors, and the differences in the automake/autoconf versions causes several warnings that will prevent autoreconf from running correctly. The "solution" was to get rid of the "-Werror" flag in the AM_INIT_AUTOMAKE directive. None of the errors seemed particularly dire, but take that observation with a grain of salt (see earlier comments about my lack of automake-fu). Removing "-Werror" caused all the relevant Makefile.in files to be properly regenerated, with the corrected LDADD/AM_LDFLAGS variables.

Third, "./configure"/"make"/"make install" as normal.

That seems to do the trick- the resulting binaries are all properly linked now.

1. in "src/lib/Makefile.am", append: libfst_la_LIBADD = -ldl

2. in "configure.ac", replace: AM_INIT_AUTOMAKE([foreign nostdinc -Wall -Werror]) with: AM_INIT_AUTOMAKE([foreign nostdinc -Wall -Wno-extra-portability -Werror])"

3. autoreconf --force --install

then the usual ./configure && make && make install .

You can check it works by running "make check".

Thanks

https://code.google.com/p/openfstwin/downloads/list

but the latest version there is 1.3.1.

Any help would be appreciated.

Thanks,

Roland

$ ./configure --prefix=$OPENFST_HOME --enable-far --enable-pdt && make clean make && make install || { echo "Error building openfst."; exit 1; } .... In file included from fst.cc:21: In file included from ./../include/fst/fst.h:34: In file included from ./../include/fst/arc.h:28: In file included from ./../include/fst/expectation-weight.h:36: In file included from ./../include/fst/pair-weight.h:29: In file included from ./../include/fst/weight.h:82: ./../include/fst/util.h:24:10: fatal error: 'tr1/unordered_map' file not found #include <tr1/unordered_map> ^ 1 error generated. make[3]: *** [fst.lo] Error 1 make[2]: *** [all-recursive] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2 Error building openfst. $ g++ --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) Target: x86_64-apple-darwin13.0.2 Thread model: posix

My understanding is that tr1 isn't part of any standard, and Apple moved it to a place where autoconf isn't looking for it. You need to set CPPFLAGS to point to that header and LIBS to point to that shared library. See:

https://github.com/kylebgorman/homebrew/blob/master/Library/Formula/openfst.rb

I was hoping that we weren't the only ones using mavericks, but it looks like we are.

For those who run into this later, here is some bash which (so far) appears to work well on mavericks:

./configure --prefix=$OPENFST_HOME --enable-compact-fsts --enable-const-fsts --enable-far=yes --enable-lookahead-fsts --enable-pdt CXX="clang++ -std=c++11 -stdlib=libstdc++" && make clean make && make install || { echo "Error building openfst."; exit 1; }

Thanks!

Thanks a lot.

return LogLatticeWeight(fst::FloatLimits

But, openfst-1.3.3/src/include/fst/float-weight.h just defines PosInfinity (no 'k' prefix).

I tried a superficial fix: deleting the 'k' in srtk -- but that yields "no matching function for call to ‘srtk::LogLatticeWeight::LogLatticeWeight(const float (&)(), const float (&)())’".

I'm a Python guy not a C++ guy ... any suggestions? I assume there's a way to cast it to (float, float), or a wrapper of some sort.

Thanks.

fst::FloatLimits<float>::PosInfinity()

V640 The code's operational logic does not correspond with its formatting. The statement is indented to the right, but it is always executed. It is possible that curly brackets are missing. arc-map.h 178

if (final_arc.ilabel = 0 || final_arc.olabel = 0 || final_arc.weight = Weight::Zero()) fst->AddArc(s, A(final_arc.ilabel, final_arc.olabel, final_arc.weight, superfinal)); fst->SetFinal(s, Weight::Zero());

fst-AddArc is conditional (then-branch of the preceded if) fst-SetFinal is unconditional, though it is indented as if it is conditional too.

When I've eliminated these checks, the speed of my application has been increased for 5%.

OpenFst 1.3.3 is much faster than OpenFst 1.3.1. While fstdeterminize of 1.3.1 takes about 1 hour, that of 1.3.3 takes only less than 1 minute! How can 1.3.3 be this faster? Could anyone explain the reason?

Thanks.

I have to build OpenFst in Windows. In the download page, Visual Studio project is just for 1.1 and 1.3.1. It seems that latest version 1.3.3 is much faster than 1.3.1 so I need 1.3.3 to be built in Windows.

Is there anyone who has 1.3.3 for windows ?

The memory map FSTs compile but aren't tested. The ngram FSTs aren't finished that why I never uploaded to the contrib section. Also includes VS2012 solutions.

I am a newbie to openfst, so this can sound stupid.

Is there a function which can merge two SymbolTables? I was using A->AddTable(SymbolTable* B) , where I want to merge B in A. function to merge two symbol tables. But I believe AddTable function just appends table B with A and starts indexing with the maximum key. ( I don't know if I am correct).

A

B

C - Resulting Table

My code needs to do this operation several times, so I thought I better ask first.

Thanks!

```
A
``` 0
a 1
b 2
c 3
B
0
d 1
a 2
b 3

```
C
```

Is there a function which can merge two SymbolTables?

I was using ` A->AddTable(SymbolTable* B) `

, where I want to merge B in A.

But I believe AddTable function just appends table B with A and starts indexing with the maximum key. ( I don't know if I am correct).

A

eps 0

a 1

b 2

c 3

B

eps 0

d 1

a 2

b 3

C - Resulting Table

eps 0

a 1

b 2

c 3

d 4

My code needs to do this operation several times, so I thought I better ask first.

Thanks!

SymbolTable * syms = new SymbolTable; syms->AddSymbol("<eps>"); syms->AddSymbol("a"); StdVectorFst res; for (int s = 0; s < big_number; s++) { res.AddState(); TropicalWeight final = -log(0.5); res.SetFinal(s, final); for (int dest = 0; dest < big_number; dest++) { res.AddArc(s, StdArc(1, 1, TropicalWeight(-log(0.2)), dest)); } } res.SetStart(0); res.SetInputSymbols(syms); res.SetOutputSymbols(syms); res.Write("badfile.fst"); StdVectorFst* loaded = StdVectorFst::Read("badfile.fst"); return 0;

For me, the big number seems to be too big at around 923. The printed error message is:

ERROR: VectorFst::Read: read failed: badfile.fst

Any insight into what's going on and how to get around this issue would be appreciated. Thanks!

Would be glad if someone could point out that to me.

PS Is it even effective to make it all in the C++-editor (I am using Eclipse)?

SymbolTable* isyms; isyms = new SymbolTable("isyms.txt"); SymbolTable* osyms; osyms = new SymbolTable("osyms.txt"); isyms->AddSymbol("a"); isyms->AddSymbol("b"); isyms->AddSymbol("c"); osyms->AddSymbol("x"); osyms->AddSymbol("y"); osyms->AddSymbol("z"); fst.SetInputSymbols(isyms); fst.SetOutputSymbols(osyms); // Adds state 0 to the initially empty FST and make it the start state. fst.AddState(); // 1st state will be state 0 (returned by AddState) fst.SetStart(0); // arg is state ID // Adds two arcs exiting state 0. // Arc constructor args: ilabel, olabel, weight, dest state ID. fst.AddArc(0, StdArc(isyms->Find("a"), osyms->Find("x"), 0.5, 1)); // 1st arg is src state ID fst.AddArc(0, StdArc(isyms->Find("b"), osyms->Find("y"), 1.5, 1)); // Adds state 1 and its arc. fst.AddState(); fst.AddArc(1, StdArc(isyms->Find("c"), osyms->Find("z"), 2.5, 2)); // Adds state 2 and set its final weight. fst.AddState(); fst.SetFinal(2, 3.5); // 1st arg is state ID, 2nd arg weight fst.Write("example.fst");

AddSymbol returns the id if the key already exists. So you can remove all the AddSymbol lines (except for the epsilon) and do this instead

fst.AddArc(0, StdArc(isyms->AddSymbol("a"), osyms- >AddSymbol("x"), 0.5, 1));

From memory in this case I think you would need to add the Symbol tables after adding all the arcs. Internally I think it will make a copy when you use SetInputSymbols method so might also need to delete the SymbolTables also.

PS You now helped me the third time, first time as Edobashira on your old blog :). I was DreeDrunk at that time. Shall I mark my thread with something like a SOLVED-tag?

But I'm getting the runtime error:

ERROR: GenericRegister::GetEntry : lookup failed in shared object: expectation-arc.so FATAL: No operation found for "CompileFst" on arc type expectation

How can I fix this?

The register call in my code looks like this (my arc is called MDExpectationArc):

#include <fst/const-fst.h> #include <fst/edit-fst.h> #include <fst/vector-fst.h> #include <fst/script/register.h> #include <fst/script/fstscript.h> namespace fst { namespace script { REGISTER_FST(VectorFst, MDExpectationArc); REGISTER_FST(ConstFst, MDExpectationArc); REGISTER_FST(EditFst, MDExpectationArc); REGISTER_FST_CLASSES(MDExpectationArc); REGISTER_FST_OPERATIONS(MDExpectationArc); }}

Here is how I compile: /usr/bin/c++ -fPIC -O2 -shared -o expectation-arc.so expectation-arc-inline.cc.o /c01_data/mdreyer/software/openfst-1.3.3/lib/libfst.so

or this, gives the same error: /usr/bin/c++ -fPIC -O2 -shared -Wl,-soname,expectation-arc.so -o expectation-arc.so expectation-arc-inline.cc.o openfst-1.3.3/lib/libfst.so -ldl -Wl,-rpath,openfst-1.3.3/lib

It used to work for me with an old openfst version, but I'm getting this error now with openfst 1.3.3.

fstcompile --arc-type=expectation

where it loads the expectation-arc.so file that I created using the c++ commands above.

Thanks,

Huanliang Wang

Using OpenFst library we can create FST for a given regular expression. But is there any way I could develop a generic RegEx to FST converter that takes 'any' regular expression and build FST ?

http://stackoverflow.com/questions/11819185/steps-to-creating-an-nfa-from-a-regular-expression

When I ran fstdeterminize on this transducer, the command line tool exited with following error message: FATAL: StringWeight::Plus: unequal arguments (non-functional FST?) w1 = 1 w2 = 2

I will try to construct such transducer directly using C++ API. Mean while, I’d appreciate any suggestion.

Jia

I am trying to calculate a kernel of the form T∘T^-1 from a transducer T, but the calculation uses up a lot of memory and I have to stop it before it converges (I stopped at 25 GB of swap). What could I try to do in order to calculate the composition result? (My ultimate goal is to calculate a kernel between acceptors A and B through the A∘T∘T^-1∘B composition and getting the (log) total weight between the starting and final states. A difficulty is that A∘T can produce a huge number of paths, and I was hoping that calculating T∘T^-1 could help solve this difficulty.)

I tried to first optimize transducer T, but this failed (a first epsilon removal yields a fatal error about StringWeight::Plus being given unequal arguments, as does determinization).

Here are some characteristics of transducer T, if they matter:

- About 15 nodes and 200k arcs.

- Accommodates input strings of any size through the use of internal loops.

If necessary, I can remove all loops, or some loops (because I know in advance how big the input strings can be); this would multiply the number of nodes and arcs by maybe 100 or 600 (depending on which loops I remove). Could removing loops significantly with the "too much memory used for composition" problem?

I could also limit the number of arcs, but this would make the transducer less expressive, so I would like to avoid this. However, if this is the best way of speeding up the calculation of T∘T^-1 and limiting its memory requirement, I am ready to do that.

What would you suggest, so that T∘T^-1 can really be calculated?

I don't think epsilon removal uses the StringWeight are your weights in the log/tropical semiring? Another problem could be negative weighted epsilon cycles.

Transducer T can **produce** many epsilons (in about half of the 200k arcs) before reaching a final state (and T^-1 therefore can consume many epsilons). This produces a huge number of possible outputs, and I was hoping that OpenFST could somehow "magically" calculate T∘T^-1 despite this. This epsilon production cannot be removed, because it is one of the main purposes of transducer T to remove parts of the input strings.

The weights are in the log semiring. There are cycles that produce epsilon (in T), with a weight of LogWeight(0.69…) (corresponding to 0.5 in real space).

With these precisions, what do you think is the best way to speed up the composition? reducing the number of arcs (I can do this by reducing the number of recognized "letters")?

The problem is that transducer T can produce infinitely many consecutive epsilons (when it is not restricted by input A) and similarly transducer T^-1 can consume infinitely many consecutive epsilons (when it is not restricted by output B). Naturally, composition does not terminate. You will have to avoid "all" epsilon loops on the output side of T if you want to compute ToT^-1, i.e. limiting the number of output-epsilon arcs won't help. Unfortunately there is no such magic hidden in openfst

Cheers, Dogan

It looks like my initial assessment was incorrect. I thought composition would somehow force enumeration of all possible matches between the epsilon cycles on the output side of T and the epsilon cycles on the input of T^-1. Instead, what happens is composition simply creates paths which first generate possibly infinitely many epsilons and then consume possibly infinitely many epsilons. The composition output for the small transducer is correct as far as I can tell.

I think the blow-up in composition is caused by the self-loops on states A_CAT_V_KEPT and B_CAT_V_KEPT. More explicitly, since T maps each input symbol on these arcs to "Wild" and T^-1 maps "Wild" back to these symbols, composition output has a mapping between each input symbol pair. If the big transducer is following the same pattern, there will be around 10K x 10K = 100M self loops in the output of composition for each of these two states.

Cheers, Dogan

Thank you for following up! Your remarks are very useful. The structure of the input data is such that the Wild labels can be specialized, so that the number of possible matches is reduced (PCP_123:Wild is now PCP_123:PCP_Wild, etc., so that only similar categories match through Wild). The result is that calculating kernel elements is much faster, thank you!

Maybe will the calculation of T∘T^-1 require less memory, too…

Best, EOL

I came across a double delete bug in the implementation of `FstFarReader`

class. `ReadFst`

method deletes the current fst before reading a new one, however if there is no more fst to read then the current fst pointer is left dangling. That leads to a segfault when the class destructor is called. You might trigger the error with

farequal fst1 fst2

I fixed the problem by moving the pointer deletion after the check for whether there is more fst to read.

This error is not triggered by other far utilities reading from an fst archive (`farprintstrings`

, `farinfo`

and `farextract`

) since these tools, unlike `farequal`

, do not delete the far reader pointer after they are done with it. It might be a good idea to fix that as well.

Cheers, Dogan

`Fst`

class similar to `VectorFst`

which has this functionality. You will first need to modify the definition of `VectorState`

and add a new vector of arcs for incoming arcs. Then you will need to modify the methods that has to do with arcs such as `AddArc`

, `RemoveArcs`

, `DeleteArcs`

, etc. to handle the incoming arcs as well as outgoing arcs. Finally you will need to define a new arc iterator for visiting incoming arcs.
Cheers, Dogan

bool isInputEpsilonCycleFree(StdVectorFst * fstp) { set<StateId> stateSet ; // reuse this set of "visited states" // if the machine has no cycles at all, then it's epsilon-cycle-free if (fstp->Properties(kAcyclic, true)) return true ; // loop through the states, looking for input epsilon cycles for (StateIterator<StdVectorFst> siter(*fstp) ; !siter.Done() ; siter.Next()) { stateSet.clear() ; if (findInputEpsilonCycle(fstp, siter.Value(), stateSet)) return false ; } // no input epsilon cycles found return true ; } bool findInputEpsilonCycle(StdVectorFst *fstp, StateId s, set<StateId> &stateSet) { // try to find an input epsilon cycle from state s back // to itself, or any other input epsilon cycle found during the search // stateSet is the set of states previously visited during the search from s if (stateSet.find(s) != stateSet.end()) // found a loop return true ; // remember state s as "visited" stateSet.insert(s) ; for (ArcIterator<StdVectorFst> aiter(*fstp, s) ; !aiter.Done() ; aiter.Next()) { StdArc arc = aiter.Value() ; // deal only with arcs with epsilon on the input side if (arc.ilabel != 0) // 0 (zero) is wired in as epsilon in OpenFst continue ; // here the ilabel is 0 (epsilon) // recursively look for an input epsilon loop from arc.nextstate if (findInputEpsilonCycle(fstp, arc.nextstate, stateSet)) return true ; } return false ; }

Using the OpenFst visitor to find a topological order on the epsilon input subgraph should work.

template<class Arc> bool HasInputEpsilonCycle(const Fst<Arc>& fst) { vector<typename Arc::StateId> order; bool acyclic = false; TopOrderVisitor<Arc> top_order_visitor(&order, &acyclic); DfsVisit(fst, &top_order_visitor, InputEpsilonArcFilter<Arc>()); return !acyclic; }

could you give an example k-close semiring that is not idempotent.

Thanks!

Edit | Attach | ~~Watch~~ | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions

Topic revision: r1 - 2018-05-30 - MichaelRiley

Copyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.

Ideas, requests, problems regarding TWiki? Send feedback

Ideas, requests, problems regarding TWiki? Send feedback