# Text Similarity: N-gram Overlap (Dice & Jaccard)

> Text Similarity: N-gram Overlap (Dice & Jaccard) is a paid API for AI agents from text-similarity.x402tookit.com, paid per call via x402, $0.02/call, status unknown (last checked 2026-10-21).

Computes Dice and Jaccard similarity scores using character or word n-gram overlap between two texts, in both set and multiset modes.

## Facts

- Endpoint: GET https://text-similarity.x402tookit.com/ngram-overlap?utm_source=zero.xyz
- Price: $0.02/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-21
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/text-similarity-n-gram-overlap-dice-jaccard-0349b868
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_XKqI2QuYi6wOEbg8LeUAe

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability text-similarity-n-gram-overlap-dice-jaccard-0349b868
```

Example prompt: Compare these two sentences using word bigram overlap and give me the Dice and Jaccard scores for both set and multiset: 'The quick brown fox jumps over the lazy dog' and 'The fast brown fox leaped over a lazy dog'.

## When to prefer this

Use this endpoint when you need fast, interpretable n-gram overlap metrics (Dice and Jaccard) for comparing two texts — especially when you want both set-based and multiset-based scores in a single call. Prefer this over edit-distance endpoints when texts are longer or you care about shared vocabulary rather than character-level edits. Prefer over cosine similarity when you want overlap metrics that don't depend on term-frequency vectors. Best for plagiarism detection, near-duplicate identification, and keyword overlap analysis.

## Known failure modes

- Missing required parameters 'a' or 'b' returns an error
- Text exceeding 2000 characters per field may be rejected or truncated
- Invalid value for 'n' outside 1–6 returns an error
- Invalid 'unit' value other than 'char' or 'word' returns an error
- Very short texts (e.g. single characters) may yield degenerate scores (0 or 1)
- Payment failure or expired x402 token results in 402 response

## How this service works

Dice and Jaccard n-gram overlap of two texts by character or word, as sets and as multisets.

## Output

Returns Dice and Jaccard similarity scores computed over n-grams as sets (treating each unique gram once) and as multisets (counting gram frequencies). Also returns gram counts for each text, the number of distinct grams in each, the count of shared distinct grams, the gram size (n), the unit used, and whether case was ignored.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "a",
      "b"
     ],
     "properties": {
      "a": {
       "type": "string",
       "description": "First text, up to 2000 characters"
      },
      "b": {
       "type": "string",
       "description": "Second text, up to 2000 characters"
      },
      "n": {
       "type": "integer",
       "description": "Gram size 1 to 6 (default 2)"
      },
      "unit": {
       "enum": [
        "char",
        "word"
       ],
       "type": "string",
       "description": "char (default) or word grams"
      },
      "ignoreCase": {
       "type": "boolean",
       "description": "true (default) lowercases both texts first"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "properties": {
      "n": {
       "type": [
        "null",
        "number"
       ]
      },
      "asOf": {
       "type": [
        "null",
        "string"
       ]
      },
      "unit": {
       "type": [
        "null",
        "string"
       ]
      },
      "gramsA": {
       "type": [
        "null",
        "number"
       ]
      },
      "gramsB": {
       "type": [
        "null",
        "number"
       ]
      },
      "source": {
       "type": [
        "null",
        "string"
       ]
      },
      "diceSet": {
       "type": [
        "null",
        "number"
       ]
      },
      "reasons": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "string"
       }
      },
      "summary": {
       "type": [
        "null",
        "string"
       ]
      },
      "verdict": {
       "type": [
        "null",
        "string"
       ]
      },
      "degraded": {
       "type": [
        "boolean",
        "null"
       ]
      },
      "distinctA": {
       "type": [
        "null",
        "number"
       ]
      },
      "distinctB": {
       "type": [
        "null",
        "number"
       ]
    
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/text-similarity-n-gram-overlap-dice-jaccard-0349b868/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from text-similarity.x402tookit.com](https://www.zero.xyz/host/text-similarity.x402tookit.com/llms.txt)
