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


Java CyclicCoreLabel類代碼示例

本文整理匯總了Java中edu.stanford.nlp.ling.CyclicCoreLabel的典型用法代碼示例。如果您正苦於以下問題:Java CyclicCoreLabel類的具體用法?Java CyclicCoreLabel怎麽用?Java CyclicCoreLabel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CyclicCoreLabel類屬於edu.stanford.nlp.ling包,在下文中一共展示了CyclicCoreLabel類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: arcLabelsToNode

import edu.stanford.nlp.ling.CyclicCoreLabel; //導入依賴的package包/類
/**
 * Finds all arcs between this node and <code>destNode</code>,
 * and returns the <code>Set</code> of <code>Object</code>s which
 * label those arcs.  If no such arcs exist, returns an empty
 * <code>Set</code>.
 *
 * @param destNode the destination node
 * @return the <code>Set</code> of <code>Object</code>s which
 *         label arcs between this node and <code>destNode</code>
 */
public Set<Class<? extends GrammaticalRelationAnnotation>> arcLabelsToNode(TreeGraphNode destNode) {
  Set<Class<? extends GrammaticalRelationAnnotation>> arcLabels = Generics.newHashSet();
  CyclicCoreLabel cl = label();
  for (Iterator<Class<?>> it = cl.keySet().iterator(); it.hasNext();) {
    Class<? extends CoreAnnotation> key = (Class<? extends CoreAnnotation>) it.next();//javac doesn't compile properly if generics are fully specified (but eclipse does...)
    Object val = cl.get(key);
    if (val != null && val instanceof Set) {
      if (((Set) val).contains(destNode)) {
        if (key != null) {
          arcLabels.add((Class<? extends GrammaticalRelationAnnotation>) key);
        }
      }
    }
  }
  return arcLabels;
}
 
開發者ID:FabianFriedrich,項目名稱:Text2Process,代碼行數:27,代碼來源:TreeGraphNode.java

示例2: TreeGraphNode

import edu.stanford.nlp.ling.CyclicCoreLabel; //導入依賴的package包/類
/**
 * Create a new <code>TreeGraphNode</code> having the same tree
 * structure and label values as an existing tree (but no shared
 * storage).  Operates recursively to construct an entire
 * subtree.
 *
 * @param t      the tree to copy
 * @param parent the parent node
 */
protected TreeGraphNode(Tree t, TreeGraphNode parent) {
  this.parent = parent;
  Tree[] tKids = t.children();
  int numKids = tKids.length;
  children = new TreeGraphNode[numKids];
  for (int i = 0; i < numKids; i++) {
    children[i] = new TreeGraphNode(tKids[i], this);
    if (t.isPreTerminal()) { // add the tags to the leaves
      children[i].label.setTag(t.label().value());
    }
  }
  this.label = (CyclicCoreLabel) mlf.newLabel(t.label());
}
 
開發者ID:FabianFriedrich,項目名稱:Text2Process,代碼行數:23,代碼來源:TreeGraphNode.java

示例3: getSpan

import edu.stanford.nlp.ling.CyclicCoreLabel; //導入依賴的package包/類
public IntPair getSpan() {
  return ((CyclicCoreLabel) label()).get(SpanAnnotation.class);
}
 
開發者ID:FabianFriedrich,項目名稱:Text2Process,代碼行數:4,代碼來源:Tree.java

示例4: mapDependencies

import edu.stanford.nlp.ling.CyclicCoreLabel; //導入依賴的package包/類
/**
 * Return a set of Label-Label dependencies, represented as
 * Dependency objects, for the Tree.  The Labels are the ones of the leaf
 * nodes of the tree, without mucking with them. The head of the sentence is a
 * dependent of a synthetic "root" label.
 *
 * @param f  Dependencies are excluded for which the Dependency is not
 *           accepted by the Filter
 * @param hf The HeadFinder to use to identify the head of constituents.
 *           The code assumes
 *           that it can use <code>headPreTerminal(hf)</code> to find a
 *           tag and word to make a CyclicCoreLabel.
 * @param    rootName Name of the root node.
 * @return   Set of dependencies (each a <code>Dependency</code> between two
 *           <code>CyclicCoreLabel</code>s, which each contain a tag(), word(),
 *           and value(), the last two of which are identical).
 */
public Set<Dependency<Label, Label, Object>> mapDependencies(Filter<Dependency<Label, Label, Object>> f, HeadFinder hf, String rootName) {
  Set<Dependency<Label, Label, Object>> deps = mapDependencies(f, hf);
  if(rootName != null) {
    Label hl = headTerminal(hf).label();
    CyclicCoreLabel rl = new CyclicCoreLabel();
    rl.set(WordAnnotation.class, rootName);
    rl.set(IndexAnnotation.class, 0);
    deps.add(new NamedDependency(rl, hl, rootName));
  }
  return deps;
}
 
開發者ID:FabianFriedrich,項目名稱:Text2Process,代碼行數:29,代碼來源:Tree.java

示例5: treeFactory

import edu.stanford.nlp.ling.CyclicCoreLabel; //導入依賴的package包/類
/**
 * Returns a <code>TreeFactory</code> that produces
 * <code>TreeGraphNode</code>s.  The <code>Label</code> of
 * <code>this</code> is examined, and providing it is not
 * <code>null</code>, a <code>LabelFactory</code> which will
 * produce that kind of <code>Label</code> is supplied to the
 * <code>TreeFactory</code>.  If the <code>Label</code> is
 * <code>null</code>, a
 * <code>CyclicCoreLabel.factory()</code> will be used.  The factories
 * returned on different calls are different: a new one is
 * allocated each time.
 *
 * @return a factory to produce treegraphs
 */
@Override
public TreeFactory treeFactory() {
  LabelFactory lf;
  if (label() != null) {
    lf = label().labelFactory();
  } else {
    lf = CyclicCoreLabel.factory();
  }
  return new TreeGraphNodeFactory(lf);
}
 
開發者ID:FabianFriedrich,項目名稱:Text2Process,代碼行數:25,代碼來源:TreeGraphNode.java

示例6: TreeGraphNodeFactory

import edu.stanford.nlp.ling.CyclicCoreLabel; //導入依賴的package包/類
/**
 * Make a <code>TreeFactory</code> that produces
 * <code>TreeGraphNode</code>s.  The labels are of class
 * <code>CyclicCoreLabel</code>.
 */
public TreeGraphNodeFactory() {
  this(CyclicCoreLabel.factory());
}
 
開發者ID:FabianFriedrich,項目名稱:Text2Process,代碼行數:9,代碼來源:TreeGraphNodeFactory.java

示例7: label

import edu.stanford.nlp.ling.CyclicCoreLabel; //導入依賴的package包/類
/**
 * Returns the label associated with the current node, or null
 * if there is no label.
 *
 * @return the label of the node
 */
@Override
public CyclicCoreLabel label() {
  return label;
}
 
開發者ID:FabianFriedrich,項目名稱:Text2Process,代碼行數:11,代碼來源:TreeGraphNode.java

示例8: setLabel

import edu.stanford.nlp.ling.CyclicCoreLabel; //導入依賴的package包/類
/**
 * Sets the label associated with the current node.
 *
 * @param label the new label to use.
 */
public void setLabel(final CyclicCoreLabel label) {
  this.label = label;
}
 
開發者ID:FabianFriedrich,項目名稱:Text2Process,代碼行數:9,代碼來源:TreeGraphNode.java


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