API: ranking/density
better-web-search-mcp / ranking/density
ranking/density#
Interfaces#
DensityResult#
Defined in: src/ranking/density.ts:32
A density verdict for one page.
Extends#
Properties#
| Property | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|
boilerplateRatio | number | Share of lines that look like navigation or boilerplate, 0..1. | DensitySignals.boilerplateRatio | src/ranking/density.ts:26 |
duplicateRatio | number | Share of paragraphs that duplicate an earlier one, 0..1. | DensitySignals.duplicateRatio | src/ranking/density.ts:24 |
linkRatio | number | Markdown links per 100 words. High on navigation and affiliate pages. | DensitySignals.linkRatio | src/ranking/density.ts:22 |
meanSentenceWords | number | Mean sentence length in words. | DensitySignals.meanSentenceWords | src/ranking/density.ts:28 |
score | number | Information density, 0..1. Higher means more substance per character. Intended as a ranking signal alongside relevance, not a gate. | - | src/ranking/density.ts:37 |
words | number | Words of visible text, after stripping markdown link syntax. | DensitySignals.words | src/ranking/density.ts:20 |
DensitySignals#
Defined in: src/ranking/density.ts:18
The component signals behind a density score.
Extended by#
Properties#
| Property | Type | Description | Defined in |
|---|---|---|---|
boilerplateRatio | number | Share of lines that look like navigation or boilerplate, 0..1. | src/ranking/density.ts:26 |
duplicateRatio | number | Share of paragraphs that duplicate an earlier one, 0..1. | src/ranking/density.ts:24 |
linkRatio | number | Markdown links per 100 words. High on navigation and affiliate pages. | src/ranking/density.ts:22 |
meanSentenceWords | number | Mean sentence length in words. | src/ranking/density.ts:28 |
words | number | Words of visible text, after stripping markdown link syntax. | src/ranking/density.ts:20 |
Functions#
densitySignals()#
densitySignals(
content):DensitySignals
Defined in: src/ranking/density.ts:68
Measure the structural signals of a page’s extracted content.
Exported so the score can be explained rather than just asserted.
Parameters#
| Parameter | Type |
|---|---|
content | string |
Returns#
informationDensity()#
informationDensity(
content):DensityResult
Defined in: src/ranking/density.ts:162
Score a page’s information density from its extracted content.
Penalties are additive and capped, so one bad signal cannot zero a page that is otherwise substantial. An empty page scores 0.
Parameters#
| Parameter | Type |
|---|---|
content | string |
Returns#
looksLikeSerializedData()#
looksLikeSerializedData(
text):boolean
Defined in: src/ranking/density.ts:138
Whether text is a serialized data blob rather than readable content.
Extraction sometimes leaves __NEXT_DATA__-style payloads in the page text,
and they score well: they repeat every query term the article uses, so they
won citation slots and spent an agent’s context on {"props":{"pageProps"….
Quoting one is pure waste, since nothing in it is prose an agent can read.
The test is deliberately narrow. A fenced code sample or a config snippet is legitimate evidence for a developer question, so it requires both a high punctuation share and the quoted-key shape that marks JSON.
Parameters#
| Parameter | Type |
|---|---|
text | string |
Returns#
boolean