diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4d6a9b8..8184b80 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt # If you have any requirements + pip install -r requirements-test.txt # If you have any requirements - name: Run tests run: python test/test.py diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 0000000..fb7e6f2 --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,5 @@ +transformers +sentencepiece==0.1.99 +sacremoses==0.0.53 +torch +nltk \ No newline at end of file diff --git a/setup.py b/setup.py index 0654123..3192817 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -version = "0.0.4" +version = "0.0.5" short_description = "BanglaTranslationKit: Open-source tool for offline Bangla-English translation." author = "shhossain" diff --git a/test/test.py b/test/test.py index bf53ac9..4678ed7 100644 --- a/test/test.py +++ b/test/test.py @@ -8,19 +8,17 @@ from bntrans import Translator +import nltk + + +def edit_distance(a, b): + words = a.split() + words2 = b.split() + return nltk.edit_distance(words, words2) + + def match_percentage(a, b): - """ - Returns the percentage of matching characters between a and b - """ - if len(a) != len(b): - a = a[: min(len(a), len(b))] - - count = 0 - for i in range(len(a)): - if a[i] == b[i]: - count += 1 - - return count / len(a) + return 1 - (edit_distance(a, b) / max(len(a), len(b))) class TestTranslator(unittest.TestCase):