FAQ for Homework 2

From 11-711
Jump to: navigation, search

1. shortest_path() doesn't seem to always find the shortest path!

Some people seem to have a problem wherein OpenFST interprets weights in regular space instead of log space. This causes all paths with all zero weights to look equally good, and so shortest_path returns a random path rather than the shortest one. To fix this do the following right before calling shortest_path():

   for state in output_fsa:
       for arc in state:
           arc.weight = fst._fst.TropicalWeight(1.0)

2. I can't visualize FSTs that have arcs ending in "\"!

Minimal steps to reproduce:

   import fst
   t = fst.Transducer()
   t.add_arc(0, 1, 'a', '\\')


   Exception                                 Traceback (most recent call last)
   <ipython-input-85-3be3f1d897c8> in <module>()
   ----> 1 t._repr_svg_()
   /opt/virtualenvs/711/local/lib/python2.7/site-packages/fst/_fst.so in fst._fst._Fst._repr_svg_ (fst/_fst.cpp:4600)()
   Exception: Warning: <stdin>: syntax error in line 10 near 

This error affects GraphViz version 2.32 to 2.37. The fix is to upgrade to GraphViz >= 2.38.

3. intersect / union / difference / compose is giving me a kError!

kError is just a generic OpenFST error. If you run your code in Python or IPython, rather than in a notebook, you'll be able to see a more detailed error message printed to stderr.

Usually though, these errors mean you need to sort the arcs of your fsts so they match up.

Before intersect / union / difference, run:


Before compose, run:


4. I composed two FSTs, and the result is blank!

Your composition probably resulted in an FST that never accepts any strings. When this happens compose returns an FST with 0 states, which displays as blank. Double check the FSTs you're trying to compose.