jpuigcerver / openfst-python

Self-contained Python package for OpenFst
Apache License 2.0
50 stars 12 forks source link

Example run error #2

Open adamwawrzynski opened 4 years ago

adamwawrzynski commented 4 years ago

I am using docker container to install all dependencies. It looks as follows:

FROM ubuntu:latest

WORKDIR /app

RUN apt-get update -y \
    && apt-get install -y \
    git \
    make \ 
    cython \
    wget \
    automake \
    build-essential \
    python3-dev \
    python3-pip \
    zlib1g-dev

RUN python3 -m pip install \
    cython \
    requests

RUN git clone https://github.com/NixOS/patchelf
WORKDIR /app/patchelf
RUN ./bootstrap.sh \
    && ./configure \
    && make \
    && make check \
    && make install
WORKDIR /app/

RUN git clone https://github.com/jpuigcerver/openfst-python
WORKDIR /app/openfst-python
RUN python3 setup.py install

WORKDIR /app/

After executing example code from README:

import openfst_python as fst

f = fst.Fst()
s0 = f.add_state()
s1 = f.add_state()
s2 = f.add_state()
f.add_arc(s0, fst.Arc(1, 2, fst.Weight(f.weight_type(), 3.0), s1))
f.add_arc(s0, fst.Arc(1, 3, fst.Weight.One(f.weight_type()), s2))
f.add_arc(s1, fst.Arc(2, 1, fst.Weight(f.weight_type(), 1.0), s2))
f.set_start(s0)
f.set_final(s2, fst.Weight(f.weight_type(), 1.5))
print(f)

And I got following error:

Traceback (most recent call last):
  File "fsa.py", line 32, in <module>
    f = fst.Fst()
  File "pywrapfst.pyx", line 1617, in pywrapfst.Fst.__init__
AttributeError: 'pywrapfst.Fst' object has no attribute '_class__'
adamjankaczmarek commented 4 years ago

There seem to be two separate issues:

jpuigcerver commented 4 years ago

Hi Adam,

Yes. The Python interface for OpenFst has been broken at least since version 1.7.1. Last time I checked, 1.7.9 was still broken. This library uses wraps that interface, so until they fix it, there's not much I can do.

You can switch to the 1.6.9 branch and that should be fine.