Bnlp Versions Save

BNLP is a natural language processing toolkit for Bengali Language.

v4.0.0

9 months ago

BNLP 4.0.0: Re-design of BNLP version 3 with proper OOP methods for re-use model, use separate train module, and so on

Highlights

BNLP v4.0.0 is re-design with proper object-orient programming method. In the earlier version pre-trained model was loading every time we try to tokenize or embed a text. But this version model will load only once and re-use for tokenization, embedding, and other task as well. Also added automatic model downloading so if someone passes no pre-train model path it will automatically load a pre-train model from the hub. In the earlier version training module was embedded with the same prediction module. Which was creating a problem to add some separate functionalities for train and predicting. So, we separated the training module for every task like tokenization, and embeddings. The Corpus module is now a class to reuse and add new features.

API Changes

Model loading changes: Previously model was loading every time it generate a results

  • Model was loading while initiating any classes
  • If no model passes through it will automatically load a pre-train model from the hub.
3.3.2 4.0.0
from bnlp import BengaliWord2Vec

bwv = BengaliWord2Vec()
model_path = "bengali_word2vec.model"
word = 'গ্রাম'
similar = bwv.most_similar(model_path, word, topn=10)
print(similar)
from bnlp import BengaliWord2Vec

model_path = "path/mymodel.model"
bwv = BengaliWord2Vec(model_path=model_path)

word = 'গ্রাম'
vector = bwv.get_word_vector(word)
print(vector.shape)

Training module changes

The training module separated from the main module and added relevant features into it.

3.3.2 4.0.0
from bnlp import BengaliWord2Vec

bwv = BengaliWord2Vec()
data_file = "raw_text.txt"
model_name = "test_model.model"
vector_name = "test_vector.vector"
bwv.train(data_file, model_name, vector_name, epochs=5)
from bnlp import Word2VecTraining

trainer = Word2VecTraining()

data_file = "raw_text.txt"
model_name = "test_model.model"
vector_name = "test_vector.vector"
trainer.train(data_file, model_name, vector_name, epochs=5)

Corpus is now class

3.3.2 4.0.0
from bnlp.corpus import stopwords, punctuations, letters, digits

print(stopwords)
print(punctuations)
print(letters)
print(digits)
from bnlp import BengaliCorpus as corpus

print(corpus.stopwords)
print(corpus.punctuations)
print(corpus.letters)
print(corpus.digits)
print(corpus.vowels)

Contributors

  • Ibrahim (automatic model downloading, fixing glove vector loading)

v4.0.0.0dev4

9 months ago

fixed build problem dev version 3

v4.0.0dev3

9 months ago

The internal build version of bnlp 4.0.0

v4.0.0dev2

9 months ago

v3.3.2

10 months ago

Bug fix

  • NLTK sentence tokenizer dummy token replacement bug fixed. It was not tokening the (.) based on the algorithm.

Incompatibility warning

  • The upcoming bnlp version 4.0.0 (dev release available) will be totally incompatible with the present and past versions. Added a deprecation warning so every time someone tries to import this version it will warn the user to put the exact version if they do not want to upgrade to the newer version.

v3.3.1

1 year ago

