KhalilMrini / LAL-Parser

Neural Adobe-UCSD Parser, the current State of the Art in Constituency and Dependency Parsing.
138 stars 24 forks source link

`ValueError: negative dimensions are not allowed` if empty sentence #12

Closed Franck-Dernoncourt closed 4 years ago

Franck-Dernoncourt commented 4 years ago

ValueError: negative dimensions are not allowed if empty sentence

Example. example_sentences.txt contains:

There is a small blue car near the house.

I ate the blueberries and apples that I purchased yesterday.

(i.e. the second line is empty)

Error:


(neural-parser2) dernonco@ilcompn0:/mnt/ilcompn0d1/user/dernonco/sensei/neural-parser/20200512/LAL-Parser$ time CUDA_VISIBLE_DEVICES=1 sh parse_quick.sh
Loading model from best_parser.pt...
/mnt/ilcompn0d1/user/dernonco/pyenv/neural-parser2/lib/python3.6/site-packages/torch/nn/_reduction.py:46: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead.
  warnings.warn(warning.format(ret))
Parsing sentences...
Parsing sentences:   0%|                                                                                                                                                                                        | 0/1 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "src_joint/main.py", line 769, in <module>
    main()
  File "src_joint/main.py", line 765, in main
    args.callback(args)
  File "src_joint/main.py", line 693, in run_parse
    syntree, _ = parser.parse_batch(tagged_sentences)
  File "/mnt/ilcompn0d1/user/dernonco/sensei/neural-parser/20200512/LAL-Parser/src_joint/KM_parser.py", line 1808, in parse_batch
    fencepost_annotations_end[start:end,:], sentences[i], i)
  File "/mnt/ilcompn0d1/user/dernonco/sensei/neural-parser/20200512/LAL-Parser/src_joint/KM_parser.py", line 1923, in parse_from_annotations
    return self.decode_from_chart(sentence, label_scores_chart_np, arc_dc_np, type, sentence_idx=sentence_idx, contributions=contributions)
  File "/mnt/ilcompn0d1/user/dernonco/sensei/neural-parser/20200512/LAL-Parser/src_joint/KM_parser.py", line 1953, in decode_from_chart
    score, p_i, p_j, p_label, p_father, p_type, _ = hpsg_decoder.decode(force_gold, **decoder_args)
  File "src_joint/hpsg_decoder.pyx", line 154, in hpsg_decoder.decode
    cdef np.ndarray[int, ndim=1] included_i = np.empty(num_tree_nodes, dtype=np.int32)
ValueError: negative dimensions are not allowed
`
KhalilMrini commented 4 years ago

Hi Franck, I added a line that should filter out empty lines :-)

Franck-Dernoncourt commented 4 years ago

great, thanks!