bmeaut / python_nlp_2017_fall

Material for the 2017 fall edition of the course "Introduction to Python and Human Language Technologies" at BME AUT
MIT License
12 stars 13 forks source link

Foma regex bonus question wrong tips? #12

Closed dobijan closed 6 years ago

dobijan commented 6 years ago

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.

DavidNemeskey commented 6 years ago

@dobijan thanks for pointing this out. I have updated the task description.