Summary
Add an n-gram extractor at app/api/routes-f/n-grams/route.ts. Extract n-grams of any size with frequency counts.
Requirements
- POST body { text, n: number, level?: word|char, lowercase?, top? }
- Return { ngrams: [{ gram, count }], total_grams, unique_grams }
- Default level word, top 50
- Validate n in [1, 10]
- Cap input at 1MB
- Tests cover word vs char modes, varied n, frequency ordering
Scope Constraint - READ BEFORE STARTING
All files for this task must live inside app/api/routes-f/. This includes the route handler, helpers/utilities, types, and tests. Do NOT modify, import from, or add files to lib/, utils/, types/, components/, or anywhere else outside app/api/routes-f/. If you need shared logic, duplicate it inside your subfolder. Keeping everything scoped to this folder is intentional - it keeps these tasks independent and mergeable in any order.
Summary
Add an n-gram extractor at app/api/routes-f/n-grams/route.ts. Extract n-grams of any size with frequency counts.
Requirements
Scope Constraint - READ BEFORE STARTING
All files for this task must live inside app/api/routes-f/. This includes the route handler, helpers/utilities, types, and tests. Do NOT modify, import from, or add files to lib/, utils/, types/, components/, or anywhere else outside app/api/routes-f/. If you need shared logic, duplicate it inside your subfolder. Keeping everything scoped to this folder is intentional - it keeps these tasks independent and mergeable in any order.