MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / computeNonFriendScores

Function computeNonFriendScores

packages/core/src/query/contact-scoring.ts:195–221  ·  view source on GitHub ↗
(
  items: readonly T[]
)

Source from the content-addressed store, hash-verified

193}
194
195export function computeNonFriendScores<T extends NonFriendScoreInput>(
196 items: readonly T[]
197): Map<T, ContactScoringResult> {
198 const coOccurrenceScores = rankPercentiles(items, (item) => nonNegative(item.coOccurrenceRawScore))
199 const groupScores = rankPercentiles(items, (item) => nonNegative(item.commonGroupCount))
200 const replyScores = rankPercentiles(items, (item) => nonNegative(item.replyInteractionCount))
201 const result = new Map<T, ContactScoringResult>()
202
203 for (const item of items) {
204 result.set(
205 item,
206 computeNonFriendScore({
207 coOccurrenceScore: coOccurrenceScores.get(item) ?? 0,
208 commonGroupScore: groupScores.get(item) ?? 0,
209 replyInteractionScore: replyScores.get(item) ?? 0,
210 commonGroupCount: nonNegative(item.commonGroupCount),
211 coOccurrenceCount: nonNegative(item.coOccurrenceCount),
212 coOccurrenceRawScore: nonNegative(item.coOccurrenceRawScore),
213 replyInteractionCount: nonNegative(item.replyInteractionCount),
214 repliesFromOwnerToContact: nonNegative(item.repliesFromOwnerToContact),
215 repliesFromContactToOwner: nonNegative(item.repliesFromContactToOwner),
216 })
217 )
218 }
219
220 return result
221}

Callers 3

buildContactItemsFunction · 0.90

Calls 5

rankPercentilesFunction · 0.85
nonNegativeFunction · 0.85
computeNonFriendScoreFunction · 0.85
setMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected