যখন কম্পিউটার প্রাকৃতিক ভাষা প্রসেস করে, কিছু অত্যন্ত সাধারণ শব্দ যা ডকুমেন্ট সিলেকশনে কম সাহায্য করে, ভোকাবুলারি থেকে সম্পূর্ণ বাদ দেওয়া হয়। এই শব্দগুলাকে স্টপ ওয়ার্ড বলা হয়।
উদাহরণস্বরূপ, ইনপুট সেন্টেন্স দিয়ে −
John is a person who takes care of the people around him.
স্টপ ওয়ার্ড রিমুভাল পাওয়ার পর আউটপুট পাবেন −
['John', 'person', 'takes', 'care', 'people', 'around', '.']
NLTK-এ এই স্টপওয়ার্ডের সংগ্রহ রয়েছে যা আমরা যেকোনো বাক্য থেকে বাদ দিতে ব্যবহার করতে পারি। এটি NLTK.corpus মডিউলের ভিতরে আছে। আমরা এটিকে ব্যবহার করে আমাদের বাক্য থেকে স্টপ ওয়ার্ড ফিল্টার আউট করতে পারি। উদাহরণস্বরূপ,
উদাহরণ
from nltk.corpus import stopwords from nltk.tokenize import word_tokenize my_sent = "John is a person who takes care of people around him." tokens = word_tokenize(my_sent) filtered_sentence = [w for w in tokens if not w in stopwords.words()] print(filtered_sentence)
আউটপুট
এটি আউটপুট দেবে −
['John', 'person', 'takes', 'care', 'people', 'around', '.']