mhulden / foma

Automatically exported from code.google.com/p/foma

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python bindings on mac - how to make work?

fractaldragonflies opened this issue · comments

Using foam on my Mac; installed foma 0.9.18alpha. Works fine from command line. I appreciate the product and the effort. Thanks!!!

But cannot figure how to use Python bindings. I've tried to use test_foma.py and more simply just the import of FST.

from foma import FST
Results in:
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(RTLD_DEFAULT, fsm_parse_regex): symbol not found

Readme says: Requires libfoma installed.
It resides in the same directory as the executables (foma, flookup, cgflookup).
But no Joy.

** What do I need to do to have foma with Python bindings installed and operational?? **

BTW, I found 'fst_lookup' available from PyPi as a pip install. It seems to work for simple stuff, but it fails on even slightly more complicated words. I am working with an agglutinative South American language (Yine) and the morphology is very complex. So I need a solution that will reproduce the same analyses up and down that I get from foma directly.

** So it remains an outstanding need with some urgency. I would appreciate the help. **

libfoma needs to be installed somewhere that Python can find it. I think in theory this should be resolvable by appropriately setting the PYTHONPATH environment variable to wherever libfoma is located.

In practice the way I've gotten this working in the past (both on macOS and on Linux) is to install foma and libfoma in a standard location like /usr/local

In case you're interested in other language bindings, I also have Swift language bindings that work:

See https://github.com/dowobeha/Foma for the code, and see https://github.com/dowobeha/yupik-parser for examples of how to use the bindings.

Note that the Swift bindings do not require foma or fomalib to be compiled or installed separately.

Thank you for the quick response! Your suggestion was enough to get me to try and resolve the problem. It wasn't quite as simple as installing in usr/local, but I did get it to work.

  1. Installed cgflookup, flookup, and foma in usr/local/bin. usr/local is not on the default path (anymore).
  2. Installed libfoma.dylib in usr/local/lib. Had to drop the .0.9.18 qualifier because it couldn't find the lib otherwise. I think a proper install would provide an alias to the fully qualified name. But that reaches my limit of competence!
  3. Errored importing (python) FST with "AttributeError: dlsym(0x7f908ac89a10, add_defined_function): symbol not found".
  4. Commented out the 2 lines referencing 'add_defined_function', with the hope that I don't need that feature!!!
  5. Had trouble loading the binary file of the FST, but that was my error which I resolved.

==

  • Also tried to Make the system from source, but ran into an error in the regex.y file. Didn't like the "%define api.pure full" line.
  • After a (plausible) fix, Make worked OK. i.e., without reported error.
  • BUT when trying to import the FST, received error that, while the lib was found, the mach-o architecture was incompatible.
  • Must be some other setting in the Make or other issue. [Running Mac air with the M1 chip, so like the build settings need to be reviewed and adjusted to work correctly.]

==
So now working. At least the load, apply_up and apply_down.

Thanks! I'm marking closed as my issue seems resolved. Opportunity for improved documentation or install, but maybe this suffices for now.

In case you're interested in other language bindings, I also have Swift language bindings that work:

See https://github.com/dowobeha/Foma for the code, and see https://github.com/dowobeha/yupik-parser for examples of how to use the bindings.

Note that the Swift bindings do not require foma or fomalib to be compiled or installed separately.

Thanks for the heads up. I'll check this out. Have worked with Swift, but never published any app.