@Test public void canCreateTreeWithIds() throws DependencyParseException { String stringTree = "Root_NNP\n" + "\tchild1 1_NN:child1\n" + "\t\tsubChild 1.1_IN\n" + "\tchild2 2_NN\n" + "\t\tsubChild 2.1_DT:child2.1\n" + "\t\tsubChild 2.2f_IN"; DependencyTree parsed = DependencyTreeParser.readFromString(stringTree); assertNotNull(parsed); assertTrue(parsed.getNode("child1").isPresent()); assertTrue(parsed.getNode("child2.1").isPresent()); assertFalse(parsed.getNode("missing").isPresent()); }
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);  }