-
Notifications
You must be signed in to change notification settings - Fork 0
/
boulos_ntwk.py
41 lines (32 loc) · 1010 Bytes
/
boulos_ntwk.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
Create graph to be used at Gephi with scraped tweets
that contains the keyword 'boulos', from november
15 to november 28, 1500 tweets per day.
@author: Bárbara Boechat
@date: 22/02/2021
"""
import json
import sys
from time import sleep
from gephi_usage import *
from utils import write_gephi_files
if __name__ == '__main__':
file = sys.argv[1]
with open(f'boulos/coleta/{file}') as json_file:
tweets = json.load(json_file)
# Create graph of mentions
gephi = Gephi(tweets)
gephi.graph_of_mentions()
date = ''.join(file.split(".json"))
filename = f'boulos/gephi_files/mentions/mentions_{date}'
write_gephi_files(gephi.graph, filename)
sleep(180)
# Create graph of retweets
gephi = Gephi(tweets)
gephi.graph_of_rts()
if gephi.graph.nodes:
date = ''.join(file.split(".json"))
filename = f'boulos/gephi_files/rts/rts_{date}'
write_gephi_files(gephi.graph, filename)
else:
print('0 tweets were quoted ):')