09.10.2023 Views

Advanced Data Analytics Using Python_ With Machine Learning, Deep Learning and NLP Examples ( 2023)

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 1

Introduction

####################### Airlines Chield #######################

class AirLineReviewCollector(SkyThoughtCollector):

months = ['January', 'February', 'March', 'April', 'May',

'June', 'July', 'August', 'September', 'October', 'November',

'December' ]

def __init__(self, configpath):

#print "In Config"

super(AirLineReviewCollector,self).getConfig(configpath)

def parseSoupHeader(self, header):

#print "parsing header"

name = surname = year = month = date = country =''

txt = header.find("h9")

words = str(txt).strip().split(' ')

for j in range(len(words)-1):

if words[j] in self.months:

date = words[j-1]

month= words[j]

year = words[j+1]

name = words[j+3]

surname = words[j+4]

if ")" in words[-1]:

country = words[-1].split(')')[0]

if "(" in country:

country = country.split('(')[1]

else:

country = words[-2].split('(')[1] + country

return (name, surname, year, month, date, country)

6

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!