Let's install foma. We will also establish a workflow that includes a workaround for the finicky "view" command. Instructions below.
Windows users
Download GraphViz installation .exe file from the "graphviz-16.1.0 (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".
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)\
Add foma's app folder to your system PATH. Here's how.
On my laptop, the two applications' executable paths are as below. Graphviz had been already added during the installation process, and I added foma manually. You should verify your exact paths.
Open up a new terminal window (cmd or Anaconda Prompt). Try where foma and where dot (see this screenshot). Your setup was successful if cmd can find the two commands.
In your terminal, run foma. Create a regex. Instead of "view", use: print dot > fst.txt (see workflow below)
In another terminal, use command: dot fst.txt -Tpng -o fst.png & start fst.png (see workflow below)
Is your .png image too small? Try adding the -Gdpi=192 option in your dot command, which doubles up the image dimensions by changing the dpi value (default is 96).
For the "view" command to work within foma, you will have to go over to the Linux side, which we can now run within Windows 10. First, install Linux: Pick Ubuntu, 20.04 worked smoothly for me. Then, within Ubuntu terminal, update your package manager sudo apt update, install graphviz: sudo apt install graphviz, and finally install foma: sudo apt install foma-bin. You also need a graphics viewer: sudo apt install gpicview. Crucially, you need an X Windows manager: VcXsrv comes highly recommended. You launch it via X-Launch; pick "Multiple windows", and for Display number specify "0". Finally, fire up a Ubuntu terminal, set display with export DISPLAY=:0, then start foma. The "view" command will now work!
Make sure you're using cmd (or Anaconda Prompt, which is built on cmd) and not PowerShell. If "where foma" does not work or you get the error "The ampersand (&) character is not allowed" while trying to create an image file, you're using the wrong terminal. cmd and PowerShell are both Windows terminals but use different syntax.
Mac users
Steps:
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.
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.
Install foma: brew install foma
In Terminal, run foma. Create a regex. Instead of "view", use: print dot > fst.txt (see workflow below)
In another Terminal, use command: dot fst.txt -Tpng -o fst.png ; open fst.png (see workflow below)
Is your .png image too small? Try adding the -Gdpi=192 option in your dot command, which doubles up the image dimensions by changing the dpi value (default is 96).
For the "view" command to work within foma, you also need graphviz-gui. Unfortunately this package is not available through homebrew; you need to install and use MacPorts: port install graphviz-gui. In my case, I needed to install Xcode before MacPorts, which took forever and took up 7GB of space. So, this may or may not be worth your time.
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
In the foma home page, find the "Getting started with foma" tutorial listed under the "Documentation" section and complete the three exercises. With each of the 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, Anaconda Prompt 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.