本文整理汇总了Java中edu.stanford.nlp.ling.Label.value方法的典型用法代码示例。如果您正苦于以下问题:Java Label.value方法的具体用法?Java Label.value怎么用?Java Label.value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.ling.Label
的用法示例。
在下文中一共展示了Label.value方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transformTree
import edu.stanford.nlp.ling.Label; //导入方法依赖的package包/类
public Tree transformTree(Tree tree) {
Label lab = tree.label();
if (tree.isLeaf()) {
Tree leaf = tf.newLeaf(lab);
leaf.setScore(tree.score());
return leaf;
}
String s = lab.value();
s = treebankLanguagePack().basicCategory(s);
int numKids = tree.numChildren();
List<Tree> children = new ArrayList<Tree>(numKids);
for (int cNum = 0; cNum < numKids; cNum++) {
Tree child = tree.getChild(cNum);
Tree newChild = transformTree(child);
// cdm 2007: for just subcategory stripping, null shouldn't happen
// if (newChild != null) {
children.add(newChild);
// }
}
// if (children.isEmpty()) {
// return null;
// }
CategoryWordTag newLabel = new CategoryWordTag(lab);
newLabel.setCategory(s);
if (lab instanceof HasTag) {
String tag = ((HasTag) lab).tag();
tag = treebankLanguagePack().basicCategory(tag);
newLabel.setTag(tag);
}
Tree node = tf.newTreeNode(newLabel, children);
node.setScore(tree.score());
return node;
}
示例2: accept
import edu.stanford.nlp.ling.Label; //导入方法依赖的package包/类
/** Doesn't accept nodes that only cover an empty. */
public boolean accept(Tree t) {
Tree[] kids = t.children();
Label l = t.label();
if ((l != null) && l.value() != null && // there appears to be a mistake in CTB3 where the label "-NONE-1" is used once
// presumably it should be "-NONE-" and be spliced out here.
(l.value().matches("-NONE-.*")) && !t.isLeaf() && kids.length == 1 && kids[0].isLeaf()) {
// Delete empty/trace nodes (ones marked '-NONE-')
if ( ! l.value().equals("-NONE-")) {
EncodingPrintWriter.err.println("Deleting errant node " + l.value() + " as if -NONE-: " + t, ChineseTreebankLanguagePack.ENCODING);
}
return false;
}
return true;
}
示例3: newLabel
import edu.stanford.nlp.ling.Label; //导入方法依赖的package包/类
/**
* Iff oldLabel is a NegraLabel, copy it.
*/
public Label newLabel(Label oldLabel) {
NegraLabel result;
if(oldLabel instanceof NegraLabel) {
NegraLabel l = (NegraLabel) oldLabel;
result = new NegraLabel(l.value(), l.getEdge(), new HashMap<String,String>());
for (Map.Entry<String,String> e : l.features.entrySet()) {
result.features.put(e.getKey(), e.getValue());
}
} else {
result = new NegraLabel(oldLabel.value());
}
return result;
}
示例4: value
import edu.stanford.nlp.ling.Label; //导入方法依赖的package包/类
public String value() {
Label lab = label();
if (lab == null) {
return null;
}
return lab.value();
}
示例5: value
import edu.stanford.nlp.ling.Label; //导入方法依赖的package包/类
/**
* Return the value of the label (or null if none).
*
* @return String the value for the label
*/
public String value() {
Label lab = label();
if (lab == null) {
return null;
}
return lab.value();
}
示例6: percolateHeads
import edu.stanford.nlp.ling.Label; //导入方法依赖的package包/类
/**
* Finds the heads of the tree. This code assumes that the label
* does store and return sensible values for the category, word, and tag.
* It will be a no-op otherwise. The tree is modified. The routine
* assumes the Tree has word leaves and tag preterminals, and copies
* their category to word and tag respectively, if they have a null
* value.
*
* @param hf The headfinding algorithm to use
*/
public void percolateHeads(HeadFinder hf) {
Label cwt = label();
if (isLeaf()) {
if (cwt instanceof HasWord) {
HasWord w = (HasWord) cwt;
if (w.word() == null) {
w.setWord(cwt.value());
}
}
} else {
Tree[] kids = children();
for (int i = 0; i < kids.length; i++) {
kids[i].percolateHeads(hf);
}
Tree head = hf.determineHead(this);
if (head != null) {
Label headCwt = head.label();
String headTag = null;
if (headCwt instanceof HasTag) {
headTag = ((HasTag) headCwt).tag();
}
if (headTag == null && head.isLeaf()) {
// below us is a leaf
headTag = cwt.value();
}
String headWord = null;
if (headCwt instanceof HasWord) {
headWord = ((HasWord) headCwt).word();
}
if (headWord == null && head.isLeaf()) {
// below us is a leaf
// this might be useful despite case for leaf above in
// case the leaf label type doesn't support word()
headWord = headCwt.value();
}
if (cwt instanceof HasWord) {
((HasWord) cwt).setWord(headWord);
}
if (cwt instanceof HasTag) {
((HasTag) cwt).setTag(headTag);
}
} else {
System.err.println("Head is null: " + this);
}
}
}
示例7: hasVerbalAuxiliary
import edu.stanford.nlp.ling.Label; //导入方法依赖的package包/类
private boolean hasVerbalAuxiliary(Tree[] kids, HashSet<String> verbalSet) {
if (DEBUG) {
System.err.println("Checking for verbal auxiliary");
}
for (Tree kid : kids) {
Label kidLabel = kid.label();
String cat = tlp.basicCategory(kidLabel.value());
if (barriers.contains(cat)) {
// don't find auxiliary within these categories
continue;
}
String word = null;
if (kidLabel instanceof HasWord) {
word = ((HasWord) kidLabel).word();
}
if (word == null) {
Label htl = kid.headTerminal(this).label();
if (htl instanceof HasWord) {
word = ((HasWord) htl).word();
}
if (word == null) {
word = htl.value();
}
}
String tag = null;
if (kidLabel instanceof HasTag) {
tag = ((HasTag) kidLabel).tag();
}
if (tag == null) {
tag = kid.headPreTerminal(this).value();
}
if (DEBUG) {
System.err.println("Checking " + kid.value() + " head is " + word + '/' + tag);
}
String lcWord = word.toLowerCase();
// got to not match on to/TO if in PP!
if (verbalTags.contains(tag) && verbalSet.contains(lcWord)) {
if (DEBUG) {
System.err.println("hasVerbalAuxiliary returns true");
}
return true;
}
}
if (DEBUG) {
System.err.println("hasVerbalAuxiliary returns false");
}
return false;
}