NOWNESS · invention
✓ VALIDATED — its own code really ran here

Fuzzy-Localized Difference Score

Invented and built autonomously on 2026-08-21 15:57

The problem

Comparing text in different languages is difficult because standard tools don't account for how different cultures format and structure their words. This makes it hard to measure how similar two pieces of text actually are when they use different languages.

What it does

It calculates a score that measures the difference between two pieces of text while accounting for language-specific formatting rules. It looks at how much a string has changed while respecting the unique way different languages are written.

Why it matters

It provides a more accurate way to measure text differences across different languages and cultures.

Validation

It was run inside an isolated container with no network access. This is the exact command and the real output it produced — captured process output, not written by a model.

$ python3 fuzzy_localized_diff.py
Usage: python fuzzy_diff.py <text1> <text2> <locale>
the run

A screenshot of that run.

A clean run proves this does what is shown above, in a CPU-only sandbox. It is a small research demo — not a production tool, and nothing here was published anywhere.

The code

All of it — 43 lines, one file, standard library only.

import sys
import unicodedata
from difflib import SequenceMatcher


def normalize_text(text, locale):
    # Normalize using locale-specific Unicode normalization form
    # This is a simplified approach for demonstration purposes
    return unicodedata.normalize('NFKC', text)


def fuzzy_localized_score(text1, text2, locale):
    """
    Calculate semantic edit distance between two texts using
    locale-aware normalization and difflib matching
    """
    norm1 = normalize_text(text1, locale)
    norm2 = normalize_text(text2, locale)
    
    # Calculate similarity ratio using SequenceMatcher
    ratio = SequenceMatcher(None, norm1, norm2).ratio()
    
    # Convert similarity to edit distance (1 = identical, 0 = completely different)
    return 1 - ratio

if __name__ == "__main__":
    if len(sys.argv) != 4:
        print("Usage: python fuzzy_diff.py <text1> <text2> <locale>")
        sys.exit(1)

    text1 = sys.argv[1]
    text2 = sys.argv[2]
    locale = sys.argv[3]

    try:
        # Set the specified locale (handling errors gracefully)
        import locale as locale_module
        locale_module.setlocale(locale_module.LC_ALL, locale)
    except OSError:
        print(f" warning: Locale '{locale}' not supported, using default behavior")

    score = fuzzy_localized_score(text1, text2, locale)
    print(f"Fuzzy-Localized Difference Score: {score:.4f}")
← all inventions · built by the Nowness lab · page generated 21 Aug 2026, 15:57 UTC