Fixed version incompatibility of gensim and python 3.10

  • remove the exact version of Gensim and replace it with the latest Gensim version to fix the build problem in Python 3.10 (#29 )

v3.3.0

1 year ago

Bug Fix

  • remove wasabi text formatting for updated version build problem in different os, python version

New Feature

Text Cleaning

We adopted different text-cleaning formulas, and codes from clean-text and modified for Bangla. Now you can normalize and clean your text using the following methods.

from bnlp import CleanText

clean_text = CleanText(
   fix_unicode=True,
   unicode_norm=True,
   unicode_norm_form="NFKC",
   remove_url=False,
   remove_email=False,
   remove_emoji=False,
   remove_number=False,
   remove_digits=False,
   remove_punct=False,
   replace_with_url="<URL>",
   replace_with_email="<EMAIL>",
   replace_with_number="<NUMBER>",
   replace_with_digit="<DIGIT>",
   replace_with_punct = "<PUNC>"
)

input_text = "আমার সোনার বাংলা।"
clean_text = clean_text(input_text)
print(clean_text)

v3.2.0

1 year ago

New Feature

  • Added document embedding module
  • Added doc2vec-based document embedding, document similarity finder, and doc2vec training with custom text files
  • Doc2vec Bengali model trained with newspaper datasets datasets. I randomly selected 8 JSON files from 21 JSON containing a total of 400013 articles. The training hyper-parameter was: epochs: 40, vector_size: 100, min_count:2.

Get document vector from input document

from bnlp import BengaliDoc2vec

bn_doc2vec = BengaliDoc2vec()

model_path = "bangla_news_article_doc2vec.model" # keep other .npy model files also in same folder
document = "রাষ্ট্রবিরোধী ও উসকানিমূলক বক্তব্য দেওয়ার অভিযোগে গাজীপুরের গাছা থানায় ডিজিটাল নিরাপত্তা আইনে করা মামলায় আলোচিত ‘শিশুবক্তা’ রফিকুল ইসলামের বিরুদ্ধে অভিযোগ গঠন করেছেন আদালত। ফলে মামলার আনুষ্ঠানিক বিচার শুরু হলো। আজ বুধবার (২৬ জানুয়ারি) ঢাকার সাইবার ট্রাইব্যুনালের বিচারক আসসামছ জগলুল হোসেন এ অভিযোগ গঠন করেন। এর আগে, রফিকুল ইসলামকে কারাগার থেকে আদালতে হাজির করা হয়। এরপর তাকে নির্দোষ দাবি করে তার আইনজীবী শোহেল মো. ফজলে রাব্বি অব্যাহতি চেয়ে আবেদন করেন। অন্যদিকে, রাষ্ট্রপক্ষ অভিযোগ গঠনের পক্ষে শুনানি করেন। উভয় পক্ষের শুনানি শেষে আদালত অব্যাহতির আবেদন খারিজ করে অভিযোগ গঠনের মাধ্যমে বিচার শুরুর আদেশ দেন। একইসঙ্গে সাক্ষ্যগ্রহণের জন্য আগামী ২২ ফেব্রুয়ারি দিন ধার্য করেন আদালত।"

vector = bn_doc2vec.get_document_vector(model_path, text)
print(vector)

Find document similarity between two document

from bnlp import BengaliDoc2vec

bn_doc2vec = BengaliDoc2vec()

model_path = "bangla_news_article_doc2vec.model" # keep other .npy model files also in same folder
article_1 = "রাষ্ট্রবিরোধী ও উসকানিমূলক বক্তব্য দেওয়ার অভিযোগে গাজীপুরের গাছা থানায় ডিজিটাল নিরাপত্তা আইনে করা মামলায় আলোচিত ‘শিশুবক্তা’ রফিকুল ইসলামের বিরুদ্ধে অভিযোগ গঠন করেছেন আদালত। ফলে মামলার আনুষ্ঠানিক বিচার শুরু হলো। আজ বুধবার (২৬ জানুয়ারি) ঢাকার সাইবার ট্রাইব্যুনালের বিচারক আসসামছ জগলুল হোসেন এ অভিযোগ গঠন করেন। এর আগে, রফিকুল ইসলামকে কারাগার থেকে আদালতে হাজির করা হয়। এরপর তাকে নির্দোষ দাবি করে তার আইনজীবী শোহেল মো. ফজলে রাব্বি অব্যাহতি চেয়ে আবেদন করেন। অন্যদিকে, রাষ্ট্রপক্ষ অভিযোগ গঠনের পক্ষে শুনানি করেন। উভয় পক্ষের শুনানি শেষে আদালত অব্যাহতির আবেদন খারিজ করে অভিযোগ গঠনের মাধ্যমে বিচার শুরুর আদেশ দেন। একইসঙ্গে সাক্ষ্যগ্রহণের জন্য আগামী ২২ ফেব্রুয়ারি দিন ধার্য করেন আদালত।"
article_2 = "রাষ্ট্রবিরোধী ও উসকানিমূলক বক্তব্য দেওয়ার অভিযোগে গাজীপুরের গাছা থানায় ডিজিটাল নিরাপত্তা আইনে করা মামলায় আলোচিত ‘শিশুবক্তা’ রফিকুল ইসলামের বিরুদ্ধে অভিযোগ গঠন করেছেন আদালত। ফলে মামলার আনুষ্ঠানিক বিচার শুরু হলো। আজ বুধবার (২৬ জানুয়ারি) ঢাকার সাইবার ট্রাইব্যুনালের বিচারক আসসামছ জগলুল হোসেন এ অভিযোগ গঠন করেন। এর আগে, রফিকুল ইসলামকে কারাগার থেকে আদালতে হাজির করা হয়। এরপর তাকে নির্দোষ দাবি করে তার আইনজীবী শোহেল মো. ফজলে রাব্বি অব্যাহতি চেয়ে আবেদন করেন। অন্যদিকে, রাষ্ট্রপক্ষ অভিযোগ গঠনের পক্ষে শুনানি করেন। উভয় পক্ষের শুনানি শেষে আদালত অব্যাহতির আবেদন খারিজ করে অভিযোগ গঠনের মাধ্যমে বিচার শুরুর আদেশ দেন। একইসঙ্গে সাক্ষ্যগ্রহণের জন্য আগামী ২২ ফেব্রুয়ারি দিন ধার্য করেন আদালত।"

similarity = bn_doc2vec.get_document_similarity(
  model_path,
  article_1,
  article_2
)
print(similarity)

Updates

v3.1.2

2 years ago
  • removed automatic train test splitting option from NER and POS module
  • Update NER and POS module for passing both train and test data while training
  • Added F1 score calculation for evaluation with Accuracy score.
  • Update NER and POS inference for passing token list for custom token passing

v3.1.0

3 years ago

New Features

  • Updated word2vec for gensim 4.0 from gensim 3.8.3
  • Updated word2vec training modules with gensim identical parameter passing while training
  • Added new word2vec pre-trained model with vector size 100
  • Added pre-training function for resume training of word2vec
  • Updated fasttext training module with fasttext identical parameter passing while training
  • Added bin2vec function in fasttext for generating vector file from fasttext bin model
  • Updated corpus class with bengali letter, punctuation, digits
  • added stale app

Bug fixed

  • fixed Bengali nltk sentence tokenizer issue. PR-19 Bengali NLTK sentence tokenizer was wrongly tokenizing for . punctuation.

New Contributor