|
| 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 | +} |
0 commit comments