How to print the sentence to parse in the output file in syntaxnet dependency parse?

75 views Asked by At

I am parsing many sentences in one file using: cat filename.txt | ./demo.sh > output.txt

Sometimes a sentence in there is not parsed and so there is no output and I need to be able to tell that that happened. So either I want to be able to print the sentence that was parsed before each parse or have some way to indicate that a sentence was not parsed in the file so I know the ordering.

1

There are 1 answers

0
Mayla On

To iterate over a bunch of files (in $FILES) with multiple sentences in each and print out the sentence that is running and then run the dependency parse, in order to add both to the output file (output_dp/output_$f)

for f in $FILES
do
  echo $f
  while read p; 
  do
    echo $p >> output_dp/output_$(basename "$f")
    echo $p | ./demo.sh >> output_dp/output_$(basename "$f")
  done < $f
done