This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function init(){ | |
$offset = 0; | |
$xhr = false; | |
if(!empty($_GET['offset'])){ | |
$offset = $_GET['offset']; | |
$xhr = true; | |
} | |
$limit = 15; | |
$data = getRSSFeedItems($limit, $offset); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YUI().use('node', 'event', 'io-base', function(Y){ | |
var updateInitiated; | |
var page; | |
var retries; | |
var maxRetries; | |
var allStoriesFetched; | |
function init(){ | |
var self = this; | |
//Initialize updateInitiated flag and pagination unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function handleScroll(){ | |
var self = this; | |
var scrollPos; | |
if(this.updateInitiated){ | |
return; | |
} | |
//Find the pageHeight and clientHeight(the no. of pixels to scroll to make the scrollbar reach max pos) | |
var pageHeight = document.documentElement.scrollHeight; | |
var clientHeight = document.documentElement.clientHeight; | |
//Handle scroll position in case of IE differently |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import regex | |
import re | |
#start process_tweet | |
def processTweet(tweet): | |
# process the tweets | |
#Convert to lower case | |
tweet = tweet.lower() | |
#Convert www.* or https?://* to URL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#initialize stopWords | |
stopWords = [] | |
#start replaceTwoOrMore | |
def replaceTwoOrMore(s): | |
#look for 2 or more repetitions of character and replace with the character itself | |
pattern = re.compile(r"(.)\1{1,}", re.DOTALL) | |
return pattern.sub(r"\1\1", s) | |
#end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Read the tweets one by one and process it | |
inpTweets = csv.reader(open('data/sampleTweets.csv', 'rb'), delimiter=',', quotechar='|') | |
tweets = [] | |
for row in inpTweets: | |
sentiment = row[0] | |
tweet = row[1] | |
processedTweet = processTweet(tweet) | |
featureVector = getFeatureVector(processedTweet, stopWords) | |
tweets.append((featureVector, sentiment)); | |
#end loop |
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 6.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|positive|,|@PrincessSuperC Hey Cici sweetheart! Just wanted to let u know I luv u! OH! and will the mixtape drop soon? FANTASY RIDE MAY 5TH!!!!| | |
|positive|,|@Msdebramaye I heard about that contest! Congrats girl!!| | |
|positive|,|UNC!!! NCAA Champs!! Franklin St.: I WAS THERE!! WILD AND CRAZY!!!!!! Nothing like it...EVER http://tinyurl.com/49955t3| | |
|neutral|,|Do you Share More #jokes #quotes #music #photos or #news #articles on #Facebook or #Twitter?| | |
|neutral|,|Good night #Twitter and #TheLegionoftheFallen. 5:45am cimes awfully early!| | |
|neutral|,|I just finished a 2.66 mi run with a pace of 11'14"/mi with Nike+ GPS. #nikeplus #makeitcount| | |
|negative|,|Disappointing day. Attended a car boot sale to raise some funds for the sanctuary, made a total of 88p after the entry fee - sigh| | |
|negative|,|no more taking Irish car bombs with strange Australian women who can drink like rockstars...my head hurts.| | |
|negative|,|Just had some bloodwork done. My arm hurts| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tweets = [(['hey', 'cici', 'luv', 'mixtape', 'drop', 'soon', 'fantasy', 'ride'], 'positive'), | |
(['heard', 'congrats'], 'positive'), | |
(['ncaa', 'franklin', 'wild'], 'positive'), | |
(['share', 'jokes', 'quotes', 'music', 'photos', 'news', 'articles', 'facebook', 'twitter'], 'neutral'), | |
(['night', 'twitter', 'thelegionofthefallen', 'cimes', 'awfully'], 'neutral'), | |
(['finished', 'mi', 'run', 'pace', 'gps', 'nikeplus', 'makeitcount'], 'neutral'), | |
(['disappointing', 'day', 'attended', 'car', 'boot', 'sale', 'raise', 'funds', 'sanctuary', | |
'total', 'entry', 'fee', 'sigh'], 'negative'), | |
(['taking', 'irish', 'car', 'bombs', 'strange', 'australian', 'women', 'drink', 'head', | |
'hurts'], 'negative'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
featureList = ['hey', 'cici', 'luv', 'mixtape', 'drop', 'soon', 'fantasy', 'ride', 'heard', | |
'congrats', 'ncaa', 'franklin', 'wild', 'share', 'jokes', 'quotes', 'music', 'photos', 'news', | |
'articles', 'facebook', 'twitter', 'night', 'twitter', 'thelegionofthefallen', 'cimes', 'awfully', | |
'finished', 'mi', 'run', 'pace', 'gps', 'nikeplus', 'makeitcount', 'disappointing', 'day', 'attended', | |
'car', 'boot', 'sale', 'raise', 'funds', 'sanctuary', 'total', 'entry', 'fee', 'sigh', 'taking', | |
'irish', 'car', 'bombs', 'strange', 'australian', 'women', 'drink', 'head', 'hurts', 'bloodwork', | |
'arm', 'hurts'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
'contains(arm)': True, #notice this | |
'contains(articles)': False, | |
'contains(attended)': False, | |
'contains(australian)': False, | |
'contains(awfully)': False, | |
'contains(bloodwork)': True, #notice this | |
'contains(bombs)': False, | |
'contains(cici)': False, | |
..... |