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

Function buildWordItems

cy/cy.ts:228–247  ·  view source on GitHub ↗
(counts: Map<string, number>)

Source from the content-addressed store, hash-verified

226 }
227}
228
229function buildWordItems(counts: Map<string, number>): WordItem[] {
230 const entries = pruneOverlappingWords([...counts.entries()])
231 .filter(([, count]) => count >= 2)
232 .sort((a, b) => b[1] - a[1])
233 .slice(0, 220);
234 if (!entries.length) return [];
235 const max = entries[0][1];
236 const min = entries[entries.length - 1][1];
237 const spread = Math.max(1, max - min);
238 return entries.map(([word, count], index) => {
239 const ratio = (count - min) / spread;
240 const size = Math.round(12 + Math.pow(ratio, 0.7) * 68);
241 return {
242 word,
243 count,
244 size,
245 color: PALETTE[index % PALETTE.length],
246 };
247 });
248}
249
250function overlaps(a: WordItem, placed: WordItem[]): boolean {

Callers 1

buildCloudImageFunction · 0.85

Calls 1

pruneOverlappingWordsFunction · 0.85

Tested by

no test coverage detected