本文整理汇总了Java中edu.stanford.nlp.ling.CategoryWordTag类的典型用法代码示例。如果您正苦于以下问题:Java CategoryWordTag类的具体用法?Java CategoryWordTag怎么用?Java CategoryWordTag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CategoryWordTag类属于edu.stanford.nlp.ling包,在下文中一共展示了CategoryWordTag类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import edu.stanford.nlp.ling.CategoryWordTag; //导入依赖的package包/类
public static void main(String[] args) {
CategoryWordTag.printWordTag = false;
String path = args[0];
List<Tree> trees = TreebankAnnotator.getTrees(path, 200, 219, 0, 10);
List<Tree> annotatedTrees = new TreebankAnnotator(new Options(), path).annotateTrees(trees);
for (Tree tree : annotatedTrees) {
System.out.println("ORIGINAL:\n");
tree.pennPrint();
System.out.println("CNFed:\n");
Tree cnfTree = new ToCNFTransformer().transformTree(tree);
cnfTree.pennPrint();
System.out.println("UnCNFed:\n");
Tree unCNFTree = new FromCNFTransformer().transformTree(cnfTree);
unCNFTree.pennPrint();
System.out.println("\n\n");
}
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:18,代码来源:CNFTransformers.java
示例2: printTrainTree
import edu.stanford.nlp.ling.CategoryWordTag; //导入依赖的package包/类
public static void printTrainTree(PrintWriter pw, String message, Tree t) {
PrintWriter myPW;
if (pw == null) {
myPW = new PrintWriter(System.out, true);
} else {
myPW = pw;
}
if (message != null && pw == null) {
// hard coded to not print message if using file output!
myPW.println(message);
}
boolean previousState = CategoryWordTag.printWordTag;
CategoryWordTag.printWordTag = false;
t.pennPrint(myPW);
CategoryWordTag.printWordTag = previousState;
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:17,代码来源:Train.java
示例3: printTrainTree
import edu.stanford.nlp.ling.CategoryWordTag; //导入依赖的package包/类
public static void printTrainTree(PrintWriter pw, String message, Tree t) {
PrintWriter myPW;
if (pw == null) {
myPW = new PrintWriter(System.out, true);
} else {
myPW = pw;
}
if (message != null && pw == null) {
// hard coded to not print message if using file output!
myPW.println(message);
}
// TODO FIXME: wtf is this shit
boolean previousState = CategoryWordTag.printWordTag;
CategoryWordTag.printWordTag = false;
t.pennPrint(myPW);
CategoryWordTag.printWordTag = previousState;
}
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:18,代码来源:TrainOptions.java
示例4: printTrainTree
import edu.stanford.nlp.ling.CategoryWordTag; //导入依赖的package包/类
public static void printTrainTree(PrintWriter pw, String message, Tree t) {
PrintWriter myPW;
if (pw == null) {
myPW = new PrintWriter(System.out, true);
} else {
myPW = pw;
}
if (message != null && pw == null) {
// hard coded to not print message if using file output!
logger.trace(message);
}
// TODO FIXME: wtf is this shit
boolean previousState = CategoryWordTag.printWordTag;
CategoryWordTag.printWordTag = false;
t.pennPrint(myPW);
CategoryWordTag.printWordTag = previousState;
}
开发者ID:chbrown,项目名称:stanford-parser,代码行数:18,代码来源:TrainOptions.java
示例5: transformTree
import edu.stanford.nlp.ling.CategoryWordTag; //导入依赖的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;
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:34,代码来源:AbstractTreebankParserParams.java
示例6: main
import edu.stanford.nlp.ling.CategoryWordTag; //导入依赖的package包/类
public static void main(String[] args) {
CategoryWordTag.printWordTag = false;
String path = args[0];
List<Tree> trees = getTrees(path, 200, 219, 0, 10);
trees.iterator().next().pennPrint();
Options op = new Options();
List<Tree> annotatedTrees = TreebankAnnotator.removeDependencyRoots(new TreebankAnnotator(op, path).annotateTrees(trees));
annotatedTrees.iterator().next().pennPrint();
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:10,代码来源:TreebankAnnotator.java
示例7: addRoot
import edu.stanford.nlp.ling.CategoryWordTag; //导入依赖的package包/类
/**
* Changes the ROOT label, and adds a Lexicon.BOUNDARY daughter to it.
* This is needed for the dependency parser.
* <i>Note:</i> This is a destructive operation on the tree passed in!!
*
* @param t The current tree into which a boundary is inserted
*/
public void addRoot(Tree t) {
if (t.isLeaf()) {
System.err.println("Warning: tree is leaf: " + t);
t = tf.newTreeNode(tlp.startSymbol(), Collections.singletonList(t));
}
t.setLabel(new CategoryWordTag(tlp.startSymbol(), Lexicon.BOUNDARY, Lexicon.BOUNDARY_TAG));
List<Tree> preTermChildList = new ArrayList<Tree>();
Tree boundaryTerm = tf.newLeaf(new StringLabel(Lexicon.BOUNDARY));//CategoryWordTag(Lexicon.BOUNDARY,Lexicon.BOUNDARY,""));
preTermChildList.add(boundaryTerm);
Tree boundaryPreTerm = tf.newTreeNode(new CategoryWordTag(Lexicon.BOUNDARY_TAG, Lexicon.BOUNDARY, Lexicon.BOUNDARY_TAG), preTermChildList);
List<Tree> childList = t.getChildrenAsList();
childList.add(boundaryPreTerm);
t.setChildren(childList);
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:22,代码来源:TreeAnnotatorAndBinarizer.java
示例8: main
import edu.stanford.nlp.ling.CategoryWordTag; //导入依赖的package包/类
/**
* Go through trees and determine their heads and print them.
* Just for debuggin'. <br>
* Usage: <code>
* java edu.stanford.nlp.trees.CollinsHeadFinder treebankFilePath
* </code>
*
* @param args The treebankFilePath
*/
public static void main(String[] args) {
Treebank treebank = new DiskTreebank();
CategoryWordTag.suppressTerminalDetails = true;
treebank.loadPath(args[0]);
final HeadFinder chf = new CollinsHeadFinder();
treebank.apply(new TreeVisitor() {
public void visitTree(Tree pt) {
pt.percolateHeads(chf);
pt.pennPrint();
System.out.println();
}
});
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:23,代码来源:CollinsHeadFinder.java
示例9: transformTree
import edu.stanford.nlp.ling.CategoryWordTag; //导入依赖的package包/类
@Override
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;
}
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:35,代码来源:AbstractTreebankParserParams.java
示例10: addRoot
import edu.stanford.nlp.ling.CategoryWordTag; //导入依赖的package包/类
/**
* Changes the ROOT label, and adds a Lexicon.BOUNDARY daughter to it.
* This is needed for the dependency parser.
* <i>Note:</i> This is a destructive operation on the tree passed in!!
*
* @param t The current tree into which a boundary is inserted
*/
public void addRoot(Tree t) {
if (t.isLeaf()) {
System.err.println("Warning: tree is leaf: " + t);
t = tf.newTreeNode(tlp.startSymbol(), Collections.singletonList(t));
}
t.setLabel(new CategoryWordTag(tlp.startSymbol(), Lexicon.BOUNDARY, Lexicon.BOUNDARY_TAG));
List<Tree> preTermChildList = new ArrayList<Tree>();
Tree boundaryTerm = tf.newLeaf(new Word(Lexicon.BOUNDARY));//CategoryWordTag(Lexicon.BOUNDARY,Lexicon.BOUNDARY,""));
preTermChildList.add(boundaryTerm);
Tree boundaryPreTerm = tf.newTreeNode(new CategoryWordTag(Lexicon.BOUNDARY_TAG, Lexicon.BOUNDARY, Lexicon.BOUNDARY_TAG), preTermChildList);
List<Tree> childList = t.getChildrenAsList();
childList.add(boundaryPreTerm);
t.setChildren(childList);
}
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:22,代码来源:TreeAnnotatorAndBinarizer.java
示例11: main
import edu.stanford.nlp.ling.CategoryWordTag; //导入依赖的package包/类
/**
* Go through trees and determine their heads and print them.
* Just for debuggin'. <br>
* Usage: <code>
* java edu.stanford.nlp.trees.CollinsHeadFinder treebankFilePath
* </code>
*
* @param args The treebankFilePath
*/
public static void main(String[] args) {
Treebank treebank = new DiskTreebank();
CategoryWordTag.suppressTerminalDetails = true;
treebank.loadPath(args[0]);
final HeadFinder chf = new CollinsHeadFinder();
treebank.apply(new TreeVisitor() {
@Override
public void visitTree(Tree pt) {
pt.percolateHeads(chf);
pt.pennPrint();
System.out.println();
}
});
}
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:24,代码来源:CollinsHeadFinder.java
示例12: main
import edu.stanford.nlp.ling.CategoryWordTag; //导入依赖的package包/类
/**
* Go through trees and determine their heads and print them.
* Just for debugging. <br>
* Usage: <code>
* java edu.stanford.nlp.trees.DybroFrenchHeadFinder treebankFilePath
* </code>
*
* @param args The treebankFilePath
*/
public static void main(String[] args) {
Treebank treebank = new DiskTreebank();
CategoryWordTag.suppressTerminalDetails = true;
treebank.loadPath(args[0]);
final HeadFinder chf = new DybroFrenchHeadFinder();
treebank.apply(new TreeVisitor() {
public void visitTree(Tree pt) {
pt.percolateHeads(chf);
pt.pennPrint();
System.out.println();
}
});
}
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:23,代码来源:DybroFrenchHeadFinder.java
示例13: main
import edu.stanford.nlp.ling.CategoryWordTag; //导入依赖的package包/类
/**
* Go through trees and determine their heads and print them.
* Just for debugging. <br>
* Usage: <code>
* java edu.stanford.nlp.trees.FrenchHeadFinder treebankFilePath
* </code>
*
* @param args The treebankFilePath
*/
public static void main(String[] args) {
Treebank treebank = new DiskTreebank();
CategoryWordTag.suppressTerminalDetails = true;
treebank.loadPath(args[0]);
final HeadFinder chf = new FrenchHeadFinder();
treebank.apply(new TreeVisitor() {
public void visitTree(Tree pt) {
pt.percolateHeads(chf);
pt.pennPrint();
System.out.println();
}
});
}
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:23,代码来源:FrenchHeadFinder.java
示例14: main
import edu.stanford.nlp.ling.CategoryWordTag; //导入依赖的package包/类
public static void main(String[] args) {
// simple testing code
Treebank treebank = new DiskTreebank();
CategoryWordTag.suppressTerminalDetails = true;
treebank.loadPath(args[0]);
final HeadFinder chf = new NoPunctuationHeadFinder();
treebank.apply(new TreeVisitor() {
public void visitTree(Tree pt) {
pt.percolateHeads(chf);
pt.pennPrint();
System.out.println();
}
});
}
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:15,代码来源:NoPunctuationHeadFinder.java
注:本文中的edu.stanford.nlp.ling.CategoryWordTag类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论