openfst-python icon indicating copy to clipboard operation
openfst-python copied to clipboard

Example run error

Open adamwawrzynski opened this issue 4 years ago • 2 comments

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__'

adamwawrzynski avatar Oct 13 '20 08:10 adamwawrzynski

There seem to be two separate issues:

  • typo in OpenFst's pywrapfst (namely _class__ instead of __class__)
  • outdated example (incompatible from openfst 1.7.6)

adamjankaczmarek avatar Oct 13 '20 12:10 adamjankaczmarek

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.

jpuigcerver avatar Oct 16 '20 11:10 jpuigcerver