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

edu.stanford.nlp.trees.DeepTree 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.trees;

import java.util.Comparator;
import java.util.IdentityHashMap;

import org.ejml.simple.SimpleMatrix;

/**
 * A tree combined with a map from subtree to SimpleMatrix vectors.
 *
 * @author Richard Socher
 */
public class DeepTree {

  private final Tree tree;
  private final IdentityHashMap vectors;
  private final double score;

  public Tree getTree() {
    return tree;
  }

  public IdentityHashMap getVectors() {
    return vectors;
  }

  public double getScore() {
    return score;
  }

  public DeepTree(Tree tree, IdentityHashMap vectors, double score) {
    this.tree = tree;
    this.vectors = vectors;
    this.score = score;
  }

  /**
   * A comparator that can be used with Collections.sort() that puts
   * the highest scoring tree first
   */
  public static final Comparator DESCENDING_COMPARATOR = new Comparator() {

    /** Reverses the score comparison so that we can sort highest score first */
    @Override
    public int compare(DeepTree o1, DeepTree o2) {
      return -Double.compare(o1.score, o2.score);
    }

  };
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy