Practica 3 del parcial 2

parent 369ad78c
{
"cells": [
{
"cell_type": "code",
"execution_count": 124,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZIAAAEWCAYAAABMoxE0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAGWtJREFUeJzt3X+UX3V95/HnywSCPRb5NfVggiaWdG2qNa4hsqdKK/4Kuyyhp6BwEMKWI3WVbnetrnFdoZtqV7ddsZ6llFR+iSJQXJccDY2sQN2zWzDDD4HAoQ4RSSKVkR+iImDkvX98b/TLOJn5JnduJsM8H+fck3s/9/P5fD/3nsy85v743puqQpKk3fW86R6AJGlmM0gkSa0YJJKkVgwSSVIrBokkqRWDRJLUikEiDSDJ/UneNFM/J8lLkvwwyZwB6/9uki1Nm1dP9Xj03GKQ6DltTwXAdEtybfNLv396MkkleUlVPVBVL6iqnw7Y5V8AZzVtbuty7Jr55k73ACS1V1XH9C83Rx5fBb5dVQ/sRpcvBTZNxdj03OcRiWalJAcm+VKS0SSPNvMLBmz7vCSrk9yX5OEkVyU5qFn35SR/OKb+HUl+dyd9nZrk200/Hxr0cwbwZ8BBwL9t+lrYHJ3MbZZvTPJfk3w9yeNJrklyUJJ5SX4IzAG+keS+AT9Ps5hBotnqecDF9P7yfgnwY+B/DNj2D4Hjgd8GXgw8CpzXrLsUeMeOikleBcwHvjy2kyRLgPOBU5t+Dgb6w2yiz9mpJCuBPwB+r6qemKDqacDvA4cC24FPVdVTVfWCZv2rqupXJ/s8ySDRrFRVD1fVF6rqiar6AfBRer+wB/Eu4ENVtbWqngL+BDih+Wt/HfBrSRY3dU8Frqyqp8fp5wTgS1X1taafDwPPDPg540ryq8AlwBlV9c1JtuOyqrqrqn7UfPbbBr0YL/UzSDQrJfmlJBc0p5UeB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cBtwDuq6qnpG+n0S/I7wPuq6tiZvH9mdZBIktqbzae2JElTwCCRJLVikEiSWjFIJEmtGCSSpFYMEmkPa54g/K0kBzXLBzbLC6d3ZNLuMUikPayqtgDnAx9rij4GrK2q+6dtUFILfo9EmgbNY1ZuAS4C3gksraqfTO+opN0zm5+1JU2bqvpJkvcDfwe8xRDRTOapLWn6HAM8CLxiugcitWGQSNMgyVJ6DzM8EvgPzRODpRnJIJH2sOYJwufTe5fJA8CfA38xvaOSdp9BIu157wQeqKrrmuW/An49yW9P45ik3eZdW5KkVjwikSS1YpBIkloxSCRJrRgkkqRWDBJJUisGiSSpFYNEktTK/wf02ReF+gX5uwAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import re\n",
"from operator import itemgetter \n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"frequency = {}\n",
"open_file = open('data/data_named_entity_recognition_sp_MX_locations.JSON', 'r')\n",
"file_to_string = open_file.read()\n",
"words = re.findall(r'(b[A-Za-z][a-z]{2,9}b)', file_to_string)\n",
"\n",
"for word in words:\n",
" count = frequency.get(word,0)\n",
" frequency[word] = count + 1\n",
"values=[] \n",
"for key, value in reversed(sorted(frequency.items(), key = itemgetter(1))):\n",
" values= np.append(values,[[key,value]])\n",
"\n",
"for i in range(len(values)):\n",
" #print(values[i])\n",
" if(i%2!=0):\n",
" x=np.append(values2,[int(values[i])])\n",
" \n",
"# the histogram of the data\n",
"patches = plt.hist(x, density=True, facecolor='g', alpha=0.75)\n",
"\n",
"plt.xlabel('X')\n",
"plt.ylabel('Y')\n",
"plt.title('La ley de Zipf')\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment