Make lint

pull/2532/head
Eren Gölge 2023-04-17 15:02:56 +02:00
parent a44a0e1fd2
commit 1a6a5710fd
2 changed files with 10 additions and 11 deletions

View File

@ -1,5 +1,4 @@
import re
from typing import List
import bangla
from bnnumerizer import numerize
@ -59,15 +58,15 @@ def tag_text(text: str):
def normalize(sen):
global bnorm
global bnorm # pylint: disable=global-statement
_words = [bnorm(word)["normalized"] for word in sen.split()]
return " ".join([word for word in _words if word is not None])
def expand_full_attribution(text):
for word in attribution_dict:
for word, attr in attribution_dict.items():
if word in text:
text = text.replace(word, normalize(attribution_dict[word]))
text = text.replace(word, normalize(attr))
return text
@ -77,7 +76,7 @@ def collapse_whitespace(text):
return re.sub(_whitespace_re, " ", text)
def bangla_text_to_phonemes(text: str, seperator: str = "|") -> str:
def bangla_text_to_phonemes(text: str) -> str:
# english numbers to bangla conversion
res = re.search("[0-9]", text)
if res is not None:
@ -110,8 +109,8 @@ def bangla_text_to_phonemes(text: str, seperator: str = "|") -> str:
sentences = sentenceEnders.split(str(bn_text))
data = ""
for i in range(len(sentences)):
res = re.sub("\n", "", sentences[i])
for sent in sentences:
res = re.sub("\n", "", sent)
res = normalize(res)
# expand attributes
res = expand_full_attribution(res)

View File

@ -33,8 +33,8 @@ class BN_Phonemizer(BasePhonemizer):
return "bn_phonemizer"
@staticmethod
def phonemize_bn(text: str, separator: str = "|") -> str:
ph = bangla_text_to_phonemes(text, separator)
def phonemize_bn(text: str, separator: str = "|") -> str: # pylint: disable=unused-argument
ph = bangla_text_to_phonemes(text)
return ph
def _phonemize(self, text, separator):
@ -52,11 +52,11 @@ class BN_Phonemizer(BasePhonemizer):
if __name__ == "__main__":
text = "রাসূলুল্লাহ সাল্লাল্লাহু আলাইহি ওয়া সাল্লাম শিক্ষা দিয়েছেন যে, কেউ যদি কোন খারাপ কিছুর সম্মুখীন হয়, তখনও যেন বলে."
txt = "রাসূলুল্লাহ সাল্লাল্লাহু আলাইহি ওয়া সাল্লাম শিক্ষা দিয়েছেন যে, কেউ যদি কোন খারাপ কিছুর সম্মুখীন হয়, তখনও যেন বলে."
e = BN_Phonemizer()
print(e.supported_languages())
print(e.version())
print(e.language)
print(e.name())
print(e.is_available())
print("`" + e.phonemize(text) + "`")
print("`" + e.phonemize(txt) + "`")