Search in sources :

Example 21 with TreeReaderFactory

use of edu.stanford.nlp.trees.TreeReaderFactory in project CoreNLP by stanfordnlp.

the class FilePanel method clearAll.

/**
   * Removes all files from the panel
   */
public void clearAll() {
    //Preserve the current TRF when we refresh the tree file list
    TreeReaderFactory oldTrf = treeModel.getTRF();
    FileTreeNode root = new FileTreeNode();
    treeModel = new FileTreeModel(root);
    setTreeReaderFactory(oldTrf);
    tree.setModel(treeModel);
    this.revalidate();
    this.repaint();
}
Also used : TreeReaderFactory(edu.stanford.nlp.trees.TreeReaderFactory)

Example 22 with TreeReaderFactory

use of edu.stanford.nlp.trees.TreeReaderFactory in project CoreNLP by stanfordnlp.

the class NegraPennTreeReaderFactory method main.

/**
   *
   * @param args File to run on
   */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.printf("Usage: java %s tree_file%n", NegraPennTreeReaderFactory.class.getName());
        return;
    }
    TreebankLanguagePack tlp = new NegraPennLanguagePack();
    TreeReaderFactory trf = new NegraPennTreeReaderFactory(2, false, false, tlp);
    try {
        TreeReader tr = trf.newTreeReader(IOUtils.readerFromString(args[0], tlp.getEncoding()));
        for (Tree t; (t = tr.readTree()) != null; ) {
            t.pennPrint();
        }
        tr.close();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : TreeReader(edu.stanford.nlp.trees.TreeReader) PennTreeReader(edu.stanford.nlp.trees.PennTreeReader) Tree(edu.stanford.nlp.trees.Tree) TreebankLanguagePack(edu.stanford.nlp.trees.TreebankLanguagePack) TreeReaderFactory(edu.stanford.nlp.trees.TreeReaderFactory)

Example 23 with TreeReaderFactory

use of edu.stanford.nlp.trees.TreeReaderFactory in project CoreNLP by stanfordnlp.

the class HebrewTreeReaderFactory method main.

/**
   * @param args
   */
public static void main(String[] args) {
    if (args.length != 1) {
        System.err.printf("Usage: java %s tree_file > trees%n", HebrewTreeReaderFactory.class.getName());
        System.exit(-1);
    }
    TreebankLanguagePack tlp = new HebrewTreebankLanguagePack();
    File treeFile = new File(args[0]);
    try {
        TreeReaderFactory trf = new HebrewTreeReaderFactory();
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(treeFile), tlp.getEncoding()));
        TreeReader tr = trf.newTreeReader(br);
        int numTrees = 0;
        for (Tree t; ((t = tr.readTree()) != null); numTrees++) System.out.println(t.toString());
        tr.close();
        System.err.printf("Processed %d trees.%n", numTrees);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : TreeReader(edu.stanford.nlp.trees.TreeReader) PennTreeReader(edu.stanford.nlp.trees.PennTreeReader) Tree(edu.stanford.nlp.trees.Tree) TreebankLanguagePack(edu.stanford.nlp.trees.TreebankLanguagePack) TreeReaderFactory(edu.stanford.nlp.trees.TreeReaderFactory)

Aggregations

TreeReaderFactory (edu.stanford.nlp.trees.TreeReaderFactory)23 Tree (edu.stanford.nlp.trees.Tree)20 TreeReader (edu.stanford.nlp.trees.TreeReader)17 FrenchTreeReaderFactory (edu.stanford.nlp.trees.international.french.FrenchTreeReaderFactory)7 FileInputStream (java.io.FileInputStream)7 InputStreamReader (java.io.InputStreamReader)7 BufferedReader (java.io.BufferedReader)6 IOException (java.io.IOException)6 FileNotFoundException (java.io.FileNotFoundException)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)5 CoreLabel (edu.stanford.nlp.ling.CoreLabel)4 ArabicTreeReaderFactory (edu.stanford.nlp.trees.international.arabic.ArabicTreeReaderFactory)4 TwoDimensionalCounter (edu.stanford.nlp.stats.TwoDimensionalCounter)3 LabeledScoredTreeReaderFactory (edu.stanford.nlp.trees.LabeledScoredTreeReaderFactory)3 TreeTransformer (edu.stanford.nlp.trees.TreeTransformer)3 TreebankLanguagePack (edu.stanford.nlp.trees.TreebankLanguagePack)3 FrenchXMLTreeReader (edu.stanford.nlp.trees.international.french.FrenchXMLTreeReader)3 SpanishTreeReaderFactory (edu.stanford.nlp.trees.international.spanish.SpanishTreeReaderFactory)3 Label (edu.stanford.nlp.ling.Label)2 PennTreeReader (edu.stanford.nlp.trees.PennTreeReader)2