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();
}
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();
}
}
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();
}
}
Aggregations