Skip to content

Commit 38cb213

Browse files
releasing version 2
1 parent 28d7e61 commit 38cb213

File tree

15 files changed

+1570
-96093
lines changed

15 files changed

+1570
-96093
lines changed

CSO-Classifier.ipynb

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Loading Libraries"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": null,
13+
"metadata": {},
14+
"outputs": [],
15+
"source": [
16+
"import classifier.misc as misc\n",
17+
"from classifier.syntacticmodule import CSOClassifierSyntactic as synt\n",
18+
"from classifier.semanticmodule import CSOClassifierSemantic as sema\n",
19+
"\n",
20+
"import json"
21+
]
22+
},
23+
{
24+
"cell_type": "markdown",
25+
"metadata": {},
26+
"source": [
27+
"# Loading Paper"
28+
]
29+
},
30+
{
31+
"cell_type": "code",
32+
"execution_count": null,
33+
"metadata": {},
34+
"outputs": [],
35+
"source": [
36+
"paper = {\n",
37+
" \"title\": \"De-anonymizing Social Networks\",\n",
38+
" \"abstract\": \"Operators of online social networks are increasingly sharing potentially \"\n",
39+
" \"sensitive information about users and their relationships with advertisers, application \"\n",
40+
" \"developers, and data-mining researchers. Privacy is typically protected by anonymization, \"\n",
41+
" \"i.e., removing names, addresses, etc. We present a framework for analyzing privacy and \"\n",
42+
" \"anonymity in social networks and develop a new re-identification algorithm targeting \"\n",
43+
" \"anonymized social-network graphs. To demonstrate its effectiveness on real-world networks, \"\n",
44+
" \"we show that a third of the users who can be verified to have accounts on both Twitter, a \"\n",
45+
" \"popular microblogging service, and Flickr, an online photo-sharing site, can be re-identified \"\n",
46+
" \"in the anonymous Twitter graph with only a 12% error rate. Our de-anonymization algorithm is \"\n",
47+
" \"based purely on the network topology, does not require creation of a large number of dummy \"\n",
48+
" \"\\\"sybil\\\" nodes, is robust to noise and all existing defenses, and works even when the overlap \"\n",
49+
" \"between the target network and the adversary's auxiliary information is small.\",\n",
50+
" \"keywords\": \"data mining, data privacy, graph theory, social networking (online)\"\n",
51+
" }\n",
52+
"\n",
53+
" \n",
54+
"\n",
55+
"from IPython.display import display, HTML\n",
56+
"\n",
57+
"display(HTML('<h1>'+paper[\"title\"]+'</h1>'))\n",
58+
"display(HTML('<p><strong>Abstract:</strong> '+paper[\"abstract\"]+'</p>'))\n",
59+
"display(HTML('<p><strong>Keywords:</strong> <i>'+paper[\"keywords\"]+'</i></p>'))"
60+
]
61+
},
62+
{
63+
"cell_type": "markdown",
64+
"metadata": {},
65+
"source": [
66+
"# Load Model, CSO and initialize"
67+
]
68+
},
69+
{
70+
"cell_type": "code",
71+
"execution_count": null,
72+
"metadata": {},
73+
"outputs": [],
74+
"source": [
75+
"cso, model = misc.load_ontology_and_model()\n",
76+
"\n",
77+
"# Passing parematers to the two classes (synt and sema)\n",
78+
"synt_module = synt(cso, paper)\n",
79+
"sema_module = sema(model, cso, paper)\n",
80+
"\n",
81+
"#initializing variable that will contain output\n",
82+
"class_res = {}"
83+
]
84+
},
85+
{
86+
"cell_type": "markdown",
87+
"metadata": {},
88+
"source": [
89+
"# Running"
90+
]
91+
},
92+
{
93+
"cell_type": "code",
94+
"execution_count": null,
95+
"metadata": {},
96+
"outputs": [],
97+
"source": [
98+
"class_res[\"syntactic\"] = synt_module.classify_syntactic()\n",
99+
"class_res[\"semantic\"] = sema_module.classify_semantic()\n",
100+
"\n",
101+
"union = list(set(class_res[\"syntactic\"] + class_res[\"semantic\"]))\n",
102+
"class_res[\"union\"] = union\n",
103+
"\n",
104+
"enhanced = misc.climb_ontology(cso,union)\n",
105+
"class_res[\"enhanced\"] = [x for x in enhanced if x not in union]"
106+
]
107+
},
108+
{
109+
"cell_type": "markdown",
110+
"metadata": {},
111+
"source": [
112+
"# Printing and Saving"
113+
]
114+
},
115+
{
116+
"cell_type": "code",
117+
"execution_count": null,
118+
"metadata": {
119+
"scrolled": true
120+
},
121+
"outputs": [],
122+
"source": [
123+
"print(class_res)\n",
124+
"\n",
125+
"with open('output.json', 'w') as outfile:\n",
126+
" json.dump(class_res, outfile, indent=4)"
127+
]
128+
}
129+
],
130+
"metadata": {
131+
"kernelspec": {
132+
"display_name": "Python 3",
133+
"language": "python",
134+
"name": "python3"
135+
},
136+
"language_info": {
137+
"codemirror_mode": {
138+
"name": "ipython",
139+
"version": 3
140+
},
141+
"file_extension": ".py",
142+
"mimetype": "text/x-python",
143+
"name": "python",
144+
"nbconvert_exporter": "python",
145+
"pygments_lexer": "ipython3",
146+
"version": "3.6.8"
147+
}
148+
},
149+
"nbformat": 4,
150+
"nbformat_minor": 2
151+
}

