当前位置: 首页>>代码示例>>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;未经允许,请勿转载。