edu.stanford.nlp.patterns.dep.ExtractedPhrase 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.patterns.dep;
import java.io.Serializable;
import edu.stanford.nlp.semgraph.semgrex.SemgrexPattern;
import edu.stanford.nlp.stats.Counter;
import edu.stanford.nlp.util.IntPair;
public class ExtractedPhrase implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
int startIndex;
int endIndex;
SemgrexPattern pattern;
String value;
double confidence = 1;
String articleId = null;
Integer sentId = null;
Counter features;
public ExtractedPhrase(int startIndex, int endIndex, SemgrexPattern pattern, String value) {
this(startIndex, endIndex, pattern, value, 1.0, null, null, null);
}
public ExtractedPhrase(int startIndex, int endIndex, SemgrexPattern pattern, String value, Counter features) {
this(startIndex, endIndex, pattern, value, 1.0, null, null, features);
}
public ExtractedPhrase(int startIndex, int endIndex, SemgrexPattern pattern, String value, double weight,
String articleId, Integer sentId){
this(startIndex, endIndex, pattern, value, weight, articleId, sentId, null);
}
public ExtractedPhrase(int startIndex, int endIndex, SemgrexPattern pattern, String value, double weight,
String articleId, Integer sentId, Counter features) {
this.startIndex = startIndex;
this.endIndex = endIndex;
this.pattern = pattern;
this.value = value;
this.confidence = weight;
this.articleId = articleId;
this.sentId = sentId;
this.features = features;
}
// public ExtractedPhrase(int startIndex, int endIndex) {
// this(startIndex, endIndex, null, null);
// }
// public ExtractedPhrase(int startIndex, int endIndex, SemgrexPattern
// pattern) {
// this(startIndex, endIndex, pattern, null);
// }
public ExtractedPhrase(int startIndex, int endIndex, String value) {
this(startIndex, endIndex, null, value);
}
int getStartIndex() {
return this.startIndex;
}
int getEndIndex() {
return this.endIndex;
}
public IntPair getIndices() {
return new IntPair(startIndex, endIndex);
}
public String getValue() {
return this.value;
}
public SemgrexPattern getPattern() {
return this.pattern;
}
void setPattern(SemgrexPattern pattern) {
this.pattern = pattern;
}
void setConfidence(double weight) {
this.confidence = weight;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof ExtractedPhrase)) return false;
ExtractedPhrase p = (ExtractedPhrase) o;
if (p.startIndex == this.startIndex && p.endIndex == this.endIndex && (this.value.equals(p.value)))
return true;
else
return false;
}
@Override
public int hashCode() {
return this.startIndex * 31 + this.endIndex + this.value.hashCode();
}
public Counter getFeatures(){
return this.features;
}
@Override
public String toString(){
return this.value + "("+startIndex+","+endIndex+"," + features+")";
}
}