astrodetection 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- astrodetection-0.1.2/PKG-INFO +112 -0
- astrodetection-0.1.2/README.md +69 -0
- astrodetection-0.1.2/pyproject.toml +3 -0
- astrodetection-0.1.2/setup.cfg +4 -0
- astrodetection-0.1.2/setup.py +46 -0
- astrodetection-0.1.2/src/astrodetection/__init__.py +4 -0
- astrodetection-0.1.2/src/astrodetection/faissd3lta.py +730 -0
- astrodetection-0.1.2/src/astrodetection/utils.py +500 -0
- astrodetection-0.1.2/src/astrodetection.egg-info/PKG-INFO +112 -0
- astrodetection-0.1.2/src/astrodetection.egg-info/SOURCES.txt +14 -0
- astrodetection-0.1.2/src/astrodetection.egg-info/dependency_links.txt +1 -0
- astrodetection-0.1.2/src/astrodetection.egg-info/requires.txt +16 -0
- astrodetection-0.1.2/src/astrodetection.egg-info/top_level.txt +2 -0
- astrodetection-0.1.2/src/astrodetection_light/__init__.py +4 -0
- astrodetection-0.1.2/src/astrodetection_light/faissd3lta.py +716 -0
- astrodetection-0.1.2/src/astrodetection_light/utils.py +500 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: astrodetection
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: A Python library for detecting astroturfing (coordinated inauthentic behavior) in social media posts.
|
|
5
|
+
Home-page: https://github.com/savaij/astrodetection
|
|
6
|
+
Author: Francesco Savatteri
|
|
7
|
+
Author-email: astrodetection_python@proton.me
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/savaij/astrodetection/issues
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
15
|
+
Requires-Python: >=3.8
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
Requires-Dist: pandas
|
|
18
|
+
Requires-Dist: networkx
|
|
19
|
+
Requires-Dist: tqdm
|
|
20
|
+
Requires-Dist: demoji
|
|
21
|
+
Requires-Dist: requests
|
|
22
|
+
Requires-Dist: polyleven
|
|
23
|
+
Requires-Dist: ipysigma
|
|
24
|
+
Requires-Dist: numpy
|
|
25
|
+
Provides-Extra: standard
|
|
26
|
+
Requires-Dist: faiss-cpu; extra == "standard"
|
|
27
|
+
Requires-Dist: fasttext; extra == "standard"
|
|
28
|
+
Requires-Dist: gensim; extra == "standard"
|
|
29
|
+
Provides-Extra: light
|
|
30
|
+
Requires-Dist: scikit-learn; extra == "light"
|
|
31
|
+
Dynamic: author
|
|
32
|
+
Dynamic: author-email
|
|
33
|
+
Dynamic: classifier
|
|
34
|
+
Dynamic: description
|
|
35
|
+
Dynamic: description-content-type
|
|
36
|
+
Dynamic: home-page
|
|
37
|
+
Dynamic: license
|
|
38
|
+
Dynamic: project-url
|
|
39
|
+
Dynamic: provides-extra
|
|
40
|
+
Dynamic: requires-dist
|
|
41
|
+
Dynamic: requires-python
|
|
42
|
+
Dynamic: summary
|
|
43
|
+
|
|
44
|
+
# Astrodetection
|
|
45
|
+
|
|
46
|
+
Astrodetection is a Python library designed for detecting astroturfing clues from lists of posts (mainly on X up to now, but not exclusively)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
1. Use the YAML file to configure the environment with conda:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
conda create -n astrodetection_env
|
|
55
|
+
conda activate astrodetection_env
|
|
56
|
+
conda env update -f environment_standard.yml
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Note:** the ```environment_standard.yml``` configuration file uses FAISS and Fasttext libraries for [VIGINUM D3LTA implementation](https://github.com/VIGINUM-FR/D3lta)
|
|
60
|
+
|
|
61
|
+
**If you have compatibility issues, prefer ```environment_light.yml``` and use ```astrodetection_light``` module
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
|
|
65
|
+
You can import directly the main functions:
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from astrodetection import semantic_faiss, prepare_input_data, compute_bot_likelihood_metrics, create_network
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or use them directly:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
import glob
|
|
75
|
+
import pandas as pd
|
|
76
|
+
import os
|
|
77
|
+
import numpy as np
|
|
78
|
+
import astrodetection
|
|
79
|
+
|
|
80
|
+
# Load a single JSON file into a DataFrame
|
|
81
|
+
file = "file_path" # Select the first file
|
|
82
|
+
df = pd.read_json(file)
|
|
83
|
+
df.index = df.index.astype(str) # Compatibility with d3lta
|
|
84
|
+
|
|
85
|
+
# Preprocess the DataFrame
|
|
86
|
+
df = df[df['tweet'].str.len() > 100]
|
|
87
|
+
df = df[df['username'] != 'grok']
|
|
88
|
+
df.index = df.index.astype(str)
|
|
89
|
+
|
|
90
|
+
# Compute matches and scores
|
|
91
|
+
df_filtered, df_emb = astrodetection.prepare_input_data(df, embeddings=df['emb'])
|
|
92
|
+
|
|
93
|
+
matches, df_cluster = astrodetection.semantic_faiss(
|
|
94
|
+
df_filtered.rename(columns={'tweet': 'original'}),
|
|
95
|
+
min_size_txt=0,
|
|
96
|
+
df_embeddings_use=df_emb,
|
|
97
|
+
threshold_grapheme=0.8,
|
|
98
|
+
threshold_language=0.715,
|
|
99
|
+
threshold_semantic=0.9
|
|
100
|
+
) #function taken from D3LTA
|
|
101
|
+
|
|
102
|
+
scores = astrodetection.compute_bot_likelihood_metrics(df, matches=matches)
|
|
103
|
+
|
|
104
|
+
# Create a network
|
|
105
|
+
network = astrodetection.create_network(matches, df)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
# New changes
|
|
109
|
+
|
|
110
|
+
1. _`semantic_faiss`_ function can now take detect only copypastas based on levenshtein distance, ignoring embeddings, if "skip" is passed as argument in _df_embeddings_use_ field.
|
|
111
|
+
|
|
112
|
+
2. _`compute_bot_likelihood_metrics`_ function can now take columns' names as arguments for more customization
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Astrodetection
|
|
2
|
+
|
|
3
|
+
Astrodetection is a Python library designed for detecting astroturfing clues from lists of posts (mainly on X up to now, but not exclusively)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
1. Use the YAML file to configure the environment with conda:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
conda create -n astrodetection_env
|
|
12
|
+
conda activate astrodetection_env
|
|
13
|
+
conda env update -f environment_standard.yml
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**Note:** the ```environment_standard.yml``` configuration file uses FAISS and Fasttext libraries for [VIGINUM D3LTA implementation](https://github.com/VIGINUM-FR/D3lta)
|
|
17
|
+
|
|
18
|
+
**If you have compatibility issues, prefer ```environment_light.yml``` and use ```astrodetection_light``` module
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
You can import directly the main functions:
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from astrodetection import semantic_faiss, prepare_input_data, compute_bot_likelihood_metrics, create_network
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Or use them directly:
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
import glob
|
|
32
|
+
import pandas as pd
|
|
33
|
+
import os
|
|
34
|
+
import numpy as np
|
|
35
|
+
import astrodetection
|
|
36
|
+
|
|
37
|
+
# Load a single JSON file into a DataFrame
|
|
38
|
+
file = "file_path" # Select the first file
|
|
39
|
+
df = pd.read_json(file)
|
|
40
|
+
df.index = df.index.astype(str) # Compatibility with d3lta
|
|
41
|
+
|
|
42
|
+
# Preprocess the DataFrame
|
|
43
|
+
df = df[df['tweet'].str.len() > 100]
|
|
44
|
+
df = df[df['username'] != 'grok']
|
|
45
|
+
df.index = df.index.astype(str)
|
|
46
|
+
|
|
47
|
+
# Compute matches and scores
|
|
48
|
+
df_filtered, df_emb = astrodetection.prepare_input_data(df, embeddings=df['emb'])
|
|
49
|
+
|
|
50
|
+
matches, df_cluster = astrodetection.semantic_faiss(
|
|
51
|
+
df_filtered.rename(columns={'tweet': 'original'}),
|
|
52
|
+
min_size_txt=0,
|
|
53
|
+
df_embeddings_use=df_emb,
|
|
54
|
+
threshold_grapheme=0.8,
|
|
55
|
+
threshold_language=0.715,
|
|
56
|
+
threshold_semantic=0.9
|
|
57
|
+
) #function taken from D3LTA
|
|
58
|
+
|
|
59
|
+
scores = astrodetection.compute_bot_likelihood_metrics(df, matches=matches)
|
|
60
|
+
|
|
61
|
+
# Create a network
|
|
62
|
+
network = astrodetection.create_network(matches, df)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
# New changes
|
|
66
|
+
|
|
67
|
+
1. _`semantic_faiss`_ function can now take detect only copypastas based on levenshtein distance, ignoring embeddings, if "skip" is passed as argument in _df_embeddings_use_ field.
|
|
68
|
+
|
|
69
|
+
2. _`compute_bot_likelihood_metrics`_ function can now take columns' names as arguments for more customization
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name='astrodetection',
|
|
5
|
+
version='0.1.2',
|
|
6
|
+
description='A Python library for detecting astroturfing (coordinated inauthentic behavior) in social media posts.',
|
|
7
|
+
long_description=open('README.md', encoding='utf-8').read(),
|
|
8
|
+
long_description_content_type='text/markdown',
|
|
9
|
+
author='Francesco Savatteri',
|
|
10
|
+
author_email='astrodetection_python@proton.me',
|
|
11
|
+
url='https://github.com/savaij/astrodetection',
|
|
12
|
+
project_urls={
|
|
13
|
+
'Bug Tracker': 'https://github.com/savaij/astrodetection/issues',
|
|
14
|
+
},
|
|
15
|
+
license='MIT',
|
|
16
|
+
packages=find_packages(where="src"),
|
|
17
|
+
package_dir={"": "src"},
|
|
18
|
+
python_requires='>=3.8',
|
|
19
|
+
install_requires=[
|
|
20
|
+
'pandas',
|
|
21
|
+
'networkx',
|
|
22
|
+
'tqdm',
|
|
23
|
+
'demoji',
|
|
24
|
+
'requests',
|
|
25
|
+
'polyleven',
|
|
26
|
+
'ipysigma',
|
|
27
|
+
'numpy',
|
|
28
|
+
],
|
|
29
|
+
extras_require={
|
|
30
|
+
'standard': [
|
|
31
|
+
'faiss-cpu',
|
|
32
|
+
'fasttext',
|
|
33
|
+
'gensim',
|
|
34
|
+
],
|
|
35
|
+
'light': [
|
|
36
|
+
'scikit-learn',
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
classifiers=[
|
|
40
|
+
'Programming Language :: Python :: 3',
|
|
41
|
+
'License :: OSI Approved :: MIT License',
|
|
42
|
+
'Operating System :: OS Independent',
|
|
43
|
+
'Intended Audience :: Science/Research',
|
|
44
|
+
'Topic :: Scientific/Engineering :: Information Analysis',
|
|
45
|
+
],
|
|
46
|
+
)
|