/** * Simple tree reading utility method. Given a tree formatted as a PTB string, returns a Tree made by a specific TreeFactory. */ public static Tree readTree(String ptbTreeString, TreeFactory treeFactory) { try { PennTreeReader ptr = new PennTreeReader(new StringReader(ptbTreeString), treeFactory); return ptr.readTree(); } catch (IOException ex) { throw new RuntimeException(ex); } }
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); }
/** * 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); }
return (E) new PennTreeReader(new StringReader(value), new LabeledScoredTreeFactory(CoreLabel.factory())).readTree(); } catch (IOException e) { throw new RuntimeException(e);
public static void main(String[] args) throws IOException { int i = 0; while (i < args.length) { Tree tree = Tree.valueOf(args[i]); if (tree == null) { // maybe it was a filename tree = Tree.valueOf(IOUtils.slurpFile(args[i])); } if (tree != null) { System.out.println(escape(texTree(tree))); } i++; } if (i == 0) { Tree tree = (new PennTreeReader(new BufferedReader(new InputStreamReader(System.in)), new LabeledScoredTreeFactory(new StringLabelFactory()))).readTree(); System.out.println(escape(texTree(tree))); } }
Tree tree = new PennTreeReader(new StringReader(line), new LabeledScoredTreeFactory(CoreLabel.factory())).readTree(); sentence.set(TreeCoreAnnotations.TreeAnnotation.class, tree);
/** * Simple tree reading utility method. Given a tree formatted as a PTB string, returns a Tree made by a specific TreeFactory. */ public static Tree readTree(String ptbTreeString, TreeFactory treeFactory) { try { PennTreeReader ptr = new PennTreeReader(new StringReader(ptbTreeString), treeFactory); return ptr.readTree(); } catch (IOException ex) { throw new RuntimeException(ex); } }
/** * Simple tree reading utility method. Given a tree formatted as a PTB string, returns a Tree made by a specific TreeFactory. */ public static Tree readTree(String ptbTreeString, TreeFactory treeFactory) { try { PennTreeReader ptr = new PennTreeReader(new StringReader(ptbTreeString), treeFactory); return ptr.readTree(); } catch (IOException ex) { throw new RuntimeException(ex); } }
/** * Simple tree reading utility method. Given a tree formatted as a PTB string, returns a Tree made by a specific TreeFactory. */ public static Tree readTree(String ptbTreeString, TreeFactory treeFactory) { try { PennTreeReader ptr = new PennTreeReader(new StringReader(ptbTreeString), treeFactory); return ptr.readTree(); } catch (IOException ex) { throw new RuntimeException(ex); } }
/** * Simple tree reading utility method. Given a tree formatted as a PTB string, returns a Tree made by a specific TreeFactory. */ public static Tree readTree(String ptbTreeString, TreeFactory treeFactory) { try { PennTreeReader ptr = new PennTreeReader(new StringReader(ptbTreeString), treeFactory); return ptr.readTree(); } catch (IOException ex) { throw new RuntimeException(ex); } }
public static void main(String[] args) throws IOException { int i = 0; while (i < args.length) { Tree tree = Tree.valueOf(args[i]); System.out.println(escape(texTree(tree))); i++; } if (i == 0) { Tree tree = (new PennTreeReader(new BufferedReader(new InputStreamReader(System.in)), new LabeledScoredTreeFactory(new StringLabelFactory()))).readTree(); System.out.println(escape(texTree(tree))); } }
/** * 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); }
public static void main(String[] args) throws IOException { int i = 0; while (i < args.length) { Tree tree = Tree.valueOf(args[i]); if (tree == null) { // maybe it was a filename tree = Tree.valueOf(IOUtils.slurpFile(args[i])); } if (tree != null) { System.out.println(escape(texTree(tree))); } i++; } if (i == 0) { Tree tree = (new PennTreeReader(new BufferedReader(new InputStreamReader(System.in)), new LabeledScoredTreeFactory(new StringLabelFactory()))).readTree(); System.out.println(escape(texTree(tree))); } }
public static void main(String[] args) throws IOException { int i = 0; while (i < args.length) { Tree tree = Tree.valueOf(args[i]); if (tree == null) { // maybe it was a filename tree = Tree.valueOf(IOUtils.slurpFile(args[i])); } if (tree != null) { System.out.println(escape(texTree(tree))); } i++; } if (i == 0) { Tree tree = (new PennTreeReader(new BufferedReader(new InputStreamReader(System.in)), new LabeledScoredTreeFactory(new StringLabelFactory()))).readTree(); System.out.println(escape(texTree(tree))); } }
public static void main(String[] args) throws IOException { int i = 0; while (i < args.length) { Tree tree = Tree.valueOf(args[i]); if (tree == null) { // maybe it was a filename tree = Tree.valueOf(IOUtils.slurpFile(args[i])); } if (tree != null) { System.out.println(escape(texTree(tree))); } i++; } if (i == 0) { Tree tree = (new PennTreeReader(new BufferedReader(new InputStreamReader(System.in)), new LabeledScoredTreeFactory(new StringLabelFactory()))).readTree(); System.out.println(escape(texTree(tree))); } }