7. Text Generation and Summarization
Activity 7.01: Summarizing Complaints in the Consumer Financial Protection Bureau Dataset
Solution
Follow these steps to complete this activity:
- Open a Jupyter Notebook and insert a new cell. Add the following code to import the required libraries:
import warnings warnings.filterwarnings('ignore') import os import csv import pandas as pd from gensim.summarization import summarize
- Insert a new cell and add the following code to fetch the Consumer Complaints dataset and consider the rows that have a complaint narrative. Drop all the columns other than
Product
,Sub-product
,Issue
,Sub-issue
, andConsumer complaint narrative
:complaints_pathname = '../data/consumercomplaints/'\ 'Consumer_Complaints.csv' df_all_complaints = pd.read_csv(complaints_pathname) df_all_narr = df_all_complaints...