Skip to content

Instantly share code, notes, and snippets.

@sshleifer
Created June 14, 2020 20:06
Show Gist options
  • Save sshleifer/3d98fc793d1d16cb0684ff77b49bf597 to your computer and use it in GitHub Desktop.
Save sshleifer/3d98fc793d1d16cb0684ff77b49bf597 to your computer and use it in GitHub Desktop.

Stanford CoreNLP Setup

ptb_tokenize () {
    cat $1 | java edu.stanford.nlp.process.PTBTokenizer -ioFileList -preserveLines > $2
}

sudo apt install openjdk-8-jre-headless
sudo apt-get install ant
wget http://nlp.stanford.edu/software/stanford-corenlp-full-2018-10-05.zip
unzip stanford-corenlp-full-2018-10-05.zip
cd stanford-corenlp-full-2018-10-05
export CLASSPATH=stanford-corenlp-3.9.2.jar:stanford-corenlp-3.9.2-models.jar

Then run ptb_tokenize on test.target and your generated hypotheses.

Rouge Setup

Install files2rouge following the instructions at here. I also needed to run sudo apt-get install libxml-parser-perl

from files2rouge import files2rouge
from files2rouge import settings
files2rouge.run(<path_to_tokenized_hypo>,
                <path_to_tokenized_target>,
               saveto='rouge_output.txt')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment