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

edu.berkeley.nlp.PCFGLA.Rule Maven / Gradle / Ivy

Go to download

The Berkeley parser analyzes the grammatical structure of natural language using probabilistic context-free grammars (PCFGs).

The newest version!
package edu.berkeley.nlp.PCFGLA;

import java.util.Comparator;
/**
 * Parent class for unary and binary rules.
 *
 * @author Dan Klein
 */
public class Rule implements java.io.Serializable {

	public int identifier; // a unique number

  public short parentState = -1;
  public boolean logarithmMode = false;

  public short getParentState() {
    return parentState;
  }

//  public int getParentSubState() {
//	    return parentSubState;
//	  }
//
//  /** @return the log of the rule probability */
//  public double score() {
//    return score;
//  }

  public boolean isUnary() {
    return false;
  }

  static class ScoreComparator implements Comparator {
    public int compare(Rule r1, Rule r2) {
    	//TODO : fix
//      if (r1.score() < r2.score()) {
//        return -1;
//      } else if (r1.score() == r2.score()) {
//        return 0;
//      } else {
        return 1;
//      }
    }

    ScoreComparator() {}

  }

  private static Comparator scoreComparator = new ScoreComparator();

  public static Comparator scoreComparator() {
    return scoreComparator;
  }
  private static final long serialVersionUID = 1L;

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy