MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / pruneOverlappingWords

Function pruneOverlappingWords

cy/cy.ts:186–197  ·  view source on GitHub ↗
(entries: Array<[string, number]>)

Source from the content-addressed store, hash-verified

184}
185
186function pruneOverlappingWords(entries: Array<[string, number]>): Array<[string, number]> {
187 return entries.filter(([word, count]) => {
188 if (word.length <= 1) return false;
189 return !entries.some(([other, otherCount]) => {
190 if (other === word) return false;
191 if (other.length <= word.length) return false;
192 if (!other.includes(word)) return false;
193 // 如果短词只是更长词里的碎片,并且频次没有明显更强,就丢掉。
194 return otherCount >= count * 0.9;
195 });
196 });
197}
198
199function collectWords(text: string, counts: Map<string, number>): void {
200 const cleaned = text

Callers 1

buildWordItemsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected