GithubHelp home page GithubHelp logo

pyfst's People

Contributors

vchahun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyfst's Issues

about the <epsilon> and fst.EPSILON

when I read a Language Model fst from a which generated by opengrm, I find that the symbol in the LM fst is not equal to the fst.EPSILON in pyfst , I don't know how to deal with the inconsistency, is there any idea?

Epsilon symbol: inconsistency?

It is sometimes useful to know if a given symbol is epsilon, in a symbol table (for instance in order to extract the full alphabet—without epsilon), in a high-level way: I was expecting the epsilon symbol to be fst.EPSILON, but this is not the case:

>>> import fst
>>> list(fst.SymbolTable().items())
[('\xce\xb5', 0)]
>>> fst.EPSILON
u'\u03b5'

Could both epsilons be unified?

PS: Since an empty SymbolTable gives value 0 to epsilon, epsilon can be excluded from the alphabet. But more consistency between symbols would be useful anyway, especially since manipulating symbol names is of a higher level than manipulating their numerical representation.

support for openFst new versions

Hi

I try to install OpenFst 1.6 and then install pyfst. but I get error while installing pyfst. However by reverting OpenFst to version 1.3, the problem was solved, but is there any plan to support most recently releases of OpenFst (1.6 at this time)?

regards

read/write from a file *object*?

Would it be possible to have fst.read()/write() read/write from/to a file object? this would be more flexible than reading through a file name only. An example application is to store and possibly compress the binary representation of a transducer completely in memory (for storage in the field of a database, etc.). With the current approach, all of this has to be done through disk read/writes, and this is not optimal.

If I understand correctly, this functionality is provided in the C++ source (http://www.openfst.org/doxygen/fst/html/classfst_1_1_fst.html#ad2c233e6e5047677dca3458f1b36c4f6).

pip install pyfst fails on python 3.7

OSX Mojave, python 3.7.1
did the following:

  • installed openfst 1.5.4
  • $ export CFLAGS="-std=c++11 -stdlib=libc++ -mmacosx-version-min=10.7" && export CPATH="/usr/local/include"
  • pip install pyfst

Had lots of compilation errors. Downgrading to python 3.6.4 solved the issue.

No suitable method found

Hi,

I am working on Ubuntu 14.04 and have a working version of openfst 1.3.4 installed. The one step installation process in the Readme doesn't seem to work for me.

LIBRARY_PATH=$FST/lib:$FST/lib/fst CPLUS_INCLUDE_PATH=$FST/include python setup.py build_ext --inplace

The paths are correct but I'm getting the following error from Cython "no suitable method found" on the call to libfst.Replace in the replace method. It seems that Cython can't match the provided argument types with the ones expected by libfst in any version of the overloaded function Replace.

Commenting out that function make the module build successfully. At this stage I don't really know what to do. The arg types seem sound and compliant with the doc of libfst and especially this function :

void fst::Replace   (   const std::vector< std::pair< typename Arc::Label, const Fst< Arc > * >> &      ifst_array,
        MutableFst< Arc > *     ofst,
        typename Arc::Label     root,
        bool    epsilon_on_replace   
    )   

Running

nm *.so -C | grep "Replace<"

in the fst lib directory tells me this among other things :

void fst::Replace<fst::ArcTpl<fst::LogWeightTpl<double> > >(std::vector<std::pair<fst::ArcTpl<fst::LogWeightTpl<double> >::Label, fst::Fst<fst::ArcTpl<fst::LogWeightTpl<double> > > const*>, std::allocator<std::pair<fst::ArcTpl<fst::LogWeightTpl<double> >::Label, fst::Fst<fst::ArcTpl<fst::LogWeightTpl<double> > > const*> > > const&, fst::MutableFst<fst::ArcTpl<fst::LogWeightTpl<double> > >*, fst::ArcTpl<fst::LogWeightTpl<double> >::Label, bool)

which leads me to think that the problem might be coming from the allocator because I have no clue what it could be otherwise. I've tried using doubles and floats instead of ints but that doesn't change anything to the problem.

Any help would be much appreciated !
Thanks

Doesn't install on OS X 10.9

While installing pyfst on osx 10.9 mavericks I get a lot of error like

/usr/local/include/fst/pair-weight.h:120:14: error: call to 'isspace' is ambiguous
        } while (isspace(c)); 

and i'm not able to install the package.

Bug: drawing arcs whose name ends in "\"

