YY-mode with pydelphin ACE wrapper?

Can I pass the following type of command:

ace -g ../srg.dat -y --yy-rules

to the pydelphin ACE wrapper? If yes, what’s the correct way of doing that?

I know the basic usage from the docs:

response = ace.parse('erg.dat', 'Dogs bark.') – but I am not sure whether and how it accepts any flags and additional arguments. “YY” occurs once in the code:

_ace_argparser.add_argument('--yy-rules', action='store_true')

Do I need to interact with the AceParser class more directly to access this functionality?

I didn’t want to repeat myself too much, so the docs make you jump around a bit to find the answer. If you see under ace.parse() the following parameter:

**kwargs – additional keyword arguments to pass to the ACEParser

Then go to ACEParser, which is a subclass of ACEProcess, it says:

See ACEProcess for initialization parameters.

Then under ACEProcess you’ll find in the parameter list:

  • cmdargs (list, optional) – a list of command-line arguments for ACE; note that arguments and their values should be separate entries, e.g. [‘-n’, ‘5’]

So you can do this (assuming this is what you want to do):

ace.parse("../srg.dat", yyinput, cmdargs=['-y', '--yy-rules'])

So you don’t need to use ACEParser directly, but it is recommended if you’re parsing many things at once, because otherwise you’re executing ACE and loading the grammar for each input. Here’s how you might use ACEParser:

with ace.ACEParser('../srg.dat', cmdargs=['-y', '--yy-rules']) as parser:
    for yyinput in inputlist:
        response = parser.interact(yyinput)