TextCompareServiceTextCompareService

Сравнивает две строки и возвращает меру близости.

Compares two strings and returns a similarity measure.

  • Distance = 1 — строки идентичны.Distance = 1 means the strings are identical.
  • Код не оптимизирован по CPU — не используйте его на горячем пути с большими объёмами.The code is not CPU-optimized — avoid it on hot paths with large volumes.
C#
var service = new TextCompareService();
var result = service.Compare(new TextCompareRequest()
{
    FirstText = "Musk. He is the founder, CEO, CTO and chief designer of SpaceX; " +
                "early investor, CEO and product architect of Tesla, Inc. founder of The Boring Company",
    SecondText = "Elon Musk. He is the founder, CEO, CTO and chief designer of SpaceX; " +
                 "early investor, CEO and product architect of Tesla, Inc. founder of The Boring Company"
});

// result.Distance == 1 means the strings are identical
Assert.IsTrue(result.Distance < 1 && result.Distance > 0.98);