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 installation .exe file from the "graphviz-12.1.2 (32-bit) EXE installer" link on this page, then install it. Windows may throw up "unsafe app was blocked" message: ignore & proceed. In the "Install Options" window, make sure to select the 2nd option "Add Graphviz to the system PATH for all users".
  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 foma's app folder to your system PATH. Here's how.
  4. Open up a new cmd window. Try where foma and where dot (see this screenshot). Your setup was successful if cmd can find the two commands.
  5. In cmd, run foma. Create a regex. Instead of "view", use: print dot > fst.txt (see workflow below)
  6. In another cmd, use command:
    dot fst.txt -Tpng -o fst.png & start fst.png (see workflow below)
  7. Your workflow should now be like this.


Mac users

First, check your OS X version. Versions 11 through 15 ("Big Sur", "Monterey", "Ventura", "Sonoma", "Sequoia") 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: the Terminal option (not the .pkg installer option) is recommended. You may be prompted to install the "CL" utility as well. If you installed homebrew via Terminal, it will prompt you to complete the last step of adding it to your OS's PATH (see this screenshot): you should do so.
  2. In Terminal, install GraphViz through homebrew: brew install graphviz
    If your Terminal complains about not finding brew, run this command in your Terminal first:
    echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> $HOME/.zprofile
    After that, open up a new Terminal window (so that the change takes effect), then try brew install ... again. It should work now.
  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 look "up" and look "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.
  • One last thing: in foma and in your console (cmd or Terminal), don't re-type your command every single time! Use up arrow and down arrow to quickly cycle through your command history.


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