{"uid":"cap_XKqI2QuYi6wOEbg8LeUAe","slug":"text-similarity-n-gram-overlap-dice-jaccard-0349b868","name":"Text Similarity: N-gram Overlap (Dice & Jaccard)","description":"Dice and Jaccard n-gram overlap of two texts by character or word, as sets and as multisets.","url":"https://text-similarity.x402tookit.com/ngram-overlap?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"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"]},"disclaimer":{"type":["null","string"]},"ignoreCase":{"type":["boolean","null"]},"jaccardSet":{"type":["null","number"]},"notChecked":{"type":["array","null"],"items":{"type":"string"}},"diceMultiset":{"type":["null","number"]},"sharedDistinct":{"type":["null","number"]},"jaccardMultiset":{"type":["null","number"]}}}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.02","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.02/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_FYJPQq7w88FtANdLQKadM","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.02","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Computes Dice and Jaccard similarity scores using character or word n-gram overlap between two texts, in both set and multiset modes.","exampleAgentPrompt":"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'.","exampleUseCases":[{"title":"Plagiarism detection in student essays","prompt":"Check how similar these two essay excerpts are using character trigrams — give me the Dice and Jaccard overlap scores: 'Climate change poses an existential threat to biodiversity worldwide.' and 'Climate change is an existential risk to global biodiversity.'"},{"title":"Duplicate product description detection","prompt":"I need to know if these two product descriptions are near-duplicates — run a word bigram overlap comparison with case ignored: 'Ultra-lightweight running shoes with breathable mesh upper' and 'Lightweight running shoe featuring a breathable mesh design'."},{"title":"Query-to-document relevance scoring","prompt":"How much word-level n-gram overlap is there between this search query and this document snippet? Query: 'machine learning model training tips', document: 'Tips for training deep learning models efficiently'. Use word unigrams and show me Dice and Jaccard for both set and multiset."}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-21T07:19:13.565Z","isFirstParty":false,"canonicalSlug":"text-similarity-n-gram-overlap-dice-jaccard-0349b868"}