// // Class for incoming tweets, determines if they are emotions and categorises them // General handler of data and parser // // Ben Alun-Jones // March 13th 2010 class Emotion{ //TwitterID Long userid; Long nFollowers; Long nFriends; //How much they use Twitter Long nUpdates; String Location; String tweetText; int Emo; boolean valid; String UserImageURL; String name; //constructor Emotion(Status tweet){ User thisGuy = tweet.user(); nFriends = thisGuy.friendsCount(); nFollowers = thisGuy.followersCount(); userid = thisGuy.id(); nUpdates = thisGuy.statusesCount(); valid = false; getEmotion(tweet.text()); UserImageURL = thisGuy.profileBackgroundImageURL(); name = thisGuy.name(); } void getEmotion(String tweetText){ //tweetText = new RiString(tweeted); tweetText.toLowerCase(); if(tweetText.indexOf("anger") != -1 || tweetText.indexOf("hate") != -1 ){ Emo = ANGER; valid = true; } if(tweetText.indexOf("joy") != -1 || tweetText.indexOf("happy") != -1 ){ Emo = JOY; valid = true; } if(tweetText.indexOf("love") != -1 ){ Emo = LOVE; valid = true; } if(tweetText.indexOf("suprise") != -1 || tweetText.indexOf("surprise") != -1 || tweetText.indexOf("shock") != -1 ){ Emo = SURPRISE; valid = true; } if(tweetText.indexOf("sad") != -1 || tweetText.indexOf("upset") != -1 ){ Emo = SADNESS; valid = true; } if(tweetText.indexOf("fear") != -1 || tweetText.indexOf("afraid") != -1 ){ Emo = FEAR; valid = true; } //if(valid) println(Emo); } boolean isEmotion(){ return valid; } Long getUserID(){ return userid; } Long getNumFollowers(){ return nFollowers; } Long getNumFriends(){ return nFriends; } Long getNumUpdates(){ return nUpdates; } String getLocation(){ return Location; } String getTweetText(){ return tweetText; } int getEmotion(){ return Emo; } String getImURL(){ return UserImageURL; } String getUserName(){ return name; } // // draw the cube in the buffer // public void drawBuffer(PGraphics buffer) { // color idColor = getColor(id); // buffer.fill(idColor); // drawCube(buffer); // } // // private void drawCube(PGraphics g) { // g.pushMatrix(); // g.translate(x, y, z); // g.ellipse(w); // g.popMatrix(); // } }