Example usage for edu.stanford.nlp.util ArrayUtils contains

List of usage examples for edu.stanford.nlp.util ArrayUtils contains

Introduction

In this page you can find the example usage for edu.stanford.nlp.util ArrayUtils contains.

Prototype

public static <T> boolean contains(T[] a, T o) 

Source Link

Document

Returns true iff object o equals (not ==) some element of array a.

Usage

From source file:filters.dependencies.NegationWordFilter.java

License:Open Source License

@Override
public boolean incrementToken() throws IOException {
    // Load next token from input stream
    Token current_token;//from  w w  w.ja  va2 s.  c  o  m
    if ((current_token = getNextToken()) == null)
        return false;

    // If current token term belongs to the set of negation terms, switch the state of the
    // negation flag (i.e. prepare to mark the next open class term as negated). Or if this
    // is already the case, reverse the effect of the negation, to account for double negatives)
    if (ArrayUtils.contains(negationTerms, current_token.term)) {
        current_token.payload.setNegation(true);
    }

    // Setting attributes for output stream
    output_term.setTermBuffer(current_token.term);
    output_type.setType(current_token.type);
    output_flags.setFlags(current_token.flags);
    output_payload.setPayload(current_token.payload.getPayload());

    return true;
}

From source file:filters.indexing.NegationScopeFilter.java

License:Open Source License

@Override
public boolean incrementToken() throws IOException {
    // Load next token from input stream
    Token current_token;/*  w w w .  j a  va  2  s  .  c  o m*/
    if ((current_token = getNextToken()) == null)
        return false;

    // If current token term belongs to the set of negation terms, switch the state of the
    // negation flag (i.e. prepare to mark the next open class term as negated). Or if this
    // is already the case, reverse the effect of the negation, to account for double negatives)
    if (ArrayUtils.contains(negationTerms, current_token.term)) {
        negative = !negative;
        return incrementToken();
    }

    // If we are within the scope of a negation, modify the token's payload accordingly and
    // reset the state of the negation flag
    if (negative) {
        if (current_token.isOpenClass()) {
            current_token.payload.setNegation(true);
            negative = false;
        }

        // If we reached the end of a phrase, reset the state of the negation flag
        else if (PosTag.isDelim(current_token.payload.getPosCat())) {
            negative = false;
        }
    }

    // Setting attributes for output stream
    output_term.setTermBuffer(current_token.term);
    output_type.setType(current_token.type);
    output_flags.setFlags(current_token.flags);
    output_payload.setPayload(current_token.payload.getPayload());

    return true;
}