Skip to content

Commit

Permalink
update jaccard comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nickoferrall committed Feb 12, 2025
1 parent fab482d commit d697028
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/**
* Example: computeJaccardDistanceMatrix(reflections)
* For each pair of reflections, measure how many words they share
* vs. how many unique words total. (Jaccard similarity = intersection/union).
* We then use distance = 1 - similarity and feed that to clusterfck.
Expand Down Expand Up @@ -28,7 +27,7 @@ const jaccardDistance = (aTokens: string[], bTokens: string[]): number => {
const setB = new Set(bTokens)
const intersectionSize = [...setA].filter((x) => setB.has(x)).length
const unionSize = new Set([...setA, ...setB]).size
if (unionSize === 0) return 0 // edge case, treat empty union as identical
if (unionSize === 0) return 0 // edge case, treat empty union as identical although reflections should always have text
const similarity = intersectionSize / unionSize
const distance = 1 - similarity
return distance
Expand Down
1 change: 0 additions & 1 deletion packages/client/utils/smartGroup/groupReflections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const groupReflections = <
groupingOptions: GroupingOptions
) => {
const reflectionTexts = reflections.map((r) => r.plaintextContent || '')

const distanceMatrix = computeJaccardDistanceMatrix(reflectionTexts)

const {
Expand Down

0 comments on commit d697028

Please sign in to comment.