Package edu.stanford.nlp.ling

Examples of edu.stanford.nlp.ling.StringLabelFactory


   */
  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();
View Full Code Here


  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);
  }
View Full Code Here

    }
    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);
      }
    }
View Full Code Here

        Reader reader = new BufferedReader(new InputStreamReader(System.in, encoding));
        ((MemoryTreebank) treebank).load(reader);
        reader.close();
      } else if (args.length == 1) {
        errPW.println("using default tree");
        TreeReader r = new PennTreeReader(new StringReader("(VP (VP (VBZ Try) (NP (NP (DT this) (NN wine)) (CC and) (NP (DT these) (NNS snails)))) (PUNCT .))"), new LabeledScoredTreeFactory(new StringLabelFactory()));
        Tree t = r.readTree();
        treebank = new MemoryTreebank();
        treebank.add(t);
      } else {
        int last = args.length - 1;
View Full Code Here

    // 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() {
View Full Code Here

  public void testPositions() {
    try {
      // System.err.println();
      // System.err.println("One.");
      // check a tree loaded from a reader, using StringLabelFactory
      Tree tree = (new PennTreeReader(new StringReader("(S (NP (NNP Mary)) (VP (VBD had) (NP (DT a) (JJ little) (NN lamb))) (. .))"), new LabeledScoredTreeFactory(new StringLabelFactory()))).readTree();
      //System.out.println(tree.pennString());
      checkTree(tree);

      // System.err.println("Two.");
      // check a tree created using Tree.valueOf()
View Full Code Here

    }
    if (args.length < 1) {
      System.out.println("Usage: ParentAnnotationStats treebankPath");
    } else {
      SisterAnnotationStats pas = new SisterAnnotationStats();
      Treebank treebank = new DiskTreebank(in -> new PennTreeReader(in, new LabeledScoredTreeFactory(new StringLabelFactory()), new BobChrisTreeNormalizer()), encoding);
      treebank.loadPath(args[0]);
      treebank.apply(pas);
      pas.printStats();
    }
  }
View Full Code Here

          System.err.println("Unknown option: " + args[i]);
          i++;
        }
      }

      Treebank treebank = new DiskTreebank(in -> 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);
View Full Code Here

   * 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()));
  }
View Full Code Here

   */
  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);
View Full Code Here

TOP

Related Classes of edu.stanford.nlp.ling.StringLabelFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.