Adjusting Comparison Sensitivity

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Comparison MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-comparison -- dnx GroupDocs.Comparison.Mcp --yes
Folders, licensing and more →

GroupDocs.Comparison for Python via .NET supports comparison sensitivity values from 0 (fastest, least detailed) to 100 (slowest, most detailed). The default is 75.

  • 0 — fastest comparison; only fully-disjoint substrings are detected as inserts/deletes.
  • 75 — the default. Sub-sequences that have more than 75% of their content inserted or deleted are treated as fully inserted or deleted.
  • 100 — slowest comparison; any common sub-sequence is taken into account.

Worked example

Consider these two strings:

1.It is our equity poetry
2.Jack is a glad calf

They share two common sub-sequences: the word is and three space characters. The common sub-sequence is " is " (length 4 including spaces). The inserted sub-sequence is Jackagladcalf (length 13). The removed sub-sequence is Itourequitypoetry (length 17). The percentage of removed and inserted symbols is (17 + 13) / (17 + 13 + 4) * 100 = 88%.

  • sensitivity_of_comparison = 80 — 88% > 80%, so the common sub-sequence is discarded. Result: Jack is a glad calfIt is our equity poetry (the first string is fully removed, the second fully inserted).
  • sensitivity_of_comparison = 89 — 88% < 89%, so the common sub-sequence is kept. Result: JackIt is aour gladequity calfpoetry.

Example 1: Adjust overall sensitivity

Increase sensitivity to detect smaller changes; lower it for faster processing.

from groupdocs.comparison import Comparer
from groupdocs.comparison.options import CompareOptions

def adjust_comparison_sensitivity():
    with Comparer("./source.docx") as comparer:
        comparer.add("./target.docx")
        options = CompareOptions()
        options.sensitivity_of_comparison = 100
        comparer.compare("./result.docx", options)

if __name__ == "__main__":
    adjust_comparison_sensitivity()

source.docx is the source file used in this example. Click here to download it.

target.docx is the target file used in this example. Click here to download it.

Binary file (DOCX, 25 KB)

Download full output

Use case: maximise accuracy for legal or scientific documents where subtle edits matter.

Example 2: Adjust sensitivity for tables

Tables can have their own sensitivity value, independent of the overall setting:

from groupdocs.comparison import Comparer
from groupdocs.comparison.options import CompareOptions

def adjust_comparison_sensitivity_tables():
    with Comparer("./source.docx") as comparer:
        comparer.add("./target.docx")
        options = CompareOptions()
        options.sensitivity_of_comparison = 100
        options.sensitivity_of_comparison_for_tables = 75
        comparer.compare("./result.docx", options)

if __name__ == "__main__":
    adjust_comparison_sensitivity_tables()

source.docx is the source file used in this example. Click here to download it.

target.docx is the target file used in this example. Click here to download it.

Binary file (DOCX, 25 KB)

Download full output

Use case: tune detection granularity in tables while keeping overall sensitivity high.