Repository: joke2k/faker
Pull request #1608 (2022-02-05 04:30:09)

Task/jabertuhin/1519/add loremprovider for bn bd
### What does this changes

This pull-request resolves issue #1519 . I have created `bn_BD` package under lorem provider.

### What was wrong

NA

### How this fixes it

NA

### Fixes

NA


Patch:
diff --git a/faker/providers/lorem/bn_BD/__init__.py b/faker/providers/lorem/bn_BD/__init__.py
new file mode 100644
index 00000000..f49df831
--- /dev/null
+++ b/faker/providers/lorem/bn_BD/__init__.py
@@ -0,0 +1,233 @@
+from .. import Provider as LoremProvider
+
+
+class Provider(LoremProvider):
+    """Implement lorem provider for ``bn_BD`` locale."""
+
+    # source 1: https://en.wikipedia.org/wiki/Bengali_vocabulary
+    # source 2: https://en.wikipedia.org/wiki/Bengali_grammar
+
+    word_connector = " "
+    sentence_punctuation = "।"
+    word_list = (
+        "পানি",
+        "লবণ",
+        "দাওয়াত",
+        "মরিচ",
+        "খালা",
+        "ফুফু",
+        "গোসল",
+        "বাতাস",
+        "চাহিদা",
+        "স্বাগতম",
+        "যোগ",
+        "আসন",
+        "আশ্রম",
+        "আয়ুর্বেদ",
+        "বন্ধন",
+        "খাট",
+        "ধুতি",
+        "মায়া",
+        "স্বামী",
+        "লক্ষ্মী",
+        "লক্ষ্মণ",
+        "কুড়ি",
+        "খুকি",
+        "খোকা",
+        "খোঁচা",
+        "খোঁজ",
+        "চাল",
+        "চিংড়ি",
+        "চুলা",
+        "ঝিনুক",
+        "ঝোল",
+        "ঠ্যাং",
+        "ঢোল",
+        "পেট",
+        "বোবা",
+        "মাঠ",
+        "মুড়ি",
+        "আবহাওয়া",
+        "চাকরি",
+        "আয়না",
+        "আরাম",
+        "বকশিশ",
+        "আস্তে",
+        "কাগজ",
+        "খারাপ",
+        "খোদা",
+        "খুব",
+        "গরম",
+        "চশমা",
+        "চাকর",
+        "চাদর",
+        "জান",
+        "জায়গা",
+        "ডেগচি",
+        "দম",
+        "দেরি",
+        "দোকান",
+        "পর্দা",
+        "বদ",
+        "বাগান",
+        "রাস্তা",
+        "রোজ",
+        "হিন্দু",
+        "পছন্দ",
+        "টেক্কা",
+        "আলু",
+        "নখ",
+        "খুন",
+        "আওয়াজ",
+        "আসল",
+        "এলাকা",
+        "ওজন",
+        "কলম",
+        "খবর",
+        "খালি",
+        "খেয়াল",
+        "গরিব",
+        "জমা",
+        "তারিখ",
+        "দুনিয়া",
+        "নকল",
+        "ফকির",
+        "বদল",
+        "বাকি",
+        "শয়তান",
+        "সাহেব",
+        "সনদ",
+        "সাল",
+        "সন",
+        "হিসাব",
+        "দাদা",
+        "বাবা",
+        "নানি",
+        "চকমক",
+        "বাবুর্চি",
+        "বেগম",
+        "কেচি",
+        "লাশ",
+        "তবলা",
+        "আলমারি",
+        "ইস্ত্রি",
+        "ইস্তিরি",
+        "ইস্পাত",
+        "কামিজ",
+        "গামলা",
+        "চাবি",
+        "জানালা",
+        "তামাক",
+        "পেরেক",
+        "ফিতা",
+        "বারান্দা",
+        "বালতি",
+        "বেহালা",
+        "বোতাম",
+        "মেজ",
+        "সাবান",
+        "কেদারা",
+        "আতা",
+        "আনারস",
+        "কাজু",
+        "কপি",
+        "পেঁপে",
+        "পেয়ারা",
+        "সালাদ",
+        "গির্জা",
+        "যিশু",
+        "পাদ্রি",
+        "ইংরেজ",
+        "অফিস",
+        "জেল",
+        "ডাক্তার",
+        "পুলিশ",
+        "ব্যাংক",
+        "ভোট",
+        "স্কুল",
+        "হাসপাতাল",
+        "কাপ",
+        "গ্লাস",
+        "চেয়ার",
+        "টেবিল",
+        "বাক্স",
+        "লণ্ঠন",
+        "প্লাস্টিক",
+        "কলেজ",
+        "সাইকেল",
+        "রেস্তোরাঁ",
+        "সুড়ঙ্গ",
+        "চা",
+        "চিনি",
+        "সুনামি",
+        "রিক্সা",
+        "বোকা",
+        "ছোট্ট",
+        "লুঙ্গি",
+        "ডেঙ্গু",
+        "মানুষজন",
+        "মাফিয়া",
+        "স্টুডিও",
+        "ম্যালেরিয়া",
+        "ক্যাঙারু",
+        "বুমেরাং",
+        "আমি",
+        "তুই",
+        "তুমি",
+        "আপনি",
+        "এ",
+        "ইনি",
+        "ও",
+        "উনি",
+        "সে",
+        "তিনি",
+        "সেটি",
+        "আমরা",
+        "তোরা",
+        "তোমরা",
+        "আপনারা",
+        "এরা",
+        "এগুলো",
+        "ওরা",
+        "এঁরা",
+        "ওঁরা",
+        "তারা",
+        "তাঁরা",
+        "সেগুলো",
+        "আমাকে",
+        "তোকে",
+        "আমাদেরকে",
+        "তোদেরকে",
+        "তোমাকে",
+        "তোমাদেরকে",
+        "আপনাকে",
+        "আপনাদেরকে",
+        "একে",
+        "এদেরকে",
+        "এঁকে",
+        "এঁদেরকে",
+        "এটি",
+        "এটা",
+        "ওকে",
+        "ওদেরকে",
+        "ওঁকে",
+        "ওঁদেরকে",
+        "ওটি",
+        "ওটা",
+        "ওগুলো",
+        "তাকে",
+        "তাদেরকে",
+        "তাঁকে",
+        "তাঁদেরকে",
+        "সেটা",
+        "কে",
+        "কার",
+        "কাকে",
+        "কোন",
+        "কি",
+        "কেউ",
+        "কারও",
+        "কাউকে",
+        "কোনও",
+        "কিছু",
+    )


