All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.stanford.nlp.parser.shiftreduce.OracleTransition Maven / Gradle / Ivy

Go to download

Stanford Parser processes raw text in English, Chinese, German, Arabic, and French, and extracts constituency parse trees.

There is a newer version: 3.9.2
Show newest version
package edu.stanford.nlp.parser.shiftreduce;

/**
 * Used internally by the Oracle.  If the next oracle transition is
 * known, that is stored.  Otherwise, general classes of transitions
 * are allowed.
 *
 * @author John Bauer
 */
class OracleTransition {
  final Transition transition;
  final boolean allowsShift;
  final boolean allowsBinary;
  final boolean allowsEitherSide;

  OracleTransition(Transition transition, boolean allowsShift, boolean allowsBinary, boolean allowsEitherSide) {
    this.transition = transition;
    this.allowsShift = allowsShift;
    this.allowsBinary = allowsBinary;
    this.allowsEitherSide = allowsEitherSide;
  }

  boolean isCorrect(Transition other) {
    if (transition != null && transition.equals(other)) {
      return true;
    }

    if (allowsShift && (other instanceof ShiftTransition)) {
      return true;
    }

    if (allowsBinary && (other instanceof BinaryTransition)) {
      return true;
    }

    if (allowsEitherSide && (other instanceof BinaryTransition) && (transition instanceof BinaryTransition)) {
      if (((BinaryTransition) other).label.equals(((BinaryTransition) transition).label)) {
        return true;
      }
    }

    return false;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy