class not functioning methods properly

I defined a class to handle blocks of tweets so I could manage them a little easier

class twitter_block(object):  def __init__(self):     self.tweets = []     self.df = pd.DataFrame()      self.tag = '' def load(self, data):      self.tweets = [x for x in data] 

then defined a method as part of a pipeline:

 def clean(self):      HTTP_PATTERN = '^https?:\/\/.*[\r\n]*'     AT_PATTERN = '@\w+ ?'      # tke away links     self.tweets = [re.sub(HTTP_PATTERN, '', str(x), flags=re.MULTILINE) for x in self.tweets]     # take away @ signs     self.tweets = [re.sub(AT_PATTERN,'',str(x)) for x in self.tweets] 

but when I call this:

tweet = load_data('The_Donald.json') block = twitter_block(tag='donald') block.load(data=tweet) block.clean() block.print() 

it returns the 1504 tweets that I loaded into the block object same as before, no cleaning links or anything. Although, actually it does remove @ signs... but this method,

def smilecheck(self): #save a tweet if there is a smiley there smiley_pattern = '^(:(|:))+$' for tweet in self.tweets:

    if re.match(smiley_pattern, str(tweet)):         pass     else:         self.tweets.remove(tweet) 

does not remove the tweets without smileys, returns 1504 tweets, the same as I put in... any help guys? im sure this is a problem with the way I am approaching objects


Category: python Time: 2016-07-28 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.141 (s). 12 q(s)