I decided to have a try with the bonus exercise in the third homework. It left me quite frustrated at first, because foma was not willing to save my regex as an automaton despite my following the tips and hints in the homework.
I finally managed to make it work, but I had to look up foma's quite limited howto, which stated that this has to be done differently than what the homework notebook implies. I thought this might be interesting to everyone (including the instructors), so I'd just like to put on record the little fix that works (I won't be including my whole solution, no worries here).
I was using the boilerplate provided by @DavidNemeskey during the labs, particularly execute_commads and apply. The homework states we should use read regex <regex> which is analogous to read lexc filename but I couldn't make this work. Instead, I managed to pull it off with regex <regex> ;. Notice the semicolon at the end and the absence of read. Also, the regex this way is read from the command, not a file.
So using the boilerplate this would be: execute_commands('regex {} ;'.format(regex), 'save stack {}'.format(self.fsa_file), fancy=False), if we have our filename stored in self.fsa_file.
Maybe there is such a thing as read regex <regex / file> but I wasn't able to make it work.
I decided to have a try with the bonus exercise in the third homework. It left me quite frustrated at first, because
foma
was not willing to save my regex as an automaton despite my following the tips and hints in the homework.I finally managed to make it work, but I had to look up
foma
's quite limitedhowto
, which stated that this has to be done differently than what the homework notebook implies. I thought this might be interesting to everyone (including the instructors), so I'd just like to put on record the little fix that works (I won't be including my whole solution, no worries here).I was using the boilerplate provided by @DavidNemeskey during the labs, particularly
execute_commads
andapply
. The homework states we should useread regex <regex>
which is analogous toread lexc filename
but I couldn't make this work. Instead, I managed to pull it off withregex <regex> ;
. Notice the semicolon at the end and the absence ofread
. Also, the regex this way is read from the command, not a file. So using the boilerplate this would be:execute_commands('regex {} ;'.format(regex), 'save stack {}'.format(self.fsa_file), fancy=False)
, if we have our filename stored inself.fsa_file
.Maybe there is such a thing as
read regex <regex / file>
but I wasn't able to make it work.