@Test public void canCopeWithDifferentSpacing() throws DependencyParseException { String stringTree = "Root_NNP\n" + " child1 1_NN\n" + " subChild 1.1_IN\n" + " child2 2_NN\n" + " subChild 2.1_DT\n" + " subChild 2.2f_IN"; DependencyTree parsed = DependencyTreeParser.readFromString(stringTree); assertNotNull(parsed); assertEquals(2, parsed.getDependencies().size()); DependencyEdge child1 = parsed.getDependencies("child1").iterator().next(); assertEquals(1, child1.getTree().getDependencies().size()); DependencyEdge child2 = parsed.getDependencies("child2").iterator().next(); assertEquals(2, child2.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);  }