Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shhossain committed Aug 27, 2023
1 parent 029d369 commit 3b0f92f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
transformers
sentencepiece==0.1.99
sacremoses==0.0.53
torch
nltk
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
22 changes: 10 additions & 12 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 3b0f92f

Please sign in to comment.