@Test public void canCreateChildren() throws DependencyParseException { String stringTree = "Test_NNP\n" + "\tdet _DT\n" + "\tprep of_IN"; DependencyTree parsed = DependencyTreeParser.readFromString(stringTree); assertNotNull(parsed); DependencyNode root = parsed.getRoot(); assertEquals("NNP", root.getType()); assertEquals("Test", root.getContent()); assertEquals(2, parsed.getDependencies().size()); DependencyEdge det = parsed.getDependencies("det").iterator().next(); assertEquals("DT", det.getTree().getRoot().getType()); assertEquals("", det.getTree().getRoot().getContent()); assertEquals(0, det.getTree().getDependencies().size()); DependencyEdge prep = parsed.getDependencies("prep").iterator().next(); assertEquals("IN", prep.getTree().getRoot().getType()); assertEquals("of", prep.getTree().getRoot().getContent()); assertEquals(0, prep.getTree().getDependencies().size()); }
public static DependencyTree readFromString(String text) throws DependencyParseException { try (ByteArrayInputStream is = new ByteArrayInputStream(text.getBytes())) { return readFromStream(is); } catch (IOException e) { throw new RuntimeException("NO io to error, should not be thrown", e); } }
DependencyTreeParser { public static DependencyTree readFromString(String text) throws DependencyParseException { try (ByteArrayInputStream is = new ByteArrayInputStream(text.getBytes())) { return readFromStream(is); } catch (IOException e) { throw new RuntimeException("NO io to error, should not be thrown", e); } } }
DependencyTreeParser { public static DependencyTree readFromString(String text) throws DependencyParseException { try (ByteArrayInputStream is = new ByteArrayInputStream(text.getBytes())) { return readFromStream(is); } catch (IOException e) { throw new RuntimeException("NO io to error, should not be thrown", e); } }  }
DependencyTreeParser { public static DependencyTree readFromString(String text) throws DependencyParseException { try (ByteArrayInputStream is = new ByteArrayInputStream(text.getBytes())) { return readFromStream(is); } catch (IOException e) { throw new RuntimeException("NO io to error, should not be thrown", e); } }  static DependencyTree readFromString(String text); static DependencyTree readFromFile(String file); static DependencyTree readFromStream(InputStream is); }
DependencyTreeParser { public static DependencyTree readFromString(String text) throws DependencyParseException { try (ByteArrayInputStream is = new ByteArrayInputStream(text.getBytes())) { return readFromStream(is); } catch (IOException e) { throw new RuntimeException("NO io to error, should not be thrown", e); } }  static DependencyTree readFromString(String text); static DependencyTree readFromFile(String file); static DependencyTree readFromStream(InputStream is);  }