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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
|
%global _empty_manifest_terminate_build 0
Name: python-coordination-network-toolkit
Version: 1.5.2
Release: 1
Summary: Tools for computing networks of coordinated behaviour on social media
License: MIT
URL: https://github.com/QUT-Digital-Observatory/coordination-network-toolkit
Source0: https://mirrors.aliyun.com/pypi/web/packages/36/a5/0650528d5bb79641c00782ff8641d6863593eacfb63c612ed2d338c53c88/coordination_network_toolkit-1.5.2.tar.gz
BuildArch: noarch
Requires: python3-urllib3
Requires: python3-regex
Requires: python3-requests
Requires: python3-networkx
Requires: python3-twarc
Requires: python3-nox
Requires: python3-pytest
Requires: python3-pip-tools
%description
# Coordination Network Toolkit
A small command line tool and set of functions for studying coordination networks
in Twitter and other social media data.
## Rationale and Background
<img src="https://i.ibb.co/qJVwBKR/coretweet-min-Weight2-coloured-By-Account-Status.png" alt="Network visualisation of a co-retweet network" width="400" height="400" align="right">
Social media activity doesn't occur in a vaccuum. Individuals on social media are often taking part in *coordinated activities* such as protest movements or interest-based communities.
Social media platforms are also used strategically to boost particular messages in line with political campaign goals or for commercial profit and scamming. This involves multiple accounts posting or reposting the same content, repeatedly and within a short time window (e.g. within 1 minute).
This software provides a toolkit to detect coordinated activity on social media and to generate networks that map the actors and their relationships. It provides a general purpose toolkit for multiple types of coordinated activity on any type of social media platform.
Fundamentally this toolkit produces networks where the nodes are accounts, and the weighted edges between these accounts are the number of messages from those accounts that meet some criterion for a type of *coordination*. This toolkit already implements several approaches to detecting different types of coordination, and is intended to be extensible to more cases in the future.
Firstly, it includes functionality for *co-tweeting* and *co-retweeting* (Keller et al., 2019; Schafer et al., 2017), where accounts post exactly the same text (co-tweets) or repost the same post within a short time window (co-retweets). Secondly, it includes functionality for *co-link* analysis, where multiple accounts post the same URLs repeatedly and in a short time window of each other (Giglietto et al., 2020). Thirdly, it adds two new types of network types: *co-reply*, where accounts are replying to the same post repeatedly together; and *co-similarity*, where accounts post similar text (but not exact duplicates), which relaxes the strict assumption of co-tweeting.
### Types of Coordination Networks
Briefly, the following network types are supported. For more information see the [documentation](docs/network_types.md)
1. Co-retweet: reposting the same post
2. Co-tweet: posting identical text
3. Co-similarity: posting similar text (Jaccard similarity or user-defined)
4. Co-link: posting the same link
5. Co-reply: replying to the same post
6. Co-post: posting any time of message within the same time window
The default time window is 60 seconds for all network types.
## Reading List
Giglietto, F., Righetti, N., Rossi, L., & Marino, G. (2020). It takes a village to manipulate the media: coordinated link sharing behavior during 2018 and 2019 Italian elections. Information, Communication and Society, 1–25.
Graham, T., Bruns, A., Zhu, G., & Campbell, R. (2020). Like a virus: The coordinated spread of coronavirus disinformation. Report commissioned for the Centre for Responsible Technology.
Keller, F. B., Schoch, D., Stier, S., & Yang, J. (2020). Political Astroturfing on Twitter: How to coordinate a disinformation Campaign. Political Communication, 37(2), 256-280.
Schafer, F., Evert, S., & Heinrich, P. (2017). Japan’s 2014 General Election: Political Bots, Right-Wing Internet Activism, and Prime Minister Shinz Abe’s Hidden Nationalist Agenda. Big Data, 5(4), 294–309.
## Installation and Requirements
This tool requires a working Python 3.6 (or later) environment.
This tool can be installed from pip - this will handle installing the necessary
dependencies.
`pip install coordination_network_toolkit`
Once you have installed, you can use the toolkit in either of two ways:
1. As a command-line tool (run `compute_networks --help` to find out how)
2. As a Python library (`import coordination_network_toolkit`)
## Basic Usage
Using this tool requires:
1. Collecting data from the social media platform of choice
2. Preparing or preprocessing the data into one of the formats the tool accepts:
- either a specific CSV format that works across all platforms OR
- using the platform native format (currently Twitter JSON from both
V1.1 and V2 APIs, including the Twitter Academic track, are supported)
3. Preprocessing the raw data into an SQLite database to setup the data structures for
efficient computation of the different networks
4. Generating the network of choice, storing the output in a specified file.
## Examples
This is just a quick example - see also [the tutorial.](docs/tutorial.md)
### Worked example - CLI tool
1. Collect Twitter data in the native Twitter JSON format using
[twarc](https://github.com/docnow/twarc/), from either the V1.1 and V2 APIs
- `twarc search '#banana' --output banana.json`
- `twarc2 search --limit 1000 --archive '#purple' purple.json `
2. Bring the data into a local database file called processed_bananas.db. The original
data file is not modified in any way. The toolkit will handle processing the Twitter
JSON formats into the necessary format, including handling things like retweets, replies,
urls, and extracting the text of the tweet. It will also handle deduplication, so if a
tweet is present more than once only the first instance will be recorded.
- `compute_networks processed_bananas.db preprocess --format twitter_json banana.json purple.json`
3. Calculate a retweet network, saving the output to a graphml format that can be
directly opened in a tool like (Gephi)[https://gephi.org]. These settings indicate that
if two users have retweeted the same tweet within 60 seconds of each other, there is a
potential link.
- `compute_networks processed_bananas.db compute co_retweet --time_window 60 --output_file bananas_retweet_60s.graphml --output_format graphml`
3. Calculate a co-link network, again saving the output in graphml format. By default
this will use the plain text of the URL for matching, so the output here will confuse
urls that are shortened.
- `compute_networks processed_bananas.db compute co_link --time_window 60 --output_file bananas_colink_unresolved_60s.graphml --output_format graphml`
4. Resolve collected URLs, to handle link shortening services. Note that this process
is intentionally rate limited to resolve no more than 25 urls/second. Once resolved,
URLs will not be retried, so you can safely run this command again.
- `compute_networks processed_bananas.db resolve_urls`
5. Calculate the co-link network, this time using the resolved urls.
- `compute_networks processed_bananas.db compute co_link --time_window 60 --output_file bananas_colink_resolved_60s.graphml --output_format graphml --resolved`
### Python library usage example
You can find the following example as a Jupyter notebook you can run yourself in
`examples/example.ipynb`.
```
import coordination_network_toolkit as coord_net_tk
import networkx as nx
# Preprocess CSV data located at '/path/to/your/csv_file.csv' into
# the database located at /path/to/your/db - if no db file
# exists here it will be created for you.
db_name = '/path/to/your/db.db'
coord_net_tk.preprocess.preprocess_csv_files(db_name, ['/path/to/your/csv_file.csv'])
# Calculate similarity network
coord_net_tk.compute_networks.compute_co_similar_tweet(db_name, 60)
# Load data as a networkx graph
similarity_graph = coord_net_tk.graph.load_networkx_graph(db_name, "co_similar_tweet")
# Play with the graph!
for g in nx.connected_components(similarity_graph):
print(g)
```
## Supported Input Formats
### Twitter
JSON data from V1.1 and V2 of the Twitter API can be ingested directly.
### CSV (All other platforms)
To use the CSV ingest format, construct a CSV with a header and the following columns.
The names of the columns don't matter but the order does.
- message_id: the unique identifier of the message on the platform
- user_id: the unique identifier of the user on the platform
- username: the text of the username (only used for display)
- repost_id: if the message is a verbatim report of another message (such as a retweet
or reblog), this is the identifier of that other message. Empty strings will be
converted to null
- reply_id: if the message is in reply to another message, the identifier for that other
message. Empty strings will be converted to null.
- message: the text of the message.
- timestamp: A timestamp in seconds for the message. The absolute offset does not matter,
but it needs to be consistent across all rows
- urls: A space delimited string containing all of the URLs in the message
## Cite the Coordination Network Toolkit
Graham, Timothy; QUT Digital Observatory; (2020): Coordination Network Toolkit.
Queensland University of Technology. (Software)
https://doi.org/10.25912/RDF_1632782596538
## Looking for Help?
Are you getting stuck somewhere or want to ask questions about using this toolkit? Please open an issue or bring your questions to the Digital Observatory's fortnightly [office hours](https://research.qut.edu.au/digitalobservatory/office-hours/).
%package -n python3-coordination-network-toolkit
Summary: Tools for computing networks of coordinated behaviour on social media
Provides: python-coordination-network-toolkit
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-coordination-network-toolkit
# Coordination Network Toolkit
A small command line tool and set of functions for studying coordination networks
in Twitter and other social media data.
## Rationale and Background
<img src="https://i.ibb.co/qJVwBKR/coretweet-min-Weight2-coloured-By-Account-Status.png" alt="Network visualisation of a co-retweet network" width="400" height="400" align="right">
Social media activity doesn't occur in a vaccuum. Individuals on social media are often taking part in *coordinated activities* such as protest movements or interest-based communities.
Social media platforms are also used strategically to boost particular messages in line with political campaign goals or for commercial profit and scamming. This involves multiple accounts posting or reposting the same content, repeatedly and within a short time window (e.g. within 1 minute).
This software provides a toolkit to detect coordinated activity on social media and to generate networks that map the actors and their relationships. It provides a general purpose toolkit for multiple types of coordinated activity on any type of social media platform.
Fundamentally this toolkit produces networks where the nodes are accounts, and the weighted edges between these accounts are the number of messages from those accounts that meet some criterion for a type of *coordination*. This toolkit already implements several approaches to detecting different types of coordination, and is intended to be extensible to more cases in the future.
Firstly, it includes functionality for *co-tweeting* and *co-retweeting* (Keller et al., 2019; Schafer et al., 2017), where accounts post exactly the same text (co-tweets) or repost the same post within a short time window (co-retweets). Secondly, it includes functionality for *co-link* analysis, where multiple accounts post the same URLs repeatedly and in a short time window of each other (Giglietto et al., 2020). Thirdly, it adds two new types of network types: *co-reply*, where accounts are replying to the same post repeatedly together; and *co-similarity*, where accounts post similar text (but not exact duplicates), which relaxes the strict assumption of co-tweeting.
### Types of Coordination Networks
Briefly, the following network types are supported. For more information see the [documentation](docs/network_types.md)
1. Co-retweet: reposting the same post
2. Co-tweet: posting identical text
3. Co-similarity: posting similar text (Jaccard similarity or user-defined)
4. Co-link: posting the same link
5. Co-reply: replying to the same post
6. Co-post: posting any time of message within the same time window
The default time window is 60 seconds for all network types.
## Reading List
Giglietto, F., Righetti, N., Rossi, L., & Marino, G. (2020). It takes a village to manipulate the media: coordinated link sharing behavior during 2018 and 2019 Italian elections. Information, Communication and Society, 1–25.
Graham, T., Bruns, A., Zhu, G., & Campbell, R. (2020). Like a virus: The coordinated spread of coronavirus disinformation. Report commissioned for the Centre for Responsible Technology.
Keller, F. B., Schoch, D., Stier, S., & Yang, J. (2020). Political Astroturfing on Twitter: How to coordinate a disinformation Campaign. Political Communication, 37(2), 256-280.
Schafer, F., Evert, S., & Heinrich, P. (2017). Japan’s 2014 General Election: Political Bots, Right-Wing Internet Activism, and Prime Minister Shinz Abe’s Hidden Nationalist Agenda. Big Data, 5(4), 294–309.
## Installation and Requirements
This tool requires a working Python 3.6 (or later) environment.
This tool can be installed from pip - this will handle installing the necessary
dependencies.
`pip install coordination_network_toolkit`
Once you have installed, you can use the toolkit in either of two ways:
1. As a command-line tool (run `compute_networks --help` to find out how)
2. As a Python library (`import coordination_network_toolkit`)
## Basic Usage
Using this tool requires:
1. Collecting data from the social media platform of choice
2. Preparing or preprocessing the data into one of the formats the tool accepts:
- either a specific CSV format that works across all platforms OR
- using the platform native format (currently Twitter JSON from both
V1.1 and V2 APIs, including the Twitter Academic track, are supported)
3. Preprocessing the raw data into an SQLite database to setup the data structures for
efficient computation of the different networks
4. Generating the network of choice, storing the output in a specified file.
## Examples
This is just a quick example - see also [the tutorial.](docs/tutorial.md)
### Worked example - CLI tool
1. Collect Twitter data in the native Twitter JSON format using
[twarc](https://github.com/docnow/twarc/), from either the V1.1 and V2 APIs
- `twarc search '#banana' --output banana.json`
- `twarc2 search --limit 1000 --archive '#purple' purple.json `
2. Bring the data into a local database file called processed_bananas.db. The original
data file is not modified in any way. The toolkit will handle processing the Twitter
JSON formats into the necessary format, including handling things like retweets, replies,
urls, and extracting the text of the tweet. It will also handle deduplication, so if a
tweet is present more than once only the first instance will be recorded.
- `compute_networks processed_bananas.db preprocess --format twitter_json banana.json purple.json`
3. Calculate a retweet network, saving the output to a graphml format that can be
directly opened in a tool like (Gephi)[https://gephi.org]. These settings indicate that
if two users have retweeted the same tweet within 60 seconds of each other, there is a
potential link.
- `compute_networks processed_bananas.db compute co_retweet --time_window 60 --output_file bananas_retweet_60s.graphml --output_format graphml`
3. Calculate a co-link network, again saving the output in graphml format. By default
this will use the plain text of the URL for matching, so the output here will confuse
urls that are shortened.
- `compute_networks processed_bananas.db compute co_link --time_window 60 --output_file bananas_colink_unresolved_60s.graphml --output_format graphml`
4. Resolve collected URLs, to handle link shortening services. Note that this process
is intentionally rate limited to resolve no more than 25 urls/second. Once resolved,
URLs will not be retried, so you can safely run this command again.
- `compute_networks processed_bananas.db resolve_urls`
5. Calculate the co-link network, this time using the resolved urls.
- `compute_networks processed_bananas.db compute co_link --time_window 60 --output_file bananas_colink_resolved_60s.graphml --output_format graphml --resolved`
### Python library usage example
You can find the following example as a Jupyter notebook you can run yourself in
`examples/example.ipynb`.
```
import coordination_network_toolkit as coord_net_tk
import networkx as nx
# Preprocess CSV data located at '/path/to/your/csv_file.csv' into
# the database located at /path/to/your/db - if no db file
# exists here it will be created for you.
db_name = '/path/to/your/db.db'
coord_net_tk.preprocess.preprocess_csv_files(db_name, ['/path/to/your/csv_file.csv'])
# Calculate similarity network
coord_net_tk.compute_networks.compute_co_similar_tweet(db_name, 60)
# Load data as a networkx graph
similarity_graph = coord_net_tk.graph.load_networkx_graph(db_name, "co_similar_tweet")
# Play with the graph!
for g in nx.connected_components(similarity_graph):
print(g)
```
## Supported Input Formats
### Twitter
JSON data from V1.1 and V2 of the Twitter API can be ingested directly.
### CSV (All other platforms)
To use the CSV ingest format, construct a CSV with a header and the following columns.
The names of the columns don't matter but the order does.
- message_id: the unique identifier of the message on the platform
- user_id: the unique identifier of the user on the platform
- username: the text of the username (only used for display)
- repost_id: if the message is a verbatim report of another message (such as a retweet
or reblog), this is the identifier of that other message. Empty strings will be
converted to null
- reply_id: if the message is in reply to another message, the identifier for that other
message. Empty strings will be converted to null.
- message: the text of the message.
- timestamp: A timestamp in seconds for the message. The absolute offset does not matter,
but it needs to be consistent across all rows
- urls: A space delimited string containing all of the URLs in the message
## Cite the Coordination Network Toolkit
Graham, Timothy; QUT Digital Observatory; (2020): Coordination Network Toolkit.
Queensland University of Technology. (Software)
https://doi.org/10.25912/RDF_1632782596538
## Looking for Help?
Are you getting stuck somewhere or want to ask questions about using this toolkit? Please open an issue or bring your questions to the Digital Observatory's fortnightly [office hours](https://research.qut.edu.au/digitalobservatory/office-hours/).
%package help
Summary: Development documents and examples for coordination-network-toolkit
Provides: python3-coordination-network-toolkit-doc
%description help
# Coordination Network Toolkit
A small command line tool and set of functions for studying coordination networks
in Twitter and other social media data.
## Rationale and Background
<img src="https://i.ibb.co/qJVwBKR/coretweet-min-Weight2-coloured-By-Account-Status.png" alt="Network visualisation of a co-retweet network" width="400" height="400" align="right">
Social media activity doesn't occur in a vaccuum. Individuals on social media are often taking part in *coordinated activities* such as protest movements or interest-based communities.
Social media platforms are also used strategically to boost particular messages in line with political campaign goals or for commercial profit and scamming. This involves multiple accounts posting or reposting the same content, repeatedly and within a short time window (e.g. within 1 minute).
This software provides a toolkit to detect coordinated activity on social media and to generate networks that map the actors and their relationships. It provides a general purpose toolkit for multiple types of coordinated activity on any type of social media platform.
Fundamentally this toolkit produces networks where the nodes are accounts, and the weighted edges between these accounts are the number of messages from those accounts that meet some criterion for a type of *coordination*. This toolkit already implements several approaches to detecting different types of coordination, and is intended to be extensible to more cases in the future.
Firstly, it includes functionality for *co-tweeting* and *co-retweeting* (Keller et al., 2019; Schafer et al., 2017), where accounts post exactly the same text (co-tweets) or repost the same post within a short time window (co-retweets). Secondly, it includes functionality for *co-link* analysis, where multiple accounts post the same URLs repeatedly and in a short time window of each other (Giglietto et al., 2020). Thirdly, it adds two new types of network types: *co-reply*, where accounts are replying to the same post repeatedly together; and *co-similarity*, where accounts post similar text (but not exact duplicates), which relaxes the strict assumption of co-tweeting.
### Types of Coordination Networks
Briefly, the following network types are supported. For more information see the [documentation](docs/network_types.md)
1. Co-retweet: reposting the same post
2. Co-tweet: posting identical text
3. Co-similarity: posting similar text (Jaccard similarity or user-defined)
4. Co-link: posting the same link
5. Co-reply: replying to the same post
6. Co-post: posting any time of message within the same time window
The default time window is 60 seconds for all network types.
## Reading List
Giglietto, F., Righetti, N., Rossi, L., & Marino, G. (2020). It takes a village to manipulate the media: coordinated link sharing behavior during 2018 and 2019 Italian elections. Information, Communication and Society, 1–25.
Graham, T., Bruns, A., Zhu, G., & Campbell, R. (2020). Like a virus: The coordinated spread of coronavirus disinformation. Report commissioned for the Centre for Responsible Technology.
Keller, F. B., Schoch, D., Stier, S., & Yang, J. (2020). Political Astroturfing on Twitter: How to coordinate a disinformation Campaign. Political Communication, 37(2), 256-280.
Schafer, F., Evert, S., & Heinrich, P. (2017). Japan’s 2014 General Election: Political Bots, Right-Wing Internet Activism, and Prime Minister Shinz Abe’s Hidden Nationalist Agenda. Big Data, 5(4), 294–309.
## Installation and Requirements
This tool requires a working Python 3.6 (or later) environment.
This tool can be installed from pip - this will handle installing the necessary
dependencies.
`pip install coordination_network_toolkit`
Once you have installed, you can use the toolkit in either of two ways:
1. As a command-line tool (run `compute_networks --help` to find out how)
2. As a Python library (`import coordination_network_toolkit`)
## Basic Usage
Using this tool requires:
1. Collecting data from the social media platform of choice
2. Preparing or preprocessing the data into one of the formats the tool accepts:
- either a specific CSV format that works across all platforms OR
- using the platform native format (currently Twitter JSON from both
V1.1 and V2 APIs, including the Twitter Academic track, are supported)
3. Preprocessing the raw data into an SQLite database to setup the data structures for
efficient computation of the different networks
4. Generating the network of choice, storing the output in a specified file.
## Examples
This is just a quick example - see also [the tutorial.](docs/tutorial.md)
### Worked example - CLI tool
1. Collect Twitter data in the native Twitter JSON format using
[twarc](https://github.com/docnow/twarc/), from either the V1.1 and V2 APIs
- `twarc search '#banana' --output banana.json`
- `twarc2 search --limit 1000 --archive '#purple' purple.json `
2. Bring the data into a local database file called processed_bananas.db. The original
data file is not modified in any way. The toolkit will handle processing the Twitter
JSON formats into the necessary format, including handling things like retweets, replies,
urls, and extracting the text of the tweet. It will also handle deduplication, so if a
tweet is present more than once only the first instance will be recorded.
- `compute_networks processed_bananas.db preprocess --format twitter_json banana.json purple.json`
3. Calculate a retweet network, saving the output to a graphml format that can be
directly opened in a tool like (Gephi)[https://gephi.org]. These settings indicate that
if two users have retweeted the same tweet within 60 seconds of each other, there is a
potential link.
- `compute_networks processed_bananas.db compute co_retweet --time_window 60 --output_file bananas_retweet_60s.graphml --output_format graphml`
3. Calculate a co-link network, again saving the output in graphml format. By default
this will use the plain text of the URL for matching, so the output here will confuse
urls that are shortened.
- `compute_networks processed_bananas.db compute co_link --time_window 60 --output_file bananas_colink_unresolved_60s.graphml --output_format graphml`
4. Resolve collected URLs, to handle link shortening services. Note that this process
is intentionally rate limited to resolve no more than 25 urls/second. Once resolved,
URLs will not be retried, so you can safely run this command again.
- `compute_networks processed_bananas.db resolve_urls`
5. Calculate the co-link network, this time using the resolved urls.
- `compute_networks processed_bananas.db compute co_link --time_window 60 --output_file bananas_colink_resolved_60s.graphml --output_format graphml --resolved`
### Python library usage example
You can find the following example as a Jupyter notebook you can run yourself in
`examples/example.ipynb`.
```
import coordination_network_toolkit as coord_net_tk
import networkx as nx
# Preprocess CSV data located at '/path/to/your/csv_file.csv' into
# the database located at /path/to/your/db - if no db file
# exists here it will be created for you.
db_name = '/path/to/your/db.db'
coord_net_tk.preprocess.preprocess_csv_files(db_name, ['/path/to/your/csv_file.csv'])
# Calculate similarity network
coord_net_tk.compute_networks.compute_co_similar_tweet(db_name, 60)
# Load data as a networkx graph
similarity_graph = coord_net_tk.graph.load_networkx_graph(db_name, "co_similar_tweet")
# Play with the graph!
for g in nx.connected_components(similarity_graph):
print(g)
```
## Supported Input Formats
### Twitter
JSON data from V1.1 and V2 of the Twitter API can be ingested directly.
### CSV (All other platforms)
To use the CSV ingest format, construct a CSV with a header and the following columns.
The names of the columns don't matter but the order does.
- message_id: the unique identifier of the message on the platform
- user_id: the unique identifier of the user on the platform
- username: the text of the username (only used for display)
- repost_id: if the message is a verbatim report of another message (such as a retweet
or reblog), this is the identifier of that other message. Empty strings will be
converted to null
- reply_id: if the message is in reply to another message, the identifier for that other
message. Empty strings will be converted to null.
- message: the text of the message.
- timestamp: A timestamp in seconds for the message. The absolute offset does not matter,
but it needs to be consistent across all rows
- urls: A space delimited string containing all of the URLs in the message
## Cite the Coordination Network Toolkit
Graham, Timothy; QUT Digital Observatory; (2020): Coordination Network Toolkit.
Queensland University of Technology. (Software)
https://doi.org/10.25912/RDF_1632782596538
## Looking for Help?
Are you getting stuck somewhere or want to ask questions about using this toolkit? Please open an issue or bring your questions to the Digital Observatory's fortnightly [office hours](https://research.qut.edu.au/digitalobservatory/office-hours/).
%prep
%autosetup -n coordination_network_toolkit-1.5.2
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-coordination-network-toolkit -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Fri Jun 09 2023 Python_Bot <Python_Bot@openeuler.org> - 1.5.2-1
- Package Spec generated
|