CSO-Classifier.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
"""
4+
Created on Thu Feb 14 14:43:42 2019
5+
6+
@author: angelosalatino
7+
"""
8+
9+
10+
11+
# In[Loading Libraries]:
12+
13+
14+
import classifier.misc as misc
15+
from classifier.syntacticmodule import CSOClassifierSyntactic as synt
16+
from classifier.semanticmodule import CSOClassifierSemantic as sema
17+
18+
import json
19+
20+
21+
# In[Loading Paper]:
22+
23+
24+
paper = {
25+
"title": "De-anonymizing Social Networks",
26+
"abstract": "Operators of online social networks are increasingly sharing potentially "
27+
"sensitive information about users and their relationships with advertisers, application "
28+
"developers, and data-mining researchers. Privacy is typically protected by anonymization, "
29+
"i.e., removing names, addresses, etc. We present a framework for analyzing privacy and "
30+
"anonymity in social networks and develop a new re-identification algorithm targeting "
31+
"anonymized social-network graphs. To demonstrate its effectiveness on real-world networks, "
32+
"we show that a third of the users who can be verified to have accounts on both Twitter, a "
33+
"popular microblogging service, and Flickr, an online photo-sharing site, can be re-identified "
34+
"in the anonymous Twitter graph with only a 12% error rate. Our de-anonymization algorithm is "
35+
"based purely on the network topology, does not require creation of a large number of dummy "
36+
"\"sybil\" nodes, is robust to noise and all existing defenses, and works even when the overlap "
37+
"between the target network and the adversary's auxiliary information is small.",
38+
"keywords": "data mining, data privacy, graph theory, social networking (online)"
39+
}
40+
41+
42+
print(paper["title"])
43+
print(paper["abstract"])
44+
print(paper["keywords"])
45+
46+
47+
48+
# In[Load Model, CSO and initialize]:
49+
50+
51+
cso, model = misc.load_ontology_and_model()
52+
53+
# Passing parematers to the two classes (synt and sema)
54+
synt_module = synt(cso, paper)
55+
sema_module = sema(model, cso, paper)
56+
57+
#initializing variable that will contain output
58+
class_res = {}
59+
60+
61+
62+
# In[Running]:
63+
64+
65+
class_res["syntactic"] = synt_module.classify_syntactic()
66+
class_res["semantic"] = sema_module.classify_semantic()
67+
68+
union = list(set(class_res["syntactic"] + class_res["semantic"]))
69+
class_res["union"] = union
70+
71+
enhanced = misc.climb_ontology(cso,union)
72+
class_res["enhanced"] = [x for x in enhanced if x not in union]
73+
74+
75+
76+
# In[Printing and Saving]:
77+
78+
79+
print(class_res)
80+
81+
with open('output.json', 'w') as outfile:
82+
json.dump(class_res, outfile, indent=4)
83+

0 commit comments

Comments
 (0)