/** * Creates a new multi-set based tree distance object. From the paper: Arnoldo Muller, Kouichi * Hirata and Takeshi Shinohara. A Tree Distance Function Based on Multi-sets. In ALSIP 2008 - * Osaka, Japan (to appear in LNCS). * * @param t A string representation of a tree. * @return * @throws RecognitionException * @throws TokenStreamException */ public static MTD createMTD(String t) throws RecognitionException, TokenStreamException { SliceLexer lexer = new SliceLexer(new StringReader(t)); SliceParser parser = new SliceParser(lexer); parser.setASTNodeClass(FTree.class.getCanonicalName()); parser.slice(); FTree s = (FTree) parser.getAST(); MTD m = new MTD(s); return m; }
/** * Creates a tree from a slice string definition * * @param x * @return */ protected static TreeIds createSliceAST(String x) throws RecognitionException, TokenStreamException { SliceLexer lexer = new SliceLexer(new StringReader(x)); SliceParser parser = new SliceParser(lexer); parser.setASTNodeClass(TreeIds.class.getCanonicalName()); parser.slice(); TreeIds s = (TreeIds) parser.getAST(); s.updateIdInfo(); s.updateContains(); return s; }
public static TreeForStandardTed createTreeForStandardTed(String x) throws RecognitionException, TokenStreamException { SliceLexer lexer = new SliceLexer(new StringReader(x)); SliceParser parser = new SliceParser(lexer); parser.setASTNodeClass(TreeForStandardTed.class.getCanonicalName()); parser.slice(); TreeForStandardTed s = (TreeForStandardTed) parser.getAST(); s.updateIdInfo(); s.updateContains(); return s; }
/** * creates the base clase of the ast. it is lighter * * @param x * @return * @throws RecognitionException * @throws TokenStreamException */ protected static Tree createSliceASTLean(String x) throws RecognitionException, TokenStreamException { SliceLexer lexer = new SliceLexer(new StringReader(x)); SliceParser parser = new SliceParser(lexer); parser.setASTNodeClass(Tree.class.getCanonicalName()); try { parser.slice(); } catch (RecognitionException e) { e.fileName = x + " " + e.fileName; throw e; } return (Tree) parser.getAST(); }