delph-in / pydelphin

Python libraries for DELPH-IN
https://pydelphin.readthedocs.io/
MIT License
79 stars 27 forks source link

how to use pydelphin to process ff profile #312

Closed arademaker closed 4 years ago

arademaker commented 4 years ago

From #201, can we make the profile for FFTB using pydelphin? I am getting some

cat process-fftb.py
from delphin import ace
from delphin import tsdb
from delphin import itsdb

ts = itsdb.TestSuite('sample-200')
with ace.ACEParser('terg.dat', cmdargs = ['--disable-generalization', '--tsdb-stdout','--itsdb-forest']) as cpu:
    ts.process(cpu)
% python process-fftb.py
Traceback (most recent call last):
  File "process-fftb.py", line 6, in <module>
    with ace.ACEParser('terg.dat', cmdargs = ['--disable-generalization', '--tsdb-stdout','--itsdb-forest']) as cpu:
  File "/Users/ar/venv/lib/python3.8/site-packages/delphin/ace.py", line 90, in __init__
    _ace_argparser.parse_args(self.cmdargs)
  File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/argparse.py", line 1771, in parse_args
    self.error(msg % ' '.join(argv))
  File "/Users/ar/venv/lib/python3.8/site-packages/delphin/ace.py", line 579, in error
    raise ValueError(message)
ValueError: unrecognized arguments: --tsdb-stdout --itsdb-forest

But ACE works fine with both calls below. But they produce different outputs

ace -g terg.dat --disable-generalization --tsdb-stdout --itsdb-forest
ace -g terg.dat --disable-generalization -O
goodmami commented 4 years ago

delphin.ace only supports a subset of ACE command-line options:

https://github.com/delph-in/pydelphin/blob/3ebcce48c4edcb4e797fc8e447a80e38e8fef53a/delphin/ace.py#L582-L603

Mainly, those that change the structure of ACE's output are excluded because PyDelphin depends on that output arriving in a certain form. For options that change ACE's output protocols in supported ways, there are parameters for the PyDelphin classes (see the docs for ACEProcess), namely tsdbinfo for --tsdb-stdout and full_forest for --itsdb-forest. And tsdbinfo=True is the default, so you only specify it if you want to turn it off.

with ace.ACEParser(grm, cmdargs=['--disable-generalization'], full_forest=True) as cpu:
    ts.process(cpu)
arademaker commented 4 years ago

Thank you. I didn't pay attention to the full_forest=False in the documentation. Sorry for that. Maybe we could add a section in the https://pydelphin.readthedocs.io/en/latest/guides/itsdb.html#processing-test-suites-with-ace about the processing of FFTB profiles.

goodmami commented 4 years ago

That's a good idea.

goodmami commented 4 years ago

I added some documentation in 0aef27543db79ea9777bec8f94146765766fb504