|
13 | 13 | },
|
14 | 14 | {
|
15 | 15 | "cell_type": "code",
|
16 |
| - "execution_count": 107, |
| 16 | + "execution_count": 1, |
17 | 17 | "metadata": {},
|
18 | 18 | "outputs": [],
|
19 | 19 | "source": [
|
|
25 | 25 | },
|
26 | 26 | {
|
27 | 27 | "cell_type": "code",
|
28 |
| - "execution_count": 146, |
| 28 | + "execution_count": 50, |
29 | 29 | "metadata": {},
|
30 | 30 | "outputs": [],
|
31 | 31 | "source": [
|
|
34 | 34 | },
|
35 | 35 | {
|
36 | 36 | "cell_type": "code",
|
37 |
| - "execution_count": 116, |
| 37 | + "execution_count": 51, |
38 | 38 | "metadata": {},
|
39 | 39 | "outputs": [],
|
40 | 40 | "source": [
|
|
43 | 43 | },
|
44 | 44 | {
|
45 | 45 | "cell_type": "code",
|
46 |
| - "execution_count": 117, |
| 46 | + "execution_count": 52, |
47 | 47 | "metadata": {},
|
48 | 48 | "outputs": [],
|
49 | 49 | "source": [
|
|
53 | 53 | },
|
54 | 54 | {
|
55 | 55 | "cell_type": "code",
|
56 |
| - "execution_count": 118, |
| 56 | + "execution_count": 53, |
57 | 57 | "metadata": {},
|
58 | 58 | "outputs": [],
|
59 | 59 | "source": [
|
|
62 | 62 | },
|
63 | 63 | {
|
64 | 64 | "cell_type": "code",
|
65 |
| - "execution_count": 119, |
| 65 | + "execution_count": 54, |
66 | 66 | "metadata": {},
|
67 | 67 | "outputs": [],
|
68 | 68 | "source": [
|
|
75 | 75 | },
|
76 | 76 | {
|
77 | 77 | "cell_type": "code",
|
78 |
| - "execution_count": 120, |
| 78 | + "execution_count": 55, |
79 | 79 | "metadata": {},
|
80 | 80 | "outputs": [],
|
81 | 81 | "source": [
|
|
84 | 84 | },
|
85 | 85 | {
|
86 | 86 | "cell_type": "code",
|
87 |
| - "execution_count": 121, |
| 87 | + "execution_count": 56, |
88 | 88 | "metadata": {},
|
89 | 89 | "outputs": [],
|
90 | 90 | "source": [
|
|
93 | 93 | },
|
94 | 94 | {
|
95 | 95 | "cell_type": "code",
|
96 |
| - "execution_count": 131, |
| 96 | + "execution_count": 57, |
97 | 97 | "metadata": {},
|
98 | 98 | "outputs": [],
|
99 | 99 | "source": [
|
|
102 | 102 | },
|
103 | 103 | {
|
104 | 104 | "cell_type": "code",
|
105 |
| - "execution_count": 134, |
| 105 | + "execution_count": 58, |
106 | 106 | "metadata": {},
|
107 | 107 | "outputs": [
|
108 | 108 | {
|
|
111 | 111 | "('', 80026)"
|
112 | 112 | ]
|
113 | 113 | },
|
114 |
| - "execution_count": 134, |
| 114 | + "execution_count": 58, |
115 | 115 | "metadata": {},
|
116 | 116 | "output_type": "execute_result"
|
117 | 117 | }
|
|
122 | 122 | },
|
123 | 123 | {
|
124 | 124 | "cell_type": "code",
|
125 |
| - "execution_count": null, |
| 125 | + "execution_count": 59, |
126 | 126 | "metadata": {},
|
127 |
| - "outputs": [], |
| 127 | + "outputs": [ |
| 128 | + { |
| 129 | + "data": { |
| 130 | + "text/plain": [ |
| 131 | + "[('the', 34254),\n", |
| 132 | + " ('and', 21799),\n", |
| 133 | + " ('to', 16569),\n", |
| 134 | + " ('of', 14941),\n", |
| 135 | + " ('a', 10395),\n", |
| 136 | + " ('he', 9574),\n", |
| 137 | + " ('in', 8844),\n", |
| 138 | + " ('his', 7949),\n", |
| 139 | + " ('that', 7589),\n", |
| 140 | + " ('was', 7297),\n", |
| 141 | + " ('with', 5667),\n", |
| 142 | + " ('had', 5348),\n", |
| 143 | + " ('it', 4653),\n", |
| 144 | + " ('her', 4587),\n", |
| 145 | + " ('not', 4571),\n", |
| 146 | + " ('at', 4503),\n", |
| 147 | + " ('him', 4294),\n", |
| 148 | + " ('as', 3913),\n", |
| 149 | + " ('on', 3879),\n", |
| 150 | + " ('but', 3664),\n", |
| 151 | + " ('for', 3426),\n", |
| 152 | + " ('she', 3316),\n", |
| 153 | + " ('i', 3246),\n", |
| 154 | + " ('is', 3165),\n", |
| 155 | + " ('you', 2988),\n", |
| 156 | + " ('said', 2757),\n", |
| 157 | + " ('from', 2670),\n", |
| 158 | + " ('all', 2641),\n", |
| 159 | + " ('were', 2401),\n", |
| 160 | + " ('be', 2386)]" |
| 161 | + ] |
| 162 | + }, |
| 163 | + "execution_count": 59, |
| 164 | + "metadata": {}, |
| 165 | + "output_type": "execute_result" |
| 166 | + } |
| 167 | + ], |
128 | 168 | "source": []
|
129 | 169 | },
|
130 | 170 | {
|
131 | 171 | "cell_type": "code",
|
132 |
| - "execution_count": 136, |
| 172 | + "execution_count": 13, |
133 | 173 | "metadata": {},
|
134 | 174 | "outputs": [],
|
135 |
| - "source": [ |
136 |
| - "dataPoints = [d[0] for d in dataCounter]" |
137 |
| - ] |
| 175 | + "source": [] |
138 | 176 | },
|
139 | 177 | {
|
140 | 178 | "cell_type": "code",
|
141 |
| - "execution_count": 153, |
| 179 | + "execution_count": 60, |
142 | 180 | "metadata": {},
|
143 | 181 | "outputs": [],
|
144 | 182 | "source": [
|
145 | 183 | "def hash_table_creator():\n",
|
146 |
| - " global dataPoints,count_sketch\n", |
| 184 | + " global dataCounter,count_sketch\n", |
147 | 185 | " hash42 = np.array(list(map(lambda x: mmh3.hash(x,42,signed=False),dataPoints)))\n",
|
148 | 186 | " hash142 = np.array(list(map(lambda x: mmh3.hash(x,142,signed=False),dataPoints)))\n",
|
149 | 187 | " hash1421 = np.array(list(map(lambda x: mmh3.hash(x,1421,signed=False),dataPoints)))\n",
|
150 | 188 | " hash14214 = np.array(list(map(lambda x: mmh3.hash(x,14214,signed=False),dataPoints)))\n",
|
151 | 189 | " hash142142 = np.array(list(map(lambda x: mmh3.hash(x,142142,signed=False),dataPoints)))\n",
|
152 |
| - " for i in range(len(dataPoints)):\n", |
153 |
| - " count_sketch[hash42%100333][0] = hash42[i]\n", |
154 |
| - " count_sketch[hash142%100333][1] = hash142[i]\n", |
155 |
| - " count_sketch[hash1421%100333][2] = hash1421[i]\n", |
156 |
| - " count_sketch[hash14214%100333][3] = hash14214[i]\n", |
157 |
| - " count_sketch[hash142142%100333][4] = hash142142[i]" |
| 190 | + " for i in range(len(dataCounter)):\n", |
| 191 | + " count_sketch[hash42[i]%100333][0] = dataCounter[i][1]\n", |
| 192 | + " count_sketch[hash142[i]%100333][1] = dataCounter[i][1]\n", |
| 193 | + " count_sketch[hash1421[i]%100333][2] = dataCounter[i][1]\n", |
| 194 | + " count_sketch[hash14214[i]%100333][3] = dataCounter[i][1]\n", |
| 195 | + " count_sketch[hash142142[i]%100333][4] = dataCounter[i][1]" |
158 | 196 | ]
|
159 | 197 | },
|
160 | 198 | {
|
161 | 199 | "cell_type": "code",
|
162 |
| - "execution_count": 154, |
| 200 | + "execution_count": 61, |
| 201 | + "metadata": {}, |
| 202 | + "outputs": [], |
| 203 | + "source": [ |
| 204 | + "def hash_table_finder(dataPoint):\n", |
| 205 | + " global count_sketch\n", |
| 206 | + " counting = []\n", |
| 207 | + " hash42 = mmh3.hash(dataPoint,42,signed=False)\n", |
| 208 | + " hash142 = mmh3.hash(dataPoint,142,signed=False)\n", |
| 209 | + " hash1421 = mmh3.hash(dataPoint,1421,signed=False)\n", |
| 210 | + " hash14214 = mmh3.hash(dataPoint,14214,signed=False)\n", |
| 211 | + " hash142142 = mmh3.hash(dataPoint,142142,signed=False)\n", |
| 212 | + " counting.append(count_sketch[hash42%100333][0])\n", |
| 213 | + " counting.append(count_sketch[hash142%100333][1])\n", |
| 214 | + " counting.append(count_sketch[hash1421%100333][2])\n", |
| 215 | + " counting.append(count_sketch[hash14214%100333][3])\n", |
| 216 | + " counting.append(count_sketch[hash142142%100333][4])\n", |
| 217 | + " return counting" |
| 218 | + ] |
| 219 | + }, |
| 220 | + { |
| 221 | + "cell_type": "code", |
| 222 | + "execution_count": 62, |
163 | 223 | "metadata": {},
|
164 | 224 | "outputs": [],
|
165 | 225 | "source": [
|
|
168 | 228 | },
|
169 | 229 | {
|
170 | 230 | "cell_type": "code",
|
171 |
| - "execution_count": 157, |
| 231 | + "execution_count": 63, |
172 | 232 | "metadata": {},
|
173 | 233 | "outputs": [
|
174 | 234 | {
|
|
183 | 243 | " [0, 0, 0, 0, 0]], dtype=int8)"
|
184 | 244 | ]
|
185 | 245 | },
|
186 |
| - "execution_count": 157, |
| 246 | + "execution_count": 63, |
187 | 247 | "metadata": {},
|
188 | 248 | "output_type": "execute_result"
|
189 | 249 | }
|
190 | 250 | ],
|
191 |
| - "source": [] |
| 251 | + "source": [ |
| 252 | + "count_sketch" |
| 253 | + ] |
| 254 | + }, |
| 255 | + { |
| 256 | + "cell_type": "code", |
| 257 | + "execution_count": 64, |
| 258 | + "metadata": {}, |
| 259 | + "outputs": [ |
| 260 | + { |
| 261 | + "data": { |
| 262 | + "text/plain": [ |
| 263 | + "[-84, 29, -84, -84, -84]" |
| 264 | + ] |
| 265 | + }, |
| 266 | + "execution_count": 64, |
| 267 | + "metadata": {}, |
| 268 | + "output_type": "execute_result" |
| 269 | + } |
| 270 | + ], |
| 271 | + "source": [ |
| 272 | + "hash_table_finder(\"you\")" |
| 273 | + ] |
192 | 274 | },
|
193 | 275 | {
|
194 | 276 | "cell_type": "code",
|
|
0 commit comments