Question: possible to write a binary file from the command line (external script)?
GoogleCodeExporter opened this issue · comments
Google Code Exporter commented
What steps will reproduce the problem?
If I open foma and run 'source phonology.foma' and then 'save stack
phon_bin.foma', I get a binary file that works as expected, i.e., I can run
'echo "word" | flookup -x phon_bin.foma' and I get a correct parse.
However, if I try to repeat this procedure using Python's subprocess module,
the binary file generated is not as expected. The Python script is basically
as follows (with absolute paths replacing the filenames).
import subprocess
process = subprocess.Popen(['foma'], shell=False, stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
process.stdin.write('source phonology.foma')
process.stdin.write('save stack phon_bin.foma')
What is the expected output? What do you see instead?
I expect to get the same output (i.e., binary file) from the command line as I
do from the Python script. However, the Python strategy results in an FSM with
2 states (678 bytes. 2 states, 2 arcs, 2 paths) while the command line strategy
correctly results in one with 20 (1.0 kB. 20 states, 24 arcs, 10 paths).
What version of the product are you using? On what operating system?
Foma, version 0.9.14alpha
Mac OS X 10.6.8
Python 2.5/2.6
Please provide any additional information below.
Is my approach incorrect? The goal is to be able to generate FSTs using foma
from within a python application.
Is it possible to use foma to convert a foma script into a binary
representation right from the command line?
Original issue reported on code.google.com by jrwdunham@gmail.com
on 17 Feb 2012 at 4:16
Google Code Exporter commented
Following works well for me:
in shell script test.foma I say:
foma -l enhu2.foma <savestack.sh
savestack.sh has following content:
save stack hun41.fst
In an other script I can the do flookup using for example:
echo tűz+Noun+Plur+Gens+Ade | flookup -i hun41.fst >> tfoma2.txt
I use Foma, version 0.9.16alpha
on linux/debian
Original comment by eleonor...@gmx.net
on 21 Feb 2012 at 5:34
Google Code Exporter commented
Thanks eleonor...,
Your approach works for me!
Original comment by jrwdunham@gmail.com
on 23 Feb 2012 at 10:26
Google Code Exporter commented
You can also just run a string of commands with various instantiations of the
-e flag producing what you want:
foma -e "source test.script" -e "save stack test.foma" -e "quit"
This would load "test.script" and then save the resulting transducer(s) in
"test.foma", and then quit foma.
Original comment by mans.hul...@gmail.com
on 24 Feb 2012 at 3:56
Google Code Exporter commented
Thanks Mans,
That was exactly what I was looking for!
Original comment by jrwdunham@gmail.com
on 28 Feb 2012 at 7:04