fst.draw() produces invalid DOT code for FSTs that contain arcs ending in "".

Minimal steps to reproduce:

import fst

t = fst.Transducer()
t.add_arc(0, 1, 'a', '\\')
t._repr_svg_()

gives:

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-85-3be3f1d897c8> in <module>()
----> 1 t._repr_svg_()

/opt/virtualenvs/711/local/lib/python2.7/site-packages/fst/_fst.so in fst._fst._Fst._repr_svg_ (fst/_fst.cpp:4600)()

Exception: Warning: <stdin>: syntax error in line 10 near ''

Specifically, it’s producing stuff like [label = "a:\\"], but in the DOT language specification, quotes are escaped with backslashes. So that second quote is escaped, and so the label is never closed.

I think this can be fixed by using HTML-like labels, e.g. [label = <a:\>], but I’m not 100% sure that won’t create other escaping issues. Looking into it…

Code lines are too long

You may want to consider limiting the lines in your code to 79 characters, as per PEP 8. This would make the code easier to read (in the numerous editors that are 80 character wide by default).

setup.py install fails on Mac OS X

python setup.py install fails on Mac OS X (with openfst installed through MacPort's, if this matters):

/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -pipe -O2 -fwrapv -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c fst/_fst.cpp -o build/temp.macosx-10.7-x86_64-2.7/fst/_fst.o -O2
clang: error: no such file or directory: 'fst/_fst.cpp'
clang: error: no input files

I does not look like _fst.cpp can be found anywhere on my Mac…

pip install pyfst does not work on Mavericks

When I tried to install a clean install of pyfst on my new 2013 Haswell Macbook Pro that came with Mavericks it would not install because it could not find tr1/unordered_map.

Looking at some similar problems I downloaded pyfst.0.2.3.tar gz and added the option '-stdlib=libstdc++' to setup.py, then ran python setup.py install. That seemed to work. But now when I open python (installed via Homebrew) I get the following error:

import fst
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/site-packages/fst/init.py", line 1, in
from fst._fst import EPSILON, EPSILON_ID, SymbolTable,
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/fst/_fst.so, 2): Symbol not found: __ZNSiD0Ev
Referenced from: /usr/local/lib/libfst.1.dylib
Expected in: flat namespace
in /usr/local/lib/libfst.1.dylib

`import fst` fails after `pip-3.2 install pyfst` with MacPorts

import fst after pip-3.2 install pyfst (through MacPorts on OS X) fails with:

Python 3.2.3 (default, Apr 19 2012, 17:51:27) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import fst
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/fst/__init__.py", line 1, in <module>
    from fst._fst import EPSILON, EPSILON_ID, SymbolTable,\
  File "_fst.pyx", line 1, in init fst._fst (fst/_fst.cpp:27271)
NameError: basestring

Many warnings are issued during the compilation, most of them being related to a comparison between signed and unsigned variables, if this can help.

pip install pyfst fails on OSX Yosemite

Strange that it can't seem to find the unordered_map header. Any suggestions?

gcc -fno-strict-aliasing -I//anaconda/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I//anaconda/include/python2.7 -c fst/_fst.cpp -o build/temp.macosx-10.5-x86_64-2.7/fst/_fst.o -O2
  In file included from fst/_fst.cpp:321:
  /Users/delip/prefix/include/fst/symbol-table.h:26:10: fatal error: 'unordered_map' file not found
  #include <unordered_map>
           ^
  1 error generated.
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for pyfst
Failed to build pyfst
Installing collected packages: pyfst
  Running setup.py install for pyfst
    Complete output from command //anaconda/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/qj/c2h005w56nlc2hpc5n1f8s5r0000gn/T/pip-build-UETMSM/pyfst/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/qj/c2h005w56nlc2hpc5n1f8s5r0000gn/T/pip-cq1YQe-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    running build_ext
    building 'fst._fst' extension
    gcc -fno-strict-aliasing -I//anaconda/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I//anaconda/include/python2.7 -c fst/_fst.cpp -o build/temp.macosx-10.5-x86_64-2.7/fst/_fst.o -O2
    In file included from fst/_fst.cpp:321:
    /Users/delip/prefix/include/fst/symbol-table.h:26:10: fatal error: 'unordered_map' file not found
    #include <unordered_map>
             ^
    1 error generated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "//anaconda/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/qj/c2h005w56nlc2hpc5n1f8s5r0000gn/T/pip-build-UETMSM/pyfst/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/qj/c2h005w56nlc2hpc5n1f8s5r0000gn/T/pip-cq1YQe-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/qj/c2h005w56nlc2hpc5n1f8s5r0000gn/T/pip-build-UETMSM/pyfst

