I took a little look in your code and found two things for little code improvements for better reading:
make this:
Code:
if (word[word.length() - 1] == "." || word[word.length() - 1] == ",") {
word = word.substring(0, word.length() - 1)
}
to this to make it easy to understand:
Code:
word.replaceAll("\\.|,", "")
make this:
Code:
if (word == "handcuffs" || word == "cuffs" || word == "handcuffed" || word == "cuffed") {
to this with a list:
Code:
if (word in ["handcuffs", "cuffs", "handcuffed", "cuffed"]) {
Or put that block of code in a map and loop over the map.
Code:
Map posspicWordMap = [
"handcuffs":["handcuffs", "cuffs", "handcuffed", "cuffed"],
// more posspic words here
]
posspicWordMap.each { it -> ... }