本文整理汇总了Java中edu.stanford.nlp.ling.LabelFactory.newLabel方法的典型用法代码示例。如果您正苦于以下问题:Java LabelFactory.newLabel方法的具体用法?Java LabelFactory.newLabel怎么用?Java LabelFactory.newLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.ling.LabelFactory
的用法示例。
在下文中一共展示了LabelFactory.newLabel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deepCopy
import edu.stanford.nlp.ling.LabelFactory; //导入方法依赖的package包/类
/**
* Makes a deep copy of not only the Tree structure but of the labels as well.
* Each tree is copied with the given TreeFactory.
* Each Label is copied using the given LabelFactory.
* That is, the tree and label factories can transform the nature of the
* data representation.
*
* @param tf The TreeFactory used to make all nodes in the copied
* tree structure
* @param lf The LabelFactory used to make all nodes in the copied
* tree structure
* @return A Tree that is a deep copy of the tree structure and
* Labels of the original tree.
*/
@SuppressWarnings({"unchecked"})
public Tree deepCopy(TreeFactory tf, LabelFactory lf) {
Label label = lf.newLabel(label());
if (isLeaf()) {
return tf.newLeaf(label);
}
Tree[] kids = children();
// NB: The below list may not be of type Tree but TreeGraphNode, so we leave it untyped
List newKids = new ArrayList(kids.length);
for (Tree kid : kids) {
newKids.add(kid.deepCopy(tf, lf));
}
return tf.newTreeNode(label, newKids);
}
示例2: deeperCopy
import edu.stanford.nlp.ling.LabelFactory; //导入方法依赖的package包/类
/**
* Same as deepCopy but will copy the labels over as well.
* Each tree is copied with the given TreeFactory.
* Each Label is copied using the given LabelFactory.
*
* @param tf The TreeFactory used to make all nodes in the copied
* tree structure
* @param lf The LabelFactory used to make all nodes in the copied
* tree structure
* @return A Tree that is a deep copy of the tree structure and
* Labels of the original tree.
*/
public Tree deeperCopy(TreeFactory tf, LabelFactory lf) {
Label label = lf.newLabel(label());
if (isLeaf()) {
return tf.newLeaf(label);
}
Tree[] kids = children();
// NB: The below list may not be of type Tree but TreeGraphNode, so we leave it untyped
List newKids = new ArrayList(kids.length);
for (Tree kid : kids) {
newKids.add(kid.deeperCopy(tf, lf));
}
return tf.newTreeNode(label, newKids);
}