Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in parsing single quotes #6

Open
oncebasun opened this issue Apr 17, 2019 · 0 comments
Open

NullPointerException in parsing single quotes #6

oncebasun opened this issue Apr 17, 2019 · 0 comments

Comments

@oncebasun
Copy link

In QuotationAnnotator.java

if (usesSingleQuotes) {
			
    Token previousToken = null;
    
    // fixes a problem with single quotes before "I" not being recognized as open quotes
    for (int i = 0; i < book.tokens.size(); i++) {
        Token token = book.tokens.get(i);
        if (token.original.equals("'")) {
            if (!previousToken.whitespaceAfter.equals("")) {
                token.lemma="`";
                token.word="`";
                token.pos="``";
            }
        }
        previousToken=token;
    }
    
    
    previousToken = null;

    for (int i = 0; i < book.tokens.size(); i++) {
        Token token = book.tokens.get(i);
        if (token.lemma.equals("`")) {
            
            if (!previousToken.whitespaceAfter.equals("")) {
                open = true;
                start = token.tokenId;
            }
        } else if (token.lemma.equals("'")) {
            end = token.tokenId;

            if (start > -1 && open) {
                Quotation quote = new Quotation(start, end,
                        token.sentenceID);
                quotations.put(start, quote);
            }
            start = -1;

            open = false;

        }
        previousToken = token;

    }
}

will cause NullPointerException when previousToken is null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant