diff options
author | Maurice Laveaux <m.laveaux@student.tue.nl> | 2014-05-22 16:33:24 +0200 |
---|---|---|
committer | Maurice Laveaux <m.laveaux@student.tue.nl> | 2014-05-22 16:33:24 +0200 |
commit | 4f32eedd2bd49837cc297acce399c108e8b558a7 (patch) | |
tree | e80ceb3fdf38db9552b52bd7f0c6b209c6c4bc28 /src/Chapter4/util/TweetFileToGraph.java | |
parent | 1da00321db0aa8c412c3ff1dff5734962ee49240 (diff) | |
download | TwitterDataAnalytics-4f32eedd2bd49837cc297acce399c108e8b558a7.tar.gz |
Removed unused source files
* Removed the shitty examples.
Diffstat (limited to 'src/Chapter4/util/TweetFileToGraph.java')
-rw-r--r-- | src/Chapter4/util/TweetFileToGraph.java | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/src/Chapter4/util/TweetFileToGraph.java b/src/Chapter4/util/TweetFileToGraph.java deleted file mode 100644 index 6cf2e3a..0000000 --- a/src/Chapter4/util/TweetFileToGraph.java +++ /dev/null @@ -1,77 +0,0 @@ -package Chapter4.util; - -import java.io.File; - -import GraphElements.RetweetEdge; -import GraphElements.UserNode; - -import edu.uci.ics.jung.graph.DirectedGraph; -import edu.uci.ics.jung.graph.DirectedSparseGraph; -import edu.uci.ics.jung.graph.util.EdgeType; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.json.JSONException; -import org.json.JSONObject; - -/** - * Some basic functionality to convert files collected - * in Chapter 2 to JUNG graphs. - */ -public class TweetFileToGraph { - - public static DirectedGraph<UserNode, RetweetEdge> getRetweetNetwork(File tweetFile){ - - JSONObject tmp; - - TweetFileProcessor tfp = new TweetFileProcessor(tweetFile); - DirectedSparseGraph<UserNode, RetweetEdge> dsg = new DirectedSparseGraph<UserNode, RetweetEdge>(); - - while (tfp.hasNext()){ - tmp = tfp.next(); - if(tmp==null) - { - continue; - } - //get the author - String user=null; - try { - user = tmp.getJSONObject("user").getString("screen_name"); - } catch (JSONException ex) { - Logger.getLogger(TweetFileToGraph.class.getName()).log(Level.SEVERE, null, ex); - } - if(user==null) - { - continue; - } - //get the retweeted user - try{ - JSONObject retweet = tmp.getJSONObject("retweeted_status"); - String retweeted_user = retweet.getJSONObject("user").getString("screen_name"); - - //make an edge or increment the weight if it exists. - UserNode toUser = new UserNode(retweeted_user); - UserNode fromUser = new UserNode(user); - - dsg.addVertex(toUser); - dsg.addVertex(fromUser); - - RetweetEdge edge = new RetweetEdge(toUser, fromUser); - - if(dsg.containsEdge(edge)){ - dsg.findEdge(fromUser, toUser).incrementRTCount(); - } - else{ - dsg.addEdge(edge, fromUser, toUser); - } - dsg.addEdge(edge, fromUser, toUser, EdgeType.DIRECTED); - } - catch(JSONException ex){ - //the tweet is not a retweet. this is not a problem. - } - - - } - - return dsg; - } -} |