Segmentation fault in copy constructor of StdTransducer

Although I cannot find it in the API description (http://pyfst.github.io/api.html) it looks like there exists a copy constructor for the StdTransducer and StdAcceptor classes. However, when I am trying to initialize a new object like that I get a segmentation fault.
Example:

>>> import fst
>>> x= fst.StdTransducer()
>>> x.add_arc(0,0,'1','0')
>>> x[0].final = True
>>> y = fst.StdTransducer(x)
Segmentation fault: 11

Is this a bug, or I am doing something unexpected for the library?

Thanks!

install failed on Ubuntu 16.04

I use pip install but report this error:

Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-v_r_ao6z/pyfst/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-39n6m0q_-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.5
    creating build/lib.linux-x86_64-3.5/fst
    copying fst/__init__.py -> build/lib.linux-x86_64-3.5/fst
    running build_ext
    building 'fst._fst' extension
    creating build/temp.linux-x86_64-3.5
    creating build/temp.linux-x86_64-3.5/fst
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c fst/_fst.cpp -o build/temp.linux-x86_64-3.5/fst/_fst.o -O2
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    fst/_fst.cpp:321:30: fatal error: fst/symbol-table.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

pip install fails on OS X with MacPorts

pip install pysft fails on OS X 10.7.5 with openfst 1.3.3_0 installed through MacPorts 2.3:

fst/_fst.cpp:264:10: fatal error: 'fst/symbol-table.h' file not found

This file is present, though: it is in /opt/local/include/fst/.

Would it be possible to include MacPort's include (and library?) path so that pip install works on OS X with a MacPort's installed openfst?

Shouldn't state.arcs return a *new* iterator?

Currently, the arcs of a state, state.arcs, return an iterator, but not a new one. As a consequence, different pieces of code might interfere if they do not take the precaution of resetting the iterator each time. For instance, getting the arcs of a linear chain must currently be done with

arcs = (next(iter(state.arcs)) for state in shortest_path)

where iter() reinitializes the iterator state.arcs. Wouldn't it be more natural to have state.arc return a new iterator each time?

installation fails on OS X 10.9

I installed Openfst 1.5.1 with --enable-python flag, and then was trying to install Pyfst.
I was first following these instructions: http://demo.clab.cs.cmu.edu/fa2014-11711/index.php/PyFST_Setup_Mac
Then, when it failed on the step "python setup.py install --prefix=$PREFIX" with "fatal error: 'unordered_map' file not found", I tried what was described in this comment.
And, still, the setup.py install fails:

dhcp-wlan-uzh-89-206-67-143:pyfst username$ sudo python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to pyfst.egg-info/requires.txt
writing pyfst.egg-info/PKG-INFO
writing top-level names to pyfst.egg-info/top_level.txt
writing dependency_links to pyfst.egg-info/dependency_links.txt
reading manifest file 'pyfst.egg-info/SOURCES.txt'
writing manifest file 'pyfst.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.5-x86_64/egg
running install_lib
running build_py
running build_ext
running pre_build_ext
Created template fst/_fst.pyx
Created template fst/libfst.pxd
cythoning fst/_fst.pyx to fst/_fst.cpp
building 'fst._fst' extension
gcc-4.9 -fno-strict-aliasing -I/Users/username/anaconda/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/include -I/Users/username/anaconda/include/python2.7 -c fst/_fst.cpp -o build/temp.macosx-10.5-x86_64-2.7/fst/_fst.o -std=c++11
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
g++-4.9 -bundle -undefined dynamic_lookup -L/Users/username/anaconda/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.5-x86_64-2.7/fst/_fst.o -L/opt/local/lib -L/Users/username/anaconda/lib -lfst -o build/lib.macosx-10.5-x86_64-2.7/fst/_fst.so -stdlib=libstdc++
g++-4.9: error: unrecognized command line option '-stdlib=libstdc++'
command 'g++-4.9' failed with exit status 1
error: command 'g++-4.9' failed with exit status 1

UPDATE
I tried to comment out the lines in setup.py which appended "-stdlib=libstdc++"

    # extra_compile_args.append('-stdlib=libstdc++')
    #extra_link_args.append('-stdlib=libstdc++')

After that, with the warning about '-Wstrict-prototypes' still remaining, it looked like the compilatio continued, but wasn't finished. First it yielded ld warning, and then failed to install PyYAML..

$ sudo python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to pyfst.egg-info/requires.txt
writing pyfst.egg-info/PKG-INFO
writing top-level names to pyfst.egg-info/top_level.txt
writing dependency_links to pyfst.egg-info/dependency_links.txt
reading manifest file 'pyfst.egg-info/SOURCES.txt'
writing manifest file 'pyfst.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.5-x86_64/egg
running install_lib
running build_py
running build_ext
running pre_build_ext
Created template fst/_fst.pyx
Created template fst/libfst.pxd
cythoning fst/_fst.pyx to fst/_fst.cpp
building 'fst._fst' extension
gcc-4.9 -fno-strict-aliasing -I/Users/username/anaconda/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/include -I/Users/username/anaconda/include/python2.7 -c fst/_fst.cpp -o build/temp.macosx-10.5-x86_64-2.7/fst/_fst.o -std=c++11
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
g++-4.9 -bundle -undefined dynamic_lookup -L/Users/username/anaconda/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.5-x86_64-2.7/fst/_fst.o -L/opt/local/lib -L/Users/username/anaconda/lib -lfst -o build/lib.macosx-10.5-x86_64-2.7/fst/_fst.so
ld: warning: could not create compact unwind for void std::__make_heap<__gnu_cxx::__normal_iterator<fst::GallicArc<fst::ArcTpl<fst::TropicalWeightTpl<float> >, (fst::GallicType)0>*, std::vector<fst::GallicArc<fst::ArcTpl<fst::TropicalWeightTpl<float> >, (fst::GallicType)0>, std::allocator<fst::GallicArc<fst::ArcTpl<fst::TropicalWeightTpl<float> >, (fst::GallicType)0> > > >, __gnu_cxx::__ops::_Iter_comp_iter<fst::ArcUniqueMapper<fst::GallicArc<fst::ArcTpl<fst::TropicalWeightTpl<float> >, (fst::GallicType)0> >::Compare> >(__gnu_cxx::__normal_iterator<fst::GallicArc<fst::ArcTpl<fst::TropicalWeightTpl<float> >, (fst::GallicType)0>*, std::vector<fst::GallicArc<fst::ArcTpl<fst::TropicalWeightTpl<float> >, (fst::GallicType)0>, std::allocator<fst::GallicArc<fst::ArcTpl<fst::TropicalWeightTpl<float> >, (fst::GallicType)0> > > >, __gnu_cxx::__normal_iterator<fst::GallicArc<fst::ArcTpl<fst::TropicalWeightTpl<float> >, (fst::GallicType)0>*, std::vector<fst::GallicArc<fst::ArcTpl<fst::TropicalWeightTpl<float> >, (fst::GallicType)0>, std::allocator<fst::GallicArc<fst::ArcTpl<fst::TropicalWeightTpl<float> >, (fst::GallicType)0> > > >, __gnu_cxx::__ops::_Iter_comp_iter<fst::ArcUniqueMapper<fst::GallicArc<fst::ArcTpl<fst::TropicalWeightTpl<float> >, (fst::GallicType)0> >::Compare>): dwarf uses DW_CFA_GNU_args_size

...

creating build/bdist.macosx-10.5-x86_64
creating build/bdist.macosx-10.5-x86_64/egg
creating build/bdist.macosx-10.5-x86_64/egg/fst
copying build/lib.macosx-10.5-x86_64-2.7/fst/__init__.py -> build/bdist.macosx-10.5-x86_64/egg/fst
copying build/lib.macosx-10.5-x86_64-2.7/fst/_fst.so -> build/bdist.macosx-10.5-x86_64/egg/fst
byte-compiling build/bdist.macosx-10.5-x86_64/egg/fst/__init__.py to __init__.pyc
creating stub loader for fst/_fst.so
byte-compiling build/bdist.macosx-10.5-x86_64/egg/fst/_fst.py to _fst.pyc
creating build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying pyfst.egg-info/PKG-INFO -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying pyfst.egg-info/SOURCES.txt -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying pyfst.egg-info/dependency_links.txt -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying pyfst.egg-info/requires.txt -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
copying pyfst.egg-info/top_level.txt -> build/bdist.macosx-10.5-x86_64/egg/EGG-INFO
writing build/bdist.macosx-10.5-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/pyfst-0.2.3dev-py2.7-macosx-10.5-x86_64.egg' and adding 'build/bdist.macosx-10.5-x86_64/egg' to it
removing 'build/bdist.macosx-10.5-x86_64/egg' (and everything under it)
Processing pyfst-0.2.3dev-py2.7-macosx-10.5-x86_64.egg
Copying pyfst-0.2.3dev-py2.7-macosx-10.5-x86_64.egg to /Users/username/anaconda/lib/python2.7/site-packages
Adding pyfst 0.2.3dev to easy-install.pth file

Installed /Users/username/anaconda/lib/python2.7/site-packages/pyfst-0.2.3dev-py2.7-macosx-10.5-x86_64.egg

...
And then there was a Cython-related compiler crash...

Compiler crash traceback from this point on:
  File "Visitor.py", line 170, in Cython.Compiler.Visitor.TreeVisitor._visit (Cython/Compiler/Visitor.c:4284)
  File "Visitor.py", line 286, in Cython.Compiler.Visitor.CythonTransform.visit_Node (Cython/Compiler/Visitor.c:6288)
  File "Visitor.py", line 238, in Cython.Compiler.Visitor.VisitorTransform.visitchildren (Cython/Compiler/Visitor.c:5294)
  File "Visitor.py", line 212, in Cython.Compiler.Visitor.TreeVisitor._visitchildren (Cython/Compiler/Visitor.c:5051)
AssertionError: Cannot insert list here: body in <Cython.Compiler.Nodes.PropertyNode object at 0x104588c90>
/tmp/easy_install-cvZXWf/Cython-0.24/Cython/Compiler/Scanning.c:1:2: error: #error Do not use this file, it is the result of a failed Cython compilation.
 #error Do not use this file, it is the result of a failed Cython compilation.
  ^
error: Setup script exited with error: command 'gcc-4.9' failed with exit status 1

union() does union of transducer *with itself*?

union() disregards the second transducer and instead seems to do the union of the first transducer with itself (instead of with the second transducer):

>>> import fst                                                                  
>>> t1 = fst.linear_chain('a')                                                  
>>> t2 = fst.linear_chain('B')                                                  
>>> t1.union(t2)

union

PS: I now realize that this may be "normal", as this may be explained by alphabets that are represented internally by identical numbers between the two transducers (with the symbols list of the first being used for the union). Thus, the union would be correct, but with the wrong labels. If this is the case, it would be nice if union() automatically created a new, unified symbol table before the merge; in fact, this would be the appropriate high-level operation (instead of union working "normally" but at a hidden low level representation).

PPS: What would be the correct way of calculating the union of the above two linear chain transducers with pyfst? Is the following correct?

symbols = fst.SymbolTable()
t1 = fst.linear_chain('a', syms=symbols)
t2 = fst.linear_chain('bac', syms=symbols)
t1.union(t2)

It would be nice ("higher-level") if the same effect were produced directly without creating a symbol dictionary first, as in the first code (maybe as an option of union(), where the correct merging would be enabled by default?).

"pip install pyfst" does not work under Cygwin

Hello, I have openfst and python working fine under Cygwin. But when I try "pip install pyfst", I get an error message as shown below.

Any guidance on how to fix this would be greatly appreciated.

Pierre Isabelle


g++ -shared -Wl,--enable-auto-image-base build/temp.cygwin-1.7.17-i686-2.6/fst/_fst.o -L/usr/lib/python2.6/config -lfst -lpython2.6 -o build/lib.cygwin-1.7.17-i686-2.6/fst/_fst.dll

/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld: cannot find -lfst

cannot install pyfst

Hi

I used pip to install pyfst and encountered by following error:

Collecting pyfst
Using cached pyfst-0.2.3.tar.gz
Building wheels for collected packages: pyfst
Running setup.py bdist_wheel for pyfst ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-N3M71s/pyfst/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d /tmp/tmpgPRLh4pip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/fst
copying fst/init.py -> build/lib.linux-x86_64-2.7/fst
running build_ext
building 'fst._fst' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/fst
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c fst/_fst.cpp -o build/temp.linux-x86_64-2.7/fst/_fst.o -O2
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
fst/_fst.cpp:321:30: fatal error: fst/symbol-table.h: No such file or directory
#include <fst/symbol-table.h>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Failed building wheel for pyfst
Running setup.py clean for pyfst
Failed to build pyfst
Installing collected packages: pyfst
Running setup.py install for pyfst ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-N3M71s/pyfst/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-XNPHYl-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/fst
copying fst/init.py -> build/lib.linux-x86_64-2.7/fst
running build_ext
building 'fst._fst' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/fst
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c fst/_fst.cpp -o build/temp.linux-x86_64-2.7/fst/_fst.o -O2
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
fst/_fst.cpp:321:30: fatal error: fst/symbol-table.h: No such file or directory
#include <fst/symbol-table.h>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Command "/usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-N3M71s/pyfst/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-XNPHYl-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-N3M71s/pyfst/

I also get git repository by git clone and still cannot install it from source:

running install
running build
running build_py
running build_ext
building 'fst._fst' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c fst/_fst.cpp -o build/temp.linux-x86_64-2.7/fst/_fst.o -O2
x86_64-linux-gnu-gcc: error: fst/_fst.cpp: No such file or directory
x86_64-linux-gnu-gcc: fatal error: no input files
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 4

any help is appreciated...

Strange Symbol Table

Hi,I installed pyfst use 'pip install pyfst --user' and my openfst version is 1.3.4
There is strange In this case :

import fst
symbolTable = fst.SymbolTable()
symbolTable[u''] = 0
symbolTable[u''] = 1
print [(a,b) for a,b in symbolTable.items()]

[(u'', 0), (u'', 0), (u'', 1)] ### there are two u''??

symbolTable.write('sym.table')
symbolTable1 = fst.read_symbols('sym.table')
print [(a,b) for a,b in symbolTable1.items()]

[(u'', 1), (u'\u03b5', 0), (u'\u03b5', 0)] ### u'' has been changed to u'\u03b5'??

PS:If I subtitued u'' with u'a' , the output is right.

cannot import fst module

Hello everybody !

I tried to install pyfst this morning...I got the following problem :
My test script fails at the very first "import" line...

import fst

Traceback (most recent call last):
File "testfst.py", line 1, in
import fst
File "/usr/local/lib/python2.6/dist-packages/fst/init.py", line 1, in
from fst._fst import EPSILON, EPSILON_ID, SymbolTable,
ImportError: libfst.so.0: cannot open shared object file: No such file or directory

Indeed, there is no libfst.so.0 on my disk....The installation of openfst library has populated /usr/local/lib with :

-rw-r--r-- 1 root staff 282595604 27 févr. 08:54 libfstscript.a
-rwxr-xr-x 1 root staff 6615292 27 févr. 09:05 libfst.so.1.0.0
lrwxrwxrwx 1 root staff 15 27 févr. 09:05 libfst.so.1 -> libfst.so.1.0.0
lrwxrwxrwx 1 root staff 15 27 févr. 09:05 libfst.so -> libfst.so.1.0.0
-rwxr-xr-x 1 root staff 109946159 27 févr. 09:05 libfstscript.so.1.0.0
lrwxrwxrwx 1 root staff 21 27 févr. 09:05 libfstscript.so.1 -> libfstscript.so.1.0.0
lrwxrwxrwx 1 root staff 21 27 févr. 09:05 libfstscript.so -> libfstscript.so.1.0.0
-rwxr-xr-x 1 root staff 960 27 févr. 09:05 libfstscript.la
-rwxr-xr-x 1 root staff 924 27 févr. 09:05 libfst.la

I tried "pip uninstall pyfst" and then "pip install pyfst" with the same result...

What am I doing wrong ?

Feature Request: Simpler interface for shortest_path

This may be mine own relative ignorance when it comes to OpenFST, but to me it would make things a lot more Pythonic if shortest_path return a list of paths (represented as lists of input/output tuples) instead of returning an FST.

For a project I'm working on I'd like to get the n-best paths through an FSA, and it's not immediately clear to me how I would go about building a list representation of all the paths easily given the current interface.

Any help you could offer would be greatly appreciated.

Can't install using pip

building 'fst._fst' extension

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c fst/_fst.cpp -o build/temp.linux-x86_64-2.7/fst/_fst.o -O2

cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]

c++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/fst/_fst.o -lz -lfst -o build/lib.linux-x86_64-2.7/fst/_fst.so

/usr/bin/ld: cannot find -lz

collect2: error: ld returned 1 exit status

error: command 'c++' failed with exit status 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.