paper-cutter/{{cookiecutter.paper_repo_name}}/helpers/get-sentences.sh

16 lines
394 B
Bash
Raw Normal View History

#!/bin/bash
input_file="$1"
method="$2"
extract_text() {
if [[ "$method" == "from-tex" ]]
then
2022-11-09 16:55:56 +01:00
detex "$input_file" | grep -E '\S' | grep -v 'unsrt' | perl -pne 's/^\s+| +$//g'
else
bash helpers/pdf-to-plain-text.sh "$input_file" | perl helpers/strip-references.pl | perl -pne 'chomp $_; $_.=" "'
fi
}
2022-11-09 16:55:56 +01:00
extract_text | python3 -m syntok.segmenter | grep -E '\S'