2. Feature Extraction Methods
Activity 2.01: Extracting Top Keywords from the News Article
Solution
The following steps will help you complete this Activity:
- Open a Jupyter Notebook.
- Insert a new cell and add the following code to import the necessary libraries and download the data:
import operator from nltk.tokenize import WhitespaceTokenizer from nltk import download, stem # The below statement will download the stop word list # 'nltk_data/corpora/stopwords/' at home directory of your computer download('stopwords') from nltk.corpus import stopwords
The
download
statement will download the stop word list atnltk_data/corpora/stopwords/
into your system's home directory. - Create the different types of methods to perform various NLP tasks:
Activity 2.01.ipynb
def load_file(file_path): news = ''.join\ ([line for line in open...