delph-in / pydelphin

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

generation causes an exception when processing a profile #314

Closed arademaker closed 3 years ago

arademaker commented 4 years ago

After finishing the annotation of https://github.com/arademaker/sick-fftb, I am using pydelphin to create a new profile with the best analysis for each sentence. The ideia is to compare the golden analysis with the best analysis from ACE. But...

% python process.py
    9746 bytes  relations
    8764 bytes  item
       0 bytes  analysis
       0 bytes  phenomenon
       0 bytes  parameter
       0 bytes  set
       0 bytes  item-phenomenon
       0 bytes  item-set
       0 bytes  run
       0 bytes  parse
       0 bytes  result
       0 bytes  rule
       0 bytes  output
       0 bytes  edge
       0 bytes  tree
       0 bytes  decision
       0 bytes  preference
       0 bytes  update
       0 bytes  fold
       0 bytes  score
Assertion failed: (ty->name[0]=='"'), function type_to_string, file type.c, line 625.
Traceback (most recent call last):
  File "process.py", line 13, in <module>
    tgt_ts.process(cpu, source=src_ts)
  File "/Users/ar/venv/lib/python3.8/site-packages/delphin/itsdb.py", line 881, in process
    response = cpu.process_item(datum, keys=keys_dict)
  File "/Users/ar/venv/lib/python3.8/site-packages/delphin/ace.py", line 284, in process_item
    response = self.interact(datum)
  File "/Users/ar/venv/lib/python3.8/site-packages/delphin/ace.py", line 257, in interact
    self.send(validated)
  File "/Users/ar/venv/lib/python3.8/site-packages/delphin/ace.py", line 201, in send
    self._p.stdin.write((datum.rstrip() + '\n'))
ValueError: I/O operation on closed file.

the code is:

from delphin import itsdb
from delphin import ace
from delphin import commands

src_path = 'golden'
tgt_path = 'p'

commands.mkprof(tgt_path, source=src_path)
src_ts = itsdb.TestSuite(src_path)
tgt_ts = itsdb.TestSuite(tgt_path)
with ace.ACEGenerator('erg.dat') as cpu:
    tgt_ts.process(cpu, source=src_ts)

but from the command line, it works fine:

% delphin process -g erg.dat -o "-n 1" -s golden parsed
goodmami commented 4 years ago

Hmm, nothing seems particularly amiss at first glance. I do notice that in your command-line version you are parsing while in the Python code you are generating. Do you get the error at the command line when you generate?

arademaker commented 4 years ago

Oh, my bad. I want to parse. I forgot to change the example from the documentation. But the generation should work right?

goodmami commented 4 years ago

Yes, I think it should work. But I wonder if the source profile has an empty result file, so there's nothing to generate from. If this is the case, there shouldn't be an exception, or at least a more informative one should be raised.

arademaker commented 4 years ago

The source profile is the golden at https://github.com/arademaker/sick-fftb. It was annotated with fftb.

goodmami commented 4 years ago

Ok I tried it out. I added the following to process.py so I could see the progress (the same as using -vv when run from the command line):

import logging
logging.basicConfig(level=logging.INFO)

And I used the 2018 version of the ERG since that is what I had.

Parsing works for me (replaced ACEGenerator with ACEParser). In process.py you don't constrain the number of results so it takes about a minute on my machine (compared to ~10s with -n1), but there were no errors.

Generation also completes without issue, but it takes about 5 minutes.

In any case, the error you got looks like ACE crashed and then PyDelphin tried to send another item to the dead process. I'm not really sure that anything is wrong with PyDelphin in this case.

goodmami commented 3 years ago

Closing as invalid; it looks like nothing was amiss here.