Documentation
¶
Index ¶
- func LevenshteinDistance(s1, s2 string) int
- func NormalizeTokenSequence(function *ast.Function) []string
- func TokenSequenceSimilarity(func1, func2 *ast.Function) float64
- func TreeEditDistance(node1, node2 goast.Node) int
- type Detector
- func (d *Detector) CalculateSimilarity(func1, func2 *ast.Function) float64
- func (d *Detector) FindSimilarFunctions(functions []*ast.Function) []Match
- func (d *Detector) FindSimilarFunctionsWithProcessor(processor ParallelProcessor, functions []*ast.Function, ...) ([]Match, error)
- func (d *Detector) IsAboveThreshold(similarity float64) bool
- type Match
- type ParallelProcessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LevenshteinDistance ¶
LevenshteinDistance calculates the Levenshtein distance between two strings.
func NormalizeTokenSequence ¶
NormalizeTokenSequence extracts a normalized token sequence from a function.
func TokenSequenceSimilarity ¶
TokenSequenceSimilarity calculates similarity between two functions based on token sequences.
func TreeEditDistance ¶
TreeEditDistance calculates the edit distance between two AST nodes. This implements a simplified tree edit distance algorithm.
Types ¶
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector handles similarity detection between functions.
func NewDetector ¶
NewDetector creates a new similarity detector with the given threshold and configuration.
func NewDetectorWithConfig ¶
NewDetectorWithConfig creates a new similarity detector with explicit configuration.
func (*Detector) CalculateSimilarity ¶
CalculateSimilarity calculates the similarity between two functions Returns a value between 0.0 (completely different) and 1.0 (identical).
func (*Detector) FindSimilarFunctions ¶
FindSimilarFunctions finds all similar function pairs above the threshold.
func (*Detector) FindSimilarFunctionsWithProcessor ¶
func (d *Detector) FindSimilarFunctionsWithProcessor( processor ParallelProcessor, functions []*ast.Function, progressCallback func(completed, total int), ) ([]Match, error)
FindSimilarFunctionsWithProcessor finds similar functions using a provided parallel processor.
func (*Detector) IsAboveThreshold ¶
IsAboveThreshold checks if similarity is above the configured threshold.