{
  "schema": "leumas.docs.page/1",
  "id": "adapter:domain/text-classifier",
  "slug": "adapters/domain/text-classifier",
  "kind": "capabilities",
  "bucket": "package",
  "title": "text-classifier — text classification + labeling microservice",
  "name": "text-classifier",
  "eyebrow": "text classification + labeling microservice",
  "chip": null,
  "summary": "Text classification and labeling microservice: assign the best label to a piece of text from a caller-supplied label set, detect conversational intent, extract topics, and identify language. Tools...",
  "keywords": [
    "text-classifier",
    "labeling",
    "praise",
    "farewell",
    "salient",
    "text classifier api",
    "zeroshot",
    "conversational"
  ],
  "audience": "both",
  "funnel": {
    "product": null,
    "cta": null
  },
  "body": "# text-classifier — text classification + labeling microservice\n\nAssign the best label to text from a caller-supplied label set, detect conversational intent, extract\ntopics, do zero-shot labeling, suggest tags, and identify language. A paid \"intelligent microservice\":\nevery tool has a deterministic bag-of-words / cosine / trigram core that runs **fully offline**;\n`classify` and `zeroShot` additionally enrich with an LLM when reachable and silently fall back.\nResults carry `{ mode: 'heuristic' | 'llm' }`.\n\n## Tools\n\n| Tool | Args | Returns |\n|---|---|---|\n| `classify` | `{ text, labels, options?:{threshold,multiLabel} }` | best `label` + ranked `scores` (softmax probs). `labels` = array \\| comma-string \\| `{label:[keywords]}` map (supervised, stronger). |\n| `intent` | `{ text }` | `intent` ∈ question/request/complaint/praise/greeting/farewell/statement, `confidence`, per-intent `scores`. |\n| `topics` | `{ text, top? }` | salient `topics` (phrases + terms) and top `terms` with counts. |\n| `zeroShot` | `{ text, labels, hypothesis?, options? }` | zero-shot `best` label + `scores` against arbitrary labels with an NL hypothesis template (`{}` placeholder). |\n| `tag` | `{ text, top? }` | suggested keyword `tags` + `hashtags`. |\n| `language` | `{ text }` | `language` code + `name` + `confidence` via character-trigram profile (en/es/fr/de/it/pt/nl/sv/pl/la). |\n\n## Usage\n\n```js\nimport pack from './index.js';\nawait pack.adapters.classify({ text: 'my payment failed again', labels: ['billing', 'shipping', 'account'] });\nawait pack.adapters.classify({ text: 'reset my password', labels: { auth: ['password', 'login', 'reset'], billing: ['invoice', 'charge'] } });\npack.adapters.intent({ text: 'Could you please refund my order?' });\npack.adapters.topics({ text: 'machine learning models train on large datasets ...' });\npack.adapters.language({ text: 'Bonjour, comment allez-vous aujourd\\'hui?' });\n```\n\nEvery tool takes ONE args object (maps 1:1 onto an HTTP POST body). Bad input throws `TypeError`.\n\n## Hybrid intelligence\n\nSet `OPENAI_BASE_URL`+`OPENAI_API_KEY` or run a local Ollama to enable the AI path on `classify` and\n`zeroShot`. With no model the heuristic core is used. A down model never throws.\n\n## DRY boundary\n\n- `nlp` owns generic corpus stats (sentiment, RAKE keywords, ngrams, readability, **stopword-based**\n  language, word frequency). text-classifier is the **classification workflow**: map text → a caller's\n  label set, intent, topics, zero-shot, tags, and **trigram** language ID (deliberately a different\n  method than `nlp.languageDetect`).\n- `embeddings` owns real vector cosine over learned vectors; here cosine is over surface term/trigram\n  bags, self-contained.\n\nPure ESM, Node built-ins only, zero npm deps (only `../_shared/llm.js` for the optional AI path).\n",
  "source": {
    "path": "shared/engines/adapters/domain/text-classifier/README.md",
    "blobSha": "",
    "commit": "",
    "committedAt": "",
    "provenance": "no-git",
    "bytes": 3020,
    "hash": "f26954eda89e37ca3229bbe42aa4ce0cd8ea76dc"
  },
  "urls": {
    "html": "/p/adapters/domain/text-classifier",
    "json": "/docs/adapters/domain/text-classifier.json",
    "md": "/docs/adapters/domain/text-classifier.md"
  },
  "links": {
    "composes": [],
    "usedBy": [],
    "product": [],
    "howTo": [],
    "skills": []
  }
}
