本文整理汇总了Java中edu.stanford.nlp.ling.CoreAnnotations.DocIDAnnotation类的典型用法代码示例。如果您正苦于以下问题:Java DocIDAnnotation类的具体用法?Java DocIDAnnotation怎么用?Java DocIDAnnotation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DocIDAnnotation类属于edu.stanford.nlp.ling.CoreAnnotations包,在下文中一共展示了DocIDAnnotation类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hashCode
import edu.stanford.nlp.ling.CoreAnnotations.DocIDAnnotation; //导入依赖的package包/类
/**
* This hashcode uses only the docID, sentenceIndex, and index
* See compareTo for more info
*/
@Override
public int hashCode() {
boolean sensible = false;
int result = 0;
if (get(DocIDAnnotation.class) != null) {
result = get(DocIDAnnotation.class).hashCode();
sensible = true;
}
if (has(SentenceIndexAnnotation.class)) {
result = 29 * result + get(SentenceIndexAnnotation.class);
sensible = true;
}
if (has(IndexAnnotation.class)) {
result = 29 * result + get(IndexAnnotation.class);
sensible = true;
}
if ( ! sensible) {
System.err.println("WARNING!!! You have hashed an IndexedWord with no docID, sentIndex or wordIndex. You will almost certainly lose");
}
return result;
}
示例2: compareTo
import edu.stanford.nlp.ling.CoreAnnotations.DocIDAnnotation; //导入依赖的package包/类
/**
* NOTE: This compareTo is based on and made to be compatible with the one
* from IndexedFeatureLabel. You <em>must</em> have a DocIDAnnotation,
* SentenceIndexAnnotation, and IndexAnnotation for this to make sense and
* be guaranteed to work properly. Currently, it won't error out and will
* try to return something sensible if these are not defined, but that really
* isn't proper usage!
*
* This compareTo method is based not by value elements like the word(),
* but on passage position. It puts NO_WORD elements first, and then orders
* by document, sentence, and word index. If these do not differ, it
* returns equal.
*
* @param w The IndexedWord to compare with
* @return Whether this is less than w or not in the ordering
*/
public int compareTo(IndexedWord w) {
if (this.equals(IndexedWord.NO_WORD)) {
if (w.equals(IndexedWord.NO_WORD)) {
return 0;
} else {
return -1;
}
}
if (w.equals(IndexedWord.NO_WORD)) {
return 1;
}
String docID = this.getString(DocIDAnnotation.class);
int docComp = docID.compareTo(w.getString(DocIDAnnotation.class));
if (docComp != 0) return docComp;
int sentComp = sentIndex() - w.sentIndex();
if (sentComp != 0) return sentComp;
return index() - w.index();
}
示例3: equals
import edu.stanford.nlp.ling.CoreAnnotations.DocIDAnnotation; //导入依赖的package包/类
/**
* This .equals is dependent only on docID, sentenceIndex, and index.
* It doesn't consider the actual word value, but assumes that it is
* validly represented by token position.
* All IndexedWords that lack these fields will be regarded as equal.
*/
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof IndexedWord)) return false;
//now compare on appropriate keys
final IndexedWord otherWord = (IndexedWord) o;
String myDocID = getString(DocIDAnnotation.class);
String otherDocID = otherWord.getString(DocIDAnnotation.class);
if (myDocID == null) {
if (otherDocID != null)
return false;
} else if ( ! myDocID.equals(otherDocID)) {
return false;
}
Integer mySentInd = get(SentenceIndexAnnotation.class);
Integer otherSentInd = otherWord.get(SentenceIndexAnnotation.class);
if (mySentInd == null) {
if (otherSentInd != null)
return false;
} else if ( ! mySentInd.equals(otherSentInd)) {
return false;
}
Integer myInd = get(IndexAnnotation.class);
Integer otherInd = otherWord.get(IndexAnnotation.class);
if (myInd == null) {
if (otherInd != null)
return false;
} else if ( ! myInd.equals(otherInd)) {
return false;
}
return true;
}
示例4: docID
import edu.stanford.nlp.ling.CoreAnnotations.DocIDAnnotation; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public String docID() {
return get(DocIDAnnotation.class);
}
示例5: setDocID
import edu.stanford.nlp.ling.CoreAnnotations.DocIDAnnotation; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void setDocID(String docID) {
set(DocIDAnnotation.class, docID);
}
示例6: IndexedWord
import edu.stanford.nlp.ling.CoreAnnotations.DocIDAnnotation; //导入依赖的package包/类
/**
* Constructor for setting docID, sentenceIndex, and
* index without any other annotations.
*
* @param docID The document ID (arbitrary string)
* @param sentenceIndex The sentence number in the document (normally 0-based)
* @param index The index of the word in the sentence (normally 0-based)
*/
public IndexedWord(String docID, int sentenceIndex, int index) {
super();
this.set(DocIDAnnotation.class, docID);
this.set(SentenceIndexAnnotation.class, sentenceIndex);
this.set(IndexAnnotation.class, index);
}