Open TonalidadeHidrica opened 5 years ago
For some reason, thre's an if statment in stog/commands/predict.py::_predict_instances()
(about line 141) that sends the code on a different path if your batch_data
size is 1 (ie.. only one sentence). The stog
model doesn't have that code implemented. I'm not sure if there is still a valid reason for this but it appear to work if you comment-out the if/else
.
Here's the revised function....
def _predict_instances(self, batch_data: List[Instance]) -> Iterator[str]:
# removed - doesn't work for single instance of batch data.
#if len(batch_data) == 1:
# results = [self._predictor.predict_instance(batch_data[0])]
#else:
results = self._predictor.predict_batch_instance(batch_data)
for output in results:
yield self._predictor.dump_line(output)
At the prediction step, if the input file contains only one sentence, it results in an error. For example, after all the preprocess was applied to the AMR 2.0 (LDC2017T10) data (following the steps in README.md), there will be a preprocessed test data file
test.preproc
indata/AMR/amr_2.0/
directory. However, if I removed all the "paragraphs" (that is, a pair of "comments" (including id, snt, and tags etc.) and AMR graph) except for the first paragraph from the file, and then apply the "6. Prediction" phase, the program shows the following error:This error occurs whenever input file with only one AMR paragraph was given to
--input-file
option ofstog.commands.predict
module. Also, if the input file contains more than two paragraphs, this error doesn't seem to be happening.