public static void main(String[] args) { TemplateManager tm = TemplateManager.getInstance(); TemplateTree root = new TemplateTree(tm.get("word[0]")); TemplateTree t2 = new TemplateTree(tm.get("pos[-1]")); root.addChild(t2); t2.addChild(new Features()); TemplateTree t3 = new TemplateTree(tm.get("pos[0]")); root.addChild(t3); t3.addChild(new Features()); TemplateTree t4 = new TemplateTree(tm.get("pos[-1]")); t2.addChild(t4); t4.addChild(new Features()); Document doc = DocumentTester.getMockDocument(); Context ctx = new Context(doc, 1); ctx.token = 2; root.apply(ctx); System.out.println(ctx); }