Commit 90d166d6 authored by Decoupes Remy's avatar Decoupes Remy
Browse files

work on gephi visualization

parent ff3c1fee
......@@ -141,11 +141,12 @@ if __name__ == '__main__':
df_tfidf = tf_idf(df_results["text"].tolist())
df_tfidf["tf_idf_terms"] = df_tfidf.index
df_tfidf = df_tfidf.merge(df_results, on="index_of_tweet")
# prepare to Gephi for graph vizu
# prepare to Gephi for graph vizu: Graph bipartites. Nodes are Newspaper and TF-IDf
news_paper_name = pd.read_csv("./../params/accountsFollowed.csv") # get account (followed by MOOD) names
news_paper_name["retweeted_status.user.id"] = news_paper_name["twitterID"] # prepare for merge
gephi = df_tfidf
gephi["Source"] = gephi["user.id"].apply(lambda x: hashlib.md5(str(x).encode()).hexdigest()) # pseudonimization
# gephi["Source"] = gephi["user.id"].apply(lambda x: hashlib.md5(str(x).encode()).hexdigest()) # pseudonimization
gephi["Source"] = gephi.index # id du lien
gephi["Target"] = gephi["retweeted_status.user.id"]
gephi["Id"] = gephi.index
gephi["Label"] = gephi["tf_idf_terms"]
......@@ -156,9 +157,15 @@ if __name__ == '__main__':
index=False
)
gephi.to_csv("analysis-output/gephi-debug.csv")
# Node: newspapers (MOOD account followed)
gephi_node = pd.DataFrame(gephi["retweeted_status.user.id"].unique(), columns=["retweeted_status.user.id"])
gephi_node["Label"] = gephi_node.merge(news_paper_name, on="retweeted_status.user.id")["account"]
gephi_node["Id"] = gephi_node["retweeted_status.user.id"]
# Node: TF-IDF
gephi_node_sub = pd.DataFrame(gephi["tf_idf_terms"].unique(), columns=["tf_idf_terms"])
gephi_node_sub["Id"] = gephi_node_sub.merge(gephi, on="tf_idf_terms")["Id"]
gephi_node_sub = gephi_node_sub.rename(columns={"tf_idf_terms": "Label", "Id": "Id"})
gephi_node = gephi_node.append(gephi_node_sub)
gephi_node.to_csv(
"analysis-output/acquitaine_script_gephi_node.csv",
index=False
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment