Difference: HfstOptimizedLookupPython (5 vs. 6)

Revision 62012-04-24 - SamHardwick

Line: 1 to 1
 
META TOPICPARENT name="HfstHome"

hfst-optimized-lookup-python

Changed:
<
<

Note

>
>
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.
 
Changed:
<
<
hfst-optimized-lookup-python is not current. The transducers shipped with hfst 2.0 work, but since then there have been bugfixes and changes to the binary transducer format not reflected in hfst-optimized-lookup-python. For support, please email hfst-bugs@helsinki.fi
>
>

Installation

 
Changed:
<
<

Purpose

>
>
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.

hfst_lookup/hfst_lookup.py
provides the utility, which you can run locally, or import
hfst_lookup
as long as the package path is visible.
 
Changed:
<
<
Load a transducer in the HFST optimized lookup format, take input one word at a time and output analyses.
>
>
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
.
 

Usage

Changed:
<
<
eg.
>
>
To run the lookup utility, run
 
Changed:
<
<
python HfstOptimizedLookup.py TRANSDUCER
>
>
hfst_lookup.py [name of transducer]
 
Changed:
<
<
Once the transducer is loaded, input is taken on stdin and output is given on stdout. Each input word should be separated by a newline. To input and output files, UNIX redirection is recommended, eg.
>
>
If you load hfst_lookup as a module, you can use the class OlTransducer from it to load and run transducers, like so:
 
Changed:
<
<
python HfstOptimizedLookup.py TRANSDUCER < INPUTFILE > OUTPUTFILE
>
>
my_transducer = Transducer(filename) for result in my_transducer.analyse(string_to_analyse): print result
 
Added:
>
>
The results are (string, weight) pairs (Unicode strings and floating point numbers).
 
META TOPICMOVED by="SamHardwick" date="1254820582" from="KitWiki.HfstRuntimePython" to="KitWiki.HfstOptimizedLookupPython"
 
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