How to stop python ACE from outputting debugging text

I’m using the Python binding of ACE to generate text like this:

 with ace.ACEGenerator('erg-2018-osx-0.9.31.dat') as generator:
      response = generator.interact(simple)

When I execute it, I get the following printed to the console:

NOTE: 211 passive, 243 active edges in final generation chart; built 217 passives total. [1 results]
NOTE: generated 1 / 1 sentences, avg 3335k, time 0.02422s
NOTE: transfer did 105 successful unifies and 136 failed ones

I was able to stop this when using ACE for parsing by using the stderr argument, which doesn’t appear to be available on the generator:

 f = open(os.devnull, 'w')
 with ace.ACEParser('erg-2018-osx-0.9.31.dat', stderr = f) as parser:
     response = parser.interact(phrase)

Any ideas?

This was already fixed in the development branch for over a month, but I hadn’t packaged the fix into a release until now. See the CHANGELOG and issue #278. The newest release (v1.2.2) should allow you to redirect stderr for generation just as you did for parsing.

That said, unless there are other things on stderr that you need separate, you can also redirect stderr to get rid of the messages by reassigning sys.stderr (e.g., as in this StackOverflow answer).

thanks @goodmami, that was actually the first thing I tried but it didn’t make the text go way. I did this:

sys.stderr = open(os.devnull, 'w')
with ace.ACEGenerator('erg-2018-osx-0.9.31.dat') as generator:
    response = generator.interact(simple)

The text was still printed.

It made me think there was some mismatch between Python’s notion of stderr and whatever ACE as doing. This post reinforced it, implying that stderr in Python is not quite the system version. Unclear what the real problem was though.

Regardless, I’ll grab the latest build. Thanks for the fix!

@goodmami, got the latest ACE and latest PyDelphin. Works great! Thx