Search code examples
pythonnlpnltktokenize

How to remove the ending sign from Bangla Text?


লোকাল ট্রেন পরিষেবা চালু করার জন্য দীর্ঘদিন ধরেই সরব হয়েছেন বহু নেতা নেত্রী।

How can I remove the "|" sign from the Bangla Sentence? and then tokenize it?

in this format "নেত্রী" instead of "নেত্রী।"

I am using python language.


Solution

  • To remove the ending "।", you can use string .replace() method: sentence.replace('।', '').

    To tokenize the sentence, there are many libraries available, you can use any of inltk, indicnlp, stanfordnlp, bnlp. Here's a complete example using bnlp:

    from bnlp import NLTKTokenizer
    
    bnltk = NLTKTokenizer()
    
    sentence = "লোকাল ট্রেন পরিষেবা চালু করার জন্য দীর্ঘদিন ধরেই সরব হয়েছেন বহু নেতা নেত্রী।"
    sentence = sentence.replace('।', '') // remove ending "।"
    word_tokens = bnltk.word_tokenize(sentence)