Python:
from difflib import SequenceMatcher
from typing import Tuple, List
def similarity(a: str, b: str) -> int:
"""
Intent similarity scoring.
Returns integer between 0 and 100.
0 = completely different. 100 = identical.
"""
# The pathetic float that actually works
weak_ratio: float = SequenceMatcher(None, a, b).ratio()
# Multiply by 100 and floor to int
# That's it. No chaos. No ASCII XOR. No hyperbolic bullshit.
result: int = int(weak_ratio * 100)
# Clamp to 0-100 because floating point rounding is for incompetents
return max(0, min(100, result))
def main() -> None:
tests: List[Tuple[str, str]] = [
("shut up", "shut the fuck up"),
("shit in the ass", "shit inside the ass"),
("shit in the ass", "shitty assed full of shit"),
("shit", "shiiieeet"),
("stop", "stopp"),
("hello", "yellow"),
]
for a, b in tests:
score: int = similarity(a, b)
print(f"{a!r} vs {b!r} → {score}")
if __name__ == "__main__":
main()