mirror of
https://github.com/ChiChou/entdb.git
synced 2026-06-10 23:07:47 +02:00
5e30a8b930
- Move filter controls into sticky header via React portal - Responsive layout: wraps to 2 rows on mobile, single row on desktop - Keys/Files nav shows icons only on mobile, icons+text on larger screens - Add tokenizer that extracts frequent terms from entitlement keys - Display clickable token pills for quick filtering (apple, security, etc.) - Move item counts below header, above lists - Fix light mode contrast (darken muted-foreground) - Reduce homepage spacing
35 lines
1003 B
TypeScript
35 lines
1003 B
TypeScript
export function tokenizeKeys(keys: string[]): Map<string, number> {
|
|
const freq = new Map<string, number>();
|
|
|
|
for (const key of keys) {
|
|
// Split by dots, dashes, underscores
|
|
const parts = key.split(/[.\-_]/);
|
|
|
|
for (const part of parts) {
|
|
// Further split camelCase: "AppBundles" -> ["App", "Bundles"]
|
|
const camelParts = part.split(/(?=[A-Z])/).filter((p) => p.length > 0);
|
|
|
|
for (const token of camelParts) {
|
|
const lower = token.toLowerCase();
|
|
// Skip very short or numeric tokens
|
|
if (lower.length < 3 || /^\d+$/.test(lower)) continue;
|
|
freq.set(lower, (freq.get(lower) || 0) + 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
return freq;
|
|
}
|
|
|
|
export function getTopTokens(
|
|
freq: Map<string, number>,
|
|
limit = 20,
|
|
minCount = 5
|
|
): Array<{ token: string; count: number }> {
|
|
return Array.from(freq.entries())
|
|
.filter(([, count]) => count >= minCount)
|
|
.sort((a, b) => b[1] - a[1])
|
|
.slice(0, limit)
|
|
.map(([token, count]) => ({ token, count }));
|
|
}
|