# review-analyzer

Customer-review intelligence microservice: turn product/app/restaurant/hotel reviews into structured insight. analyze extracts sentiment, a 1-5 star estimate, pros, cons and per-aspect opinions from...


Customer-review intelligence microservice. Turns product / app / restaurant / hotel reviews into
structured insight: sentiment, a 1-5 star estimate, pros/cons, per-aspect opinion mining, theme
clustering across many reviews, and fake-review detection.

Every tool has a deterministic heuristic core (opinion lexicon with negation + intensifier handling,
aspect-based opinion mining) that runs fully **offline** with no model. `analyze`, `summary` and
`themes` also try an optional LLM (via `../_shared/llm.js`) and silently fall back to the heuristic —
results are tagged `{ mode: 'heuristic' | 'llm' }`. A missing/down model never throws.

## Tools

| Tool | Input | Returns |
|---|---|---|
| `analyze` | `{ review }` | `{ sentiment, polarity, rating, stars, pros, cons, aspects, confidence }` |
| `aspects` | `{ review, feature }` | sentiment toward one named feature (e.g. `battery`, `shipping`) |
| `summary` | `{ review }` | `{ headline, tldr, rating, keywords, topPro, topCon }` |
| `starEstimate` | `{ review }` | `{ stars, rating, distribution, confidence }` |
| `themes` | `{ reviews: [..] }` | top recurring themes with quotes, praised/criticized lists, keywords |
| `spamLikelihood` | `{ review }` | `{ spamLikelihood, label, isSuspicious, flags }` |

## Usage

```js
import pack from './index.js';

await pack.adapters.analyze({ review: 'Battery life is amazing but the app crashes constantly.' });
// -> { sentiment:'positive'|... , rating, pros:[...], cons:[...], aspects:[{aspect:'reliability',sentiment:'negative'},...] }

pack.adapters.aspects({ review: 'Shipping was super fast, packaging was flimsy.', feature: 'shipping' });
// -> { feature:'shipping', sentiment:'positive', score, evidence:[...] }

await pack.adapters.themes({ reviews: ['Great value!', 'Broke after a week', 'Support was rude'] });
// -> { topThemes:[...], praised:[...], criticized:[...], avgEstimatedRating }
```

Options: `{ topN, minMentions, maxQuotes, useLlm:false }` (pass `useLlm:false` to force the offline
core and skip the network call).

## DRY boundaries

- Generic tokenize / bag-of-words / readability of arbitrary prose lives in **`nlp`** / **`a-text`**;
  general keyword extraction in **`seo`**. This pack owns **review-domain** modeling only: opinion
  polarity, aspect-based opinion mining, star estimation, review-theme clustering, fake-review detection.
- Aggregate numeric stats (percentiles, anomalies) live in **`numbers`** / **`statistics`** — this pack
  emits shares/counts, not a stats engine.
- Self-contained: the only import is `../_shared/llm.js`.


---
Source: shared/engines/adapters/domain/review-analyzer/README.md
Canonical: https://docs.leumas.tech/p/adapters/domain/review-analyzer