Test patch:
diff --git a/tests/providers/test_lorem.py b/tests/providers/test_lorem.py
index 0838017e..22e3d615 100644
--- a/tests/providers/test_lorem.py
+++ b/tests/providers/test_lorem.py
@@ -3,6 +3,7 @@ import re
 import pytest
 
 from faker.providers.lorem.az_AZ import Provider as AzAzLoremProvider
+from faker.providers.lorem.bn_BD import Provider as BnBdLoremProvider
 from faker.providers.lorem.cs_CZ import Provider as CsCzLoremProvider
 from faker.providers.lorem.de_AT import Provider as DeAtLoremProvider
 from faker.providers.lorem.de_DE import Provider as DeDeLoremProvider
@@ -317,6 +318,46 @@ class TestAzAz:
             assert all(isinstance(word, str) and word in AzAzLoremProvider.word_list for word in words)
 
 
+class TestBnBd:
+    """Test bn_BD lorem provider"""
+
+    word_list = BnBdLoremProvider.word_list
+
+    def test_paragraph(self, faker, num_samples):
+        num_sentences = 10
+        for _ in range(num_samples):
+            paragraph = faker.paragraph(nb_sentences=num_sentences)
+            assert isinstance(paragraph, str)
+            words = paragraph.replace("।", "").split()
+            assert all(word in self.word_list for word in words)
+
+    def test_paragraphs(self, faker, num_samples):
+        num_paragraphs = 5
+        for _ in range(num_samples):
+            paragraphs = faker.paragraphs(nb=num_paragraphs)
+            for paragraph in paragraphs:
+                assert isinstance(paragraph, str)
+                words = paragraph.replace("।", "").split()
+                assert all(word in self.word_list for word in words)
+
+    def test_sentence(self, faker, num_samples):
+        num_words = 10
+        for _ in range(num_samples):
+            sentence = faker.sentence(nb_words=num_words)
+            assert isinstance(sentence, str)
+            words = sentence.replace("।", "").split()
+            assert all(word in self.word_list for word in words)
+
+    def test_sentences(self, faker, num_samples):
+        num_sentences = 5
+        for _ in range(num_samples):
+            sentences = faker.sentences(nb=num_sentences)
+            for sentence in sentences:
+                assert isinstance(sentence, str)
+                words = sentence.replace("।", "").split()
+                assert all(word in self.word_list for word in words)
+
+
 class TestDeDe:
     """Test ```de_DE``` lorem provider"""