當前位置: 首頁>>代碼示例>>Java>>正文


Java DocIDAnnotation類代碼示例

本文整理匯總了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;
}
 
開發者ID:amark-india,項目名稱:eventspotter,代碼行數:26,代碼來源:IndexedWord.java

示例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();
}
 
開發者ID:amark-india,項目名稱:eventspotter,代碼行數:38,代碼來源:IndexedWord.java

示例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;
}
 
開發者ID:amark-india,項目名稱:eventspotter,代碼行數:40,代碼來源:IndexedWord.java

示例4: docID

import edu.stanford.nlp.ling.CoreAnnotations.DocIDAnnotation; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
public String docID() {
  return get(DocIDAnnotation.class);
}
 
開發者ID:FabianFriedrich,項目名稱:Text2Process,代碼行數:7,代碼來源:CoreLabel.java

示例5: setDocID

import edu.stanford.nlp.ling.CoreAnnotations.DocIDAnnotation; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
public void setDocID(String docID) {
  set(DocIDAnnotation.class, docID);
}
 
開發者ID:FabianFriedrich,項目名稱:Text2Process,代碼行數:7,代碼來源:CoreLabel.java

示例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);
}
 
開發者ID:amark-india,項目名稱:eventspotter,代碼行數:15,代碼來源:IndexedWord.java


注:本文中的edu.stanford.nlp.ling.CoreAnnotations.DocIDAnnotation類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。