Giter VIP home page Giter VIP logo

foma-py's Introduction

Foma PY

Downloads total Downloads monthly PyPi Package Version PyPi status Supported python versions Github issues MIT License

Python bindings for Foma

This is a foma interface implemented in Python. Requires libfoma installed.

Installation

From PyPI:

pip install foma

From source:

git clone https://github.com/GooDeeJaY/foma-py.git
cd foma-py
python -m pip install .

Basic usage

from foma import FST

fst = FST.load("path_to_model")

fst.apply_up("example")
fst.apply_down("example")

Other modules:

attapply

This is a stand-alone Python utility for reading AT&T files and applying transductions. Useful for minimizing dependencies. Also supports weighted transducers, in which case apply() returns output strings in least-cost order.

TODO: Add basic usage

phonrule

This is a simple helper tool for debugging foma-scripts that are sequences of phonological rules meant to apply in a certain order. It assumes a grammar is written as a sequence of define-statements and ordered rewrite-rules combined with a chain-statement (simulating composition of the rules). It then passes words from STDIN through the sequence of transducers and prints a decorated output to STDOUT where rules that fire are shown between brackets.

TODO: Add basic usage

foma2js

This is a port of foma/contrib/foma2js.perl to Python 3. Get the help using foma2js.py -h. Everything else like in the original program.

TODO: Add basic usage


Forked from mhulden/foma/python

foma-py's People

Contributors

goodeejay avatar

Stargazers

 avatar

Watchers

 avatar

foma-py's Issues

Undefined symbol: `add_defined_function`

Hi there!

I am working on a project that uses foma in Python, and saw you had created this library with the code from foma's own Github, and wanted to ask about an error I am encountering with both (considering the issues on the actual repo are rarely answered).

When using foma in my Python code, either after installing this package or using the file given in foma's repo, I find that I get:

  File "/root/reconstruct/reconstruct.py", line 2, in <module>
    from foma import FST
  File "/usr/local/lib/python3.9/dist-packages/foma/__init__.py", line 111, in <module>
    foma_add_defined_function = foma.add_defined_function
  File "/usr/lib/python3.9/ctypes/__init__.py", line 387, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python3.9/ctypes/__init__.py", line 392, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /lib/x86_64-linux-gnu/libfoma.so.0: undefined symbol: add_defined_function

I have installed libfoma0 and libfoma0-dev and I can see that the Python code is clearly finding the shared object, however when I run objdump -TC libfoma.so.0 | grep defined, it is clear that there is no add_defined_function exposed as a method:

0000000000006130 g    DF .text  00000000000000c8  Base        add_defined
00000000000141f0 g    DF .text  00000000000000d9  Base        load_defined
0000000000013dc0 g    DF .text  00000000000000b8  Base        save_defined
0000000000005eb0 g    DF .text  000000000000000f  Base        defined_networks_init
0000000000005ec0 g    DF .text  000000000000000f  Base        defined_functions_init

I have found that a solution to have this work is to just comment out lines 111 and 112, along with the function definef of your __init__.py / foma.py as I am not currently using this in my program. I was wondering whether you have gotten this to work without the error, and if so how? Is it possible I am somehow on a wrong version of libfoma? Thank you for any help!

Collaboration

@GooDeeJAY We might very well be like the only people using this package lol. I have a question for you. We have forked the mhulden foma project with its python binding file in there. However, you have control over the pip package. For us, the get_defined_function functionality doesn't work as it can't find the symbol in the foma library .so, but also we're looking to add functionality to this overtime. Not sure how best to maintain this. We were planning on making PRs into the main foma project, but we were under the false impression that Mans was maintaining the pip package. Just wondering what you're thinking as it may impact how we go forward.

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.