edu.stanford.nlp.parser.lexparser.LatticeEdge Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stanford-corenlp Show documentation
Show all versions of stanford-corenlp Show documentation
Stanford CoreNLP provides a set of natural language analysis tools which can take raw English language text input and give the base forms of words, their parts of speech, whether they are names of companies, people, etc., normalize dates, times, and numeric quantities, mark up the structure of sentences in terms of phrases and word dependencies, and indicate which noun phrases refer to the same entities. It provides the foundational building blocks for higher level text understanding applications.
package edu.stanford.nlp.parser.lexparser;
import java.util.*;
import java.io.Serializable;
import edu.stanford.nlp.util.Generics;
public class LatticeEdge implements Serializable {
public final String word;
public String label = null;
public double weight;
public final int start;
public final int end;
public final Map attrs;
public LatticeEdge(String word, double weight, int start, int end) {
this.word = word;
this.weight = weight;
this.start = start;
this.end = end;
attrs = Generics.newHashMap();
}
public void setAttr(String key, String value) { attrs.put(key, value); }
public String getAttr(String key) { return attrs.get(key); }
public void setLabel(String l) { label = l; }
public void setWeight(double w) { weight = w; }
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("[ " + word);
sb.append(String.format(" start(%d) end(%d) wt(%f) ]", start,end,weight));
if(label != null)
sb.append(" / " + label);
return sb.toString();
}
private static final long serialVersionUID = 4416189959485854286L;
}