hfst-optimized-lookup-python provides a native Python package for lookup (both as a utility and as an interface) and a C++ implementation of the same, usable from Python via SWIG. The C++ version is much faster, and is recommended for practical use.


You can either install the package or just run it in the directory it comes in. To install, use the standard setup.py. See

python setup.py --help
You probably just want (as root)
python setup.py install
You'll need Python's setuptools to be installed for this to work.

provides the utility, which you can run locally, or import
as long as the package path is visible.

To install the SWIG-bound C++ code, you'll need a C++ compiler and SWIG.

cd swig
swig -c++ -python hfst_lookup.i
python setup.py build_ext --inplace

should build the module in the local directory. You can run it there, or again install it with

python setup.py install


To run the lookup utility, run

hfst_lookup.py [name of transducer]

If you load hfst_lookup as a module, you can use the class OlTransducer from it to load and run transducers, like so:

my_transducer = Transducer(filename)
for result in my_transducer.analyse(string_to_analyse):
    print result

The results are (string, weight) pairs (Unicode strings and floating point numbers).

Topic revision: r6 - 2012-04-24 - SamHardwick
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 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