Skip to content

Commit 9f1b015

Browse files
committed
fix an error when the string being examined is shorter than the test length
1 parent 2bfd39e commit 9f1b015

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/edu/stanford/nlp/pipeline/QuoteAnnotator.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -681,12 +681,16 @@ private static boolean isSingleQuoteEnd(String text, int i) {
681681
private static boolean isDoubleQuoteEnd(String text, int i) {
682682
if (i == text.length() - 1) return true;
683683
String next = text.substring(i + 1, i + 2);
684-
if (i == text.length() - 2 && isWhitespaceOrPunct(next)) {
685-
return true;
684+
if (i == text.length() - 2) {
685+
if (isWhitespaceOrPunct(next)) {
686+
return true;
687+
} else {
688+
return false;
689+
}
686690
}
687691
String nextNext = text.substring(i + 2, i + 3);
688-
return ((isWhitespaceOrPunct(next) &&
689-
!isSingleQuote(next)) || (isSingleQuote(next) && isWhitespaceOrPunct(nextNext)));
692+
return ((isWhitespaceOrPunct(next) && !isSingleQuote(next)) ||
693+
(isSingleQuote(next) && isWhitespaceOrPunct(nextNext)));
690694
}
691695

692696
public static boolean isWhitespaceOrPunct(String c) {

0 commit comments

Comments
 (0)