Skip to content

Commit

Permalink
releasing version 2
Browse files Browse the repository at this point in the history
  • Loading branch information
angelosalatino committed May 3, 2019
1 parent 28d7e61 commit 38cb213
Show file tree
Hide file tree
Showing 15 changed files with 1,570 additions and 96,093 deletions.
151 changes: 151 additions & 0 deletions CSO-Classifier.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Loading Libraries"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import classifier.misc as misc\n",
"from classifier.syntacticmodule import CSOClassifierSyntactic as synt\n",
"from classifier.semanticmodule import CSOClassifierSemantic as sema\n",
"\n",
"import json"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Loading Paper"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"paper = {\n",
" \"title\": \"De-anonymizing Social Networks\",\n",
" \"abstract\": \"Operators of online social networks are increasingly sharing potentially \"\n",
" \"sensitive information about users and their relationships with advertisers, application \"\n",
" \"developers, and data-mining researchers. Privacy is typically protected by anonymization, \"\n",
" \"i.e., removing names, addresses, etc. We present a framework for analyzing privacy and \"\n",
" \"anonymity in social networks and develop a new re-identification algorithm targeting \"\n",
" \"anonymized social-network graphs. To demonstrate its effectiveness on real-world networks, \"\n",
" \"we show that a third of the users who can be verified to have accounts on both Twitter, a \"\n",
" \"popular microblogging service, and Flickr, an online photo-sharing site, can be re-identified \"\n",
" \"in the anonymous Twitter graph with only a 12% error rate. Our de-anonymization algorithm is \"\n",
" \"based purely on the network topology, does not require creation of a large number of dummy \"\n",
" \"\\\"sybil\\\" nodes, is robust to noise and all existing defenses, and works even when the overlap \"\n",
" \"between the target network and the adversary's auxiliary information is small.\",\n",
" \"keywords\": \"data mining, data privacy, graph theory, social networking (online)\"\n",
" }\n",
"\n",
" \n",
"\n",
"from IPython.display import display, HTML\n",
"\n",
"display(HTML('<h1>'+paper[\"title\"]+'</h1>'))\n",
"display(HTML('<p><strong>Abstract:</strong> '+paper[\"abstract\"]+'</p>'))\n",
"display(HTML('<p><strong>Keywords:</strong> <i>'+paper[\"keywords\"]+'</i></p>'))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Load Model, CSO and initialize"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"cso, model = misc.load_ontology_and_model()\n",
"\n",
"# Passing parematers to the two classes (synt and sema)\n",
"synt_module = synt(cso, paper)\n",
"sema_module = sema(model, cso, paper)\n",
"\n",
"#initializing variable that will contain output\n",
"class_res = {}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Running"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"class_res[\"syntactic\"] = synt_module.classify_syntactic()\n",
"class_res[\"semantic\"] = sema_module.classify_semantic()\n",
"\n",
"union = list(set(class_res[\"syntactic\"] + class_res[\"semantic\"]))\n",
"class_res[\"union\"] = union\n",
"\n",
"enhanced = misc.climb_ontology(cso,union)\n",
"class_res[\"enhanced\"] = [x for x in enhanced if x not in union]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Printing and Saving"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"print(class_res)\n",
"\n",
"with open('output.json', 'w') as outfile:\n",
" json.dump(class_res, outfile, indent=4)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
83 changes: 83 additions & 0 deletions CSO-Classifier.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 14 14:43:42 2019
@author: angelosalatino
"""



# In[Loading Libraries]:


import classifier.misc as misc
from classifier.syntacticmodule import CSOClassifierSyntactic as synt
from classifier.semanticmodule import CSOClassifierSemantic as sema

import json


# In[Loading Paper]:


paper = {
"title": "De-anonymizing Social Networks",
"abstract": "Operators of online social networks are increasingly sharing potentially "
"sensitive information about users and their relationships with advertisers, application "
"developers, and data-mining researchers. Privacy is typically protected by anonymization, "
"i.e., removing names, addresses, etc. We present a framework for analyzing privacy and "
"anonymity in social networks and develop a new re-identification algorithm targeting "
"anonymized social-network graphs. To demonstrate its effectiveness on real-world networks, "
"we show that a third of the users who can be verified to have accounts on both Twitter, a "
"popular microblogging service, and Flickr, an online photo-sharing site, can be re-identified "
"in the anonymous Twitter graph with only a 12% error rate. Our de-anonymization algorithm is "
"based purely on the network topology, does not require creation of a large number of dummy "
"\"sybil\" nodes, is robust to noise and all existing defenses, and works even when the overlap "
"between the target network and the adversary's auxiliary information is small.",
"keywords": "data mining, data privacy, graph theory, social networking (online)"
}


print(paper["title"])
print(paper["abstract"])
print(paper["keywords"])



# In[Load Model, CSO and initialize]:


cso, model = misc.load_ontology_and_model()

# Passing parematers to the two classes (synt and sema)
synt_module = synt(cso, paper)
sema_module = sema(model, cso, paper)

#initializing variable that will contain output
class_res = {}



# In[Running]:


class_res["syntactic"] = synt_module.classify_syntactic()
class_res["semantic"] = sema_module.classify_semantic()

union = list(set(class_res["syntactic"] + class_res["semantic"]))
class_res["union"] = union

enhanced = misc.climb_ontology(cso,union)
class_res["enhanced"] = [x for x in enhanced if x not in union]



# In[Printing and Saving]:


print(class_res)

with open('output.json', 'w') as outfile:
json.dump(class_res, outfile, indent=4)

Loading

0 comments on commit 38cb213

Please sign in to comment.