Page 473 - AI Ver 3.0 class 10_Flipbook
P. 473
For removing stopwords:
[1]: import nltk
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
nltk.download('stopwords')
nltk.download('punkt')
def remove_stopwords(text):
stop_words = set(stopwords.words('english'))
words = word_tokenize(text)
filtered_words = [word for word in words if word.lower() not in stop_words]
return ' '.join(filtered_words)
text = " Natural Language Processing or NLP is the subset of Artificial Intelligence."
clean_text = remove_stopwords(text)
print(clean_text)
Natural Language Processing NLP subset Artificial Intelligence.
OpenCV
OpenCV stands for Open-Source Computer Vision Library, originally developed by Intel and officially launched
in 1999. It is an open-source software library for computer vision and Machine Learning that helps a computer
understand the content of digital images like photographs and videos.
It helps in processing images and videos to identify objects, faces, or even handwriting. It supports a wide variety
of programming languages like Python, C++, Java, etc. and is available on almost all platforms. We will use OpenCV
for basic image processing operations on images such as resizing, cropping and many more.
Let us first see how we can install it in our computer:
• Open Anaconda prompt and write the following command:
pip install opencv-python
Make sure you download the get-pip.py file and store it in the same directory as python is installed before you
install OpenCV.
Brainy Fact
Stanford’s robot “Stanley” used OpenCV and was declared the winner of the DARPA Grand Challenge in 2005.
This challenge is a prize competition for American autonomous vehicles, funded by the Defense Advanced
Research Projects Agency.
The imread() Function in OpenCV
The imread() function read the image and loads it into the computer’s memory. Syntax of imread() function
is: cv2.imread(path, flag)
Where,
• path is the path of the image to be read. If the file is in the working directory, then write only the name and the
extension of the image otherwise it is a must to specify the complete path.
• flag is the way how our image should be read.
Advance Python (Practical) 471

