Go to: LING 1330/2330 home page  

Exercise 8: Getting to know foma

Install foma, establish workflow

Let's install foma. We will also establish a workflow that includes a workaround for the finicky "view" command. Instructions below.

Windows users

  1. Download GraphViz zip file "windows_10_msbuild_Release_graphviz-9.0.0-win32.zip" from here, unzip it, then move the "Graphviz" folder into C:\Program Files (x86)\
  2. Download Foma zip file "foma-0.9.18_win32.zip" from here, unzip it, rename the folder name "foma-0.9.18_win32" to "Foma", then move it into C:\Program Files (x86)\
  3. Add the two applications to system PATH. Here's how.
  4. In cmd, run foma. Create a regex. Instead of "view", use: print dot > fst.txt (see workflow below)
  5. In another cmd, use command:
    dot fst.txt -Tpng -o fst.png & start fst.png (see workflow below)
  6. Your workflow should now be like this.

Mac users

First, check your OS X version. Versions 11, 12, 13 ("Big Sur", "Monterey", "Ventura", "Sonoma") are fine; if you have version 10, make sure it's 10.14 or later ("Mojave" or "Catalina"). Steps:
  1. Install homebrew, if you don't have it already. Make sure you complete the very last step of adding homebrew to your OS's PATH (see this screenshot).
  2. In Terminal, install GraphViz through homebrew: brew install graphviz
  3. Install foma: brew install foma
  4. In Terminal, run foma. Create a regex. Instead of "view", use: print dot > fst.txt (see workflow below)
  5. In another Terminal, use command:
    dot fst.txt -Tpng -o fst.png ; open fst.png (see workflow below)
  6. Your workflow should now be like this.

Linux users

Install Graphviz and then foma. On Ubuntu, foma can be installed via apt install foma-bin. If your system knows how to handle .png files, "view" will work from within foma. Your workflow will be like this (image from my WSL setup).


Explore

Follow the "Getting started with foma" tutorial, listed under the "Documentation" section in the foma home page. There are three exercises: turn your solution into a graph image, and paste them in a word-processed document. A few additional pointers:
  • Need to quit foma? Type in "exit" followed by ENTER. That kicks you back into your command-line environment.
  • Make sure to substitute the "view" command with the "print dot --> convert to png --> open image" routine above.
  • Avoid going into the "up" and "down" modes, which can be hard to get out of (Ctrl+D usually works). Instead, supply a word argument with up and down: up buses, down bus[PL].
  • + is a special regex symbol, so you will need to escape it.
  • Defining a regular expression (def NAME REGEX ;) does not in fact push it onto the stack, which is necessary before you can test it out. For this, you should follow up with the push command, as in push NAME
  • In fact, going the other way is more intuitive: first create a regular expression onto your stack through regex a|b|c|d ;, test it out, and when you are satisfied, give it a name through define. Screenshot here.
  • Is your stack becoming too high? Use clear stack
  • Having trouble? Check the "Common mistakes" section at the bottom of the tutorial.


SUBMIT:
  • A word-processed document (MS Word) containing your FST graph images. PDF version is fine too.