Function
setSimilarity
(left: ReadonlySet<string>, right: ReadonlySet<string>)
Source from the content-addressed store, hash-verified
| 58 | } |
| 59 | |
| 60 | const setSimilarity = (left: ReadonlySet<string>, right: ReadonlySet<string>): number => { |
| 61 | if (left.size === 0 && right.size === 0) { |
| 62 | return 1 |
| 63 | } |
| 64 | let shared = 0 |
| 65 | for (const value of left) { |
| 66 | if (right.has(value)) { |
| 67 | shared++ |
| 68 | } |
| 69 | } |
| 70 | return shared / (left.size + right.size - shared) |
| 71 | } |
| 72 | |
| 73 | const documentationTokenCache = new WeakMap<ApiEntity, ReadonlySet<string>>() |
| 74 | |
Tested by
no test coverage detected