Skip to content

Commit

Permalink
fix: editdistthreshold
Browse files Browse the repository at this point in the history
  • Loading branch information
sshivaditya committed Oct 1, 2024
1 parent 3721f0f commit ac2eae6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/adapters/supabase/helpers/issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,22 @@ export class Issues extends SuperSupabase {
query_embedding: embedding,
threshold: threshold,
});

if (error) {
this.context.logger.error("Error finding similar issues", error);
return [];
}
//Calculate the edit distance between the query and the similar issues

const similarIssues: string[] = data.map((issue: IssueSimilaritySearchResult) => issue.issue_plaintext);

// Calculate the maximum edit distance based on the length of the input markdown
const maxLength = markdown.length;
const editDistanceThreshold = maxLength * (1 - threshold); // Convert similarity threshold to edit distance threshold

// Calculate edit distances
const editDistances = similarIssues.map((issue) => this.calculateEditDistance(markdown, issue));
//Filter out the issues that are below the threshold
return data.filter((index: number) => editDistances[index] <= threshold);

// Filter out the issues that are above the edit distance threshold
return data.filter((index: number) => editDistances[index] <= editDistanceThreshold);
}
}

0 comments on commit ac2eae6

Please sign in to comment.