OpenCCG / openccg

OpenCCG library for parsing and realization with CCG
http://openccg.sourceforge.net/
Other
205 stars 45 forks source link

Adding -prompt flag to WebCCG #22

Open shoeffner opened 5 years ago

shoeffner commented 5 years ago

Adding -prompt flag to WebCCG to allow tools like Python's pexpect to parse it more easily.

Specifying the prompt flag wccg -prompt ">>>" GRAMMAR will case wccg to show the prompt expecting input like this:

>>> 

Entering a sentence looks thus:

>>> she sings a song

By default, the old behavior is kept stable (no prompt sign at all).

I use this feature to parse the output using replwrap, to keep a process alive for a longer time (before I used Popen.communicate, which is a one-off command and forced me to create new wccg processes for each parse).

To keep the diff small, I tried to keep the whitespace as it is in the surroundings, but the file mixes tabs and spaces a lot and it seems in lines 85 and 120/121 I somehow missed the conventions a little bit, as I just realized. If you want, I can update my lines or reindent the file completely.