From 2811ce22be2aae024fd5a52844762d0e3a472b63 Mon Sep 17 00:00:00 2001 From: Ronan Kervella Date: Thu, 27 Dec 2012 11:46:59 +0100 Subject: [PATCH] Ajout userId dans fichier resultat --- tweetsToJson.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tweetsToJson.py b/tweetsToJson.py index 2323778..a697b18 100755 --- a/tweetsToJson.py +++ b/tweetsToJson.py @@ -17,7 +17,7 @@ def extractTweets(fileName): file = open(fileName) json_str = file.read() data = json.loads(json_str) - + print("Parsing "+fileName+" ...") for tweet in data['results']: nTweet = Tweet() nTweet.id = tweet['id'] @@ -112,7 +112,7 @@ def writeJson(tweetList, outputFile): for tweet in tweetList: if not any (tweet.userName == node["nodeName"] for node in nodeList): - nodeList.append({"nodeName":tweet.userName, "avatar": tweet.profileImgUrlHttp, "nodeScore":compute_user_score(tweet.userName, tweetList), "webSite":False}) + nodeList.append({"userId":tweet.user, "nodeName":tweet.userName, "avatar": tweet.profileImgUrlHttp, "nodeScore":compute_user_score(tweet.userName, tweetList), "webSite":False}) if len(tweet.urls) > 0: for url in tweet.urls: @@ -122,7 +122,7 @@ def writeJson(tweetList, outputFile): edgesList.append({"source":tweet.userName,"destination":url_hostname, "url":url ,"date": tweet.date}) for mention in tweet.userMentions: if not any(mention["name"] == node["nodeName"] for node in nodeList): - nodeList.append({"nodeName":mention["name"],"nodeScore":compute_user_score(mention["name"],tweetList), "webSite":False}) + nodeList.append({"userId":mention["screenName"] ,"nodeName":mention["name"],"nodeScore":compute_user_score(mention["name"],tweetList), "webSite":False}) edgesList.append({"source":tweet.userName,"destination":mention["name"], "date":tweet.date, "content":tweet.text}) edgesList.sort(key=lambda r: r["date"]) -- 2.43.0