ROSE  0.11.96.11
Classes | Typedefs | Enumerations | Functions
Rose::EditDistance::TreeEditDistance Namespace Reference

Description

Analysis to determine how to make one AST look like another.

Actually editing one tree have the same shape as another is, in many cases, nonsensical but the edit distance metric is nonetheless useful to determine the similarity of two trees. See Analysis::compute for details about how this analysis is implemented.

The way the analysis is used is like this:

using namespace Rose::EditDistance;
SgNode *ast1 = ...; // The first subtree
SgNode *ast2 = ...; // Second subtree
TreeEditDistance::Analysis ted; // Object for performing the analysis
ted.substitutionCost(0.0); // Adjust some parameters
ted.compute(ast1, ast2); // Run the analysis
double cost = ted.cost(); // Query some results

Or in one expression:

double cost = TreeEditDistance::Analysis() .substitutionCost(0.0) .compute(ast1, ast2) .cost();

The analysis object can be reused as many times as one likes by calling its compute method with different trees. The query methods always return the same results until the next call to compute.

Classes

class  Analysis
 Analysis object for tree edit distance. More...
 
struct  Edit
 A single edit operation. More...
 
class  SubstitutionPredicate
 Base class for substitution prediates. More...
 

Typedefs

typedef std::vector< EditEdits
 List of edit operations.
 

Enumerations

enum  EditType {
  INSERT,
  DELETE,
  SUBSTITUTE
}
 Type of edit operation. More...
 

Functions

std::ostream & operator<< (std::ostream &, const TreeEditDistance::Edit &)
 

Enumeration Type Documentation

◆ EditType

Type of edit operation.

Enumerator
INSERT 

Insert a node from another tree.

DELETE 

Delete a node from this tree.

SUBSTITUTE 

Substitute a node; same as an insert-delete pair.

Definition at line 60 of file TreeEditDistance.h.

Rose::EditDistance::TreeEditDistance::Analysis
Analysis object for tree edit distance.
Definition: TreeEditDistance.h:95
Rose::EditDistance
Edit distance algorithms and analyses.
Definition: DamerauLevenshtein.h:7
Rose::EditDistance::TreeEditDistance::Analysis::compute
Analysis & compute(SgNode *source, SgNode *target, SgFile *sourceFile=NULL, SgFile *targetFile=NULL)
Compute tree edit distances.
Rose::EditDistance::TreeEditDistance::Analysis::substitutionCost
double substitutionCost() const
Property: substitution cost.
Definition: TreeEditDistance.h:173
Rose::EditDistance::TreeEditDistance::Analysis::cost
double cost() const
Total cost for making one tree the same shape as the other.
SgNode
This class represents the base class for all IR nodes within Sage III.
Definition: Cxx_Grammar.h:6739