From b0521e00486d0efeb29660bae8ae70ece2bb47ea Mon Sep 17 00:00:00 2001 From: Vlad Ovchynnykov Date: Wed, 15 Sep 2021 15:24:32 +0300 Subject: [PATCH] Adds textdistance --- harnic/compare/utils.py | 4 +++- requirements.txt | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/harnic/compare/utils.py b/harnic/compare/utils.py index b988e5a..99810a3 100644 --- a/harnic/compare/utils.py +++ b/harnic/compare/utils.py @@ -1,5 +1,7 @@ from difflib import _mdiff +import textdistance + class Comparison: def __init__(self, equal, strict_equal, diff, score): @@ -73,7 +75,7 @@ def qp_compare(qp1, qp2): def text_compare(t1, t2): - return 1 + return textdistance.levenshtein.normalized_similarity(str(t1).splitlines(), str(t2).splitlines()) def content_compare(r1, r2): diff --git a/requirements.txt b/requirements.txt index ac38295..ae3118d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ six==1.16.0 tabulate==0.8.9 tqdm==4.62.1 termcolor==1.1.0 +textdistance[extras]==4.2.1