本文整理汇总了Java中edu.stanford.nlp.ling.StringLabelFactory类的典型用法代码示例。如果您正苦于以下问题:Java StringLabelFactory类的具体用法?Java StringLabelFactory怎么用?Java StringLabelFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringLabelFactory类属于edu.stanford.nlp.ling包,在下文中一共展示了StringLabelFactory类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import edu.stanford.nlp.ling.StringLabelFactory; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
TreeJPanel tjp = new TreeJPanel();
// String ptbTreeString1 = "(ROOT (S (NP (DT This)) (VP (VBZ is) (NP (DT a) (NN test))) (. .)))";
String ptbTreeString = "(ROOT (S (NP (NNP Interactive_Tregex)) (VP (VBZ works)) (PP (IN for) (PRP me)) (. !))))";
if (args.length > 0) {
ptbTreeString = args[0];
}
Tree tree = (new PennTreeReader(new StringReader(ptbTreeString), new LabeledScoredTreeFactory(new StringLabelFactory()))).readTree();
tjp.setTree(tree);
tjp.setBackground(Color.white);
JFrame frame = new JFrame();
frame.getContentPane().add(tjp, BorderLayout.CENTER);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.pack();
frame.setVisible(true);
frame.setVisible(true);
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:23,代码来源:TreeJPanel.java
示例2: main
import edu.stanford.nlp.ling.StringLabelFactory; //导入依赖的package包/类
/**
* This method just tests the functionality of the included transformers.
*/
public static void main(String[] args) {
//TreeFactory tf = new LabeledScoredTreeFactory();
Tree stringyTree = null;
try {
stringyTree = (new PennTreeReader(new StringReader("(S (VP (VBZ Try) (NP (DT this))) (. .))"), new LabeledScoredTreeFactory(new StringLabelFactory()))).readTree();
} catch (IOException e) {
}
System.out.println(stringyTree);
Function<Tree, Tree> a = getLabeledTreeToCategoryWordTagTreeFunction();
Tree adaptyTree = a.apply(stringyTree);
System.out.println(adaptyTree);
adaptyTree.percolateHeads(new CollinsHeadFinder());
System.out.println(adaptyTree);
Function<Tree, Tree> b = getLabeledTreeToStringLabeledTreeFunction();
Tree stringLabelTree = b.apply(adaptyTree);
System.out.println(stringLabelTree);
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:23,代码来源:TreeFunctions.java
示例3: main
import edu.stanford.nlp.ling.StringLabelFactory; //导入依赖的package包/类
/**
* This method just tests the functionality of the included transformers.
*/
public static void main(String[] args) {
//TreeFactory tf = new LabeledScoredTreeFactory();
Tree stringyTree = null;
try {
stringyTree = (new PennTreeReader(new StringReader("(S (VP (VBZ Try) (NP (DT this))) (. .))"), new LabeledScoredTreeFactory(new StringLabelFactory()))).readTree();
} catch (IOException e) {
// do nothing
}
System.out.println(stringyTree);
Function<Tree, Tree> a = getLabeledTreeToCategoryWordTagTreeFunction();
Tree adaptyTree = a.apply(stringyTree);
System.out.println(adaptyTree);
adaptyTree.percolateHeads(new CollinsHeadFinder());
System.out.println(adaptyTree);
Function<Tree, Tree> b = getLabeledTreeToStringLabeledTreeFunction();
Tree stringLabelTree = b.apply(adaptyTree);
System.out.println(stringLabelTree);
}
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:24,代码来源:TreeFunctions.java
示例4: main
import edu.stanford.nlp.ling.StringLabelFactory; //导入依赖的package包/类
/**
* Calculate sister annotation statistics suitable for doing
* selective sister splitting in the PCFGParser inside the
* FactoredParser.
*
* @param args One argument: path to the Treebank
*/
public static void main(String[] args) {
ClassicCounter<String> c = new ClassicCounter<String>();
c.setCount("A", 0);
c.setCount("B", 1);
double d = Counters.klDivergence(c, c);
System.out.println("KL Divergence: " + d);
String encoding = "UTF-8";
if (args.length > 1) {
encoding = args[1];
}
if (args.length < 1) {
System.out.println("Usage: ParentAnnotationStats treebankPath");
} else {
SisterAnnotationStats pas = new SisterAnnotationStats();
Treebank treebank = new DiskTreebank(new TreeReaderFactory() {
public TreeReader newTreeReader(Reader in) {
return new PennTreeReader(in, new LabeledScoredTreeFactory(new StringLabelFactory()), new BobChrisTreeNormalizer());
}
}, encoding);
treebank.loadPath(args[0]);
treebank.apply(pas);
pas.printStats();
}
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:36,代码来源:SisterAnnotationStats.java
示例5: main
import edu.stanford.nlp.ling.StringLabelFactory; //导入依赖的package包/类
/**
* Calculate parent annotation statistics suitable for doing
* selective parent splitting in the PCFGParser inside
* FactoredParser. <p>
* Usage: java edu.stanford.nlp.parser.lexparser.ParentAnnotationStats
* [-tags] treebankPath
*
* @param args One argument: path to the Treebank
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: java edu.stanford.nlp.parser.lexparser.ParentAnnotationStats [-tags] treebankPath");
} else {
int i = 0;
boolean useCutOff = false;
double cutOff = 0.0;
while (args[i].startsWith("-")) {
if (args[i].equals("-tags")) {
doTags = true;
i++;
} else if (args[i].equals("-cutOff") && i + 1 < args.length) {
useCutOff = true;
cutOff = Double.parseDouble(args[i + 1]);
i += 2;
} else {
System.err.println("Unknown option: " + args[i]);
i++;
}
}
Treebank treebank = new DiskTreebank(new TreeReaderFactory() {
public TreeReader newTreeReader(Reader in) {
return new PennTreeReader(in, new LabeledScoredTreeFactory(new StringLabelFactory()), new BobChrisTreeNormalizer());
}
});
treebank.loadPath(args[i]);
if (useCutOff) {
Set<String> splitters = getSplitCategories(treebank, doTags, 0, cutOff, cutOff, null);
System.out.println(splitters);
} else {
ParentAnnotationStats pas = new ParentAnnotationStats();
treebank.apply(pas);
pas.printStats();
}
}
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:48,代码来源:ParentAnnotationStats.java
示例6: newTreeReader
import edu.stanford.nlp.ling.StringLabelFactory; //导入依赖的package包/类
public TreeReader newTreeReader(Reader in) {
final TreeNormalizer tn1 = new GrammaticalFunctionTreeNormalizer(tlp, nodeCleanup);
final TueBaDZPennTreeNormalizer tn2 = new TueBaDZPennTreeNormalizer(tlp, nodeCleanup);
final TreeNormalizer norm = new OrderedCombinationTreeNormalizer(Arrays.asList(tn1, tn2));
return new PennTreeReader(in, new LabeledScoredTreeFactory(new StringLabelFactory()), norm);
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:8,代码来源:TueBaDZTreeReaderFactory.java
示例7: newTreeReader
import edu.stanford.nlp.ling.StringLabelFactory; //导入依赖的package包/类
/**
* Create a new <code>TreeReader</code> using the provided
* <code>Reader</code>.
*
* @param in The <code>Reader</code> to build on
* @return The new TreeReader
*/
public TreeReader newTreeReader(Reader in) {
if (discardFrags) {
return new FragDiscardingPennTreeReader(in, new LabeledScoredTreeFactory(new StringLabelFactory()), tn, new CHTBTokenizer(in));
} else {
return new PennTreeReader(in, new LabeledScoredTreeFactory(new StringLabelFactory()), tn, new CHTBTokenizer(in));
}
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:15,代码来源:CTBTreeReaderFactory.java
示例8: newTreeReader
import edu.stanford.nlp.ling.StringLabelFactory; //导入依赖的package包/类
public TreeReader newTreeReader(Reader in) {
final NegraPennTreeNormalizer tn = new NegraPennTreeNormalizer(tlp, nodeCleanup);
if (treeNormalizerInsertNPinPP) {
tn.setInsertNPinPP(true);
}
return new PennTreeReader(in, new LabeledScoredTreeFactory(new StringLabelFactory()), tn, new NegraPennTokenizer(in));
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:9,代码来源:NegraPennTreeReaderFactory.java
示例9: main
import edu.stanford.nlp.ling.StringLabelFactory; //导入依赖的package包/类
/**
* Calculate parent annotation statistics suitable for doing
* selective parent splitting in the PCFGParser inside
* FactoredParser. <p>
* Usage: java edu.stanford.nlp.parser.lexparser.ParentAnnotationStats
* [-tags] treebankPath
*
* @param args One argument: path to the Treebank
*/
public static void main(String[] args) {
boolean doTags = false;
if (args.length < 1) {
System.out.println("Usage: java edu.stanford.nlp.parser.lexparser.ParentAnnotationStats [-tags] treebankPath");
} else {
int i = 0;
boolean useCutOff = false;
double cutOff = 0.0;
while (args[i].startsWith("-")) {
if (args[i].equals("-tags")) {
doTags = true;
i++;
} else if (args[i].equals("-cutOff") && i + 1 < args.length) {
useCutOff = true;
cutOff = Double.parseDouble(args[i + 1]);
i += 2;
} else {
System.err.println("Unknown option: " + args[i]);
i++;
}
}
Treebank treebank = new DiskTreebank(new TreeReaderFactory() {
public TreeReader newTreeReader(Reader in) {
return new PennTreeReader(in, new LabeledScoredTreeFactory(new StringLabelFactory()), new BobChrisTreeNormalizer());
}
});
treebank.loadPath(args[i]);
if (useCutOff) {
Set<String> splitters = getSplitCategories(treebank, doTags, 0, cutOff, cutOff, null);
System.out.println(splitters);
} else {
ParentAnnotationStats pas = new ParentAnnotationStats(null, doTags);
treebank.apply(pas);
pas.printStats();
}
}
}
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:49,代码来源:ParentAnnotationStats.java
示例10: Debinarizer
import edu.stanford.nlp.ling.StringLabelFactory; //导入依赖的package包/类
public Debinarizer(boolean forceCNF) {
this(forceCNF, new StringLabelFactory());
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:4,代码来源:Debinarizer.java
示例11: transformTree
import edu.stanford.nlp.ling.StringLabelFactory; //导入依赖的package包/类
/** The tree t is normally expected to be a Penn-Treebank-style tree
* in which the top node is an extra node that rewrites unarily.
* If this isn't the case, an extra node is added and the user is
* warned.
*/
public Tree transformTree(Tree t) {
if (Train.printTreeTransformations > 0) {
Train.printTrainTree(null, "ORIGINAL TREE:", t);
}
Tree trTree = annotator.transformTree(t);
if (Train.selectivePostSplit) {
trTree = postSplitter.transformTree(trTree);
}
if (Train.printTreeTransformations > 0) {
Train.printTrainTree(Train.printAnnotatedPW, "ANNOTATED TREE:", trTree);
}
if (Train.printAnnotatedRuleCounts) {
Tree tr2 = trTree.deeperCopy(new LabeledScoredTreeFactory(), new StringLabelFactory());
Set<Tree> localTrees = tr2.localTrees();
for (Tree tr : localTrees) {
annotatedRuleCounts.incrementCount(tr);
}
}
if (Train.printAnnotatedStateCounts) {
for (Tree subt : trTree) {
if ( ! subt.isLeaf()) {
annotatedStateCounts.incrementCount(subt.label().value());
}
}
}
// if we add the ROOT first, then we don't know how to percolate the heads at the top
addRoot(trTree); // this creates a few non-binarized rules at the top
Tree binarizedTree = binarizer.transformTree(trTree);
if (Train.printTreeTransformations > 0) {
Train.printTrainTree(Train.printBinarizedPW, "BINARIZED TREE:", binarizedTree);
Train.printTreeTransformations--;
}
if (forceCNF) {
binarizedTree = new CNFTransformers.ToCNFTransformer().transformTree(binarizedTree);
// System.out.println("BinarizedCNF:\n");
// binarizedTree.pennPrint();
}
return binarizedTree;
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:48,代码来源:TreeAnnotatorAndBinarizer.java
示例12: newTreeReader
import edu.stanford.nlp.ling.StringLabelFactory; //导入依赖的package包/类
public TreeReader newTreeReader(Reader in) {
return new PennTreeReader(new BufferedReader(in), new LabeledScoredTreeFactory(new StringLabelFactory()), tn);
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:4,代码来源:TregexPattern.java
示例13: transformTree
import edu.stanford.nlp.ling.StringLabelFactory; //导入依赖的package包/类
/** The tree t is normally expected to be a Penn-Treebank-style tree
* in which the top node is an extra node that rewrites unarily.
* If this isn't the case, an extra node is added and the user is
* warned.
*/
public Tree transformTree(Tree t) {
if (trainOptions.printTreeTransformations > 0) {
trainOptions.printTrainTree(null, "ORIGINAL TREE:", t);
}
Tree trTree = annotator.transformTree(t);
if (trainOptions.selectivePostSplit) {
trTree = postSplitter.transformTree(trTree);
}
if (trainOptions.printTreeTransformations > 0) {
trainOptions.printTrainTree(trainOptions.printAnnotatedPW, "ANNOTATED TREE:", trTree);
}
if (trainOptions.printAnnotatedRuleCounts) {
Tree tr2 = trTree.deepCopy(new LabeledScoredTreeFactory(), new StringLabelFactory());
Set<Tree> localTrees = tr2.localTrees();
for (Tree tr : localTrees) {
annotatedRuleCounts.incrementCount(tr);
}
}
if (trainOptions.printAnnotatedStateCounts) {
for (Tree subt : trTree) {
if ( ! subt.isLeaf()) {
annotatedStateCounts.incrementCount(subt.label().value());
}
}
}
// if we add the ROOT first, then we don't know how to percolate the heads at the top
addRoot(trTree); // this creates a few non-binarized rules at the top
Tree binarizedTree = binarizer.transformTree(trTree);
if (trainOptions.printTreeTransformations > 0) {
trainOptions.printTrainTree(trainOptions.printBinarizedPW, "BINARIZED TREE:", binarizedTree);
trainOptions.printTreeTransformations--;
}
if (forceCNF) {
binarizedTree = new CNFTransformers.ToCNFTransformer().transformTree(binarizedTree);
// System.out.println("BinarizedCNF:\n");
// binarizedTree.pennPrint();
}
return binarizedTree;
}
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:48,代码来源:TreeAnnotatorAndBinarizer.java
示例14: newTreeReader
import edu.stanford.nlp.ling.StringLabelFactory; //导入依赖的package包/类
/**
* An implementation of the <code>TreeReaderFactory</code> interface.
* It creates a simple <code>TreeReader</code> which literally
* reproduces trees in the treebank as <code>LabeledScoredTree</code>
* objects, with <code>StringLabel</code> labels.
*/
public TreeReader newTreeReader(Reader in) {
return new PennTreeReader(in, new LabeledScoredTreeFactory(new StringLabelFactory()));
}
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:10,代码来源:StringLabeledScoredTreeReaderFactory.java
注:本文中的edu.stanford.nlp.ling.StringLabelFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论