534 lines
174 KiB
Plaintext
534 lines
174 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"![Logo 1](https://git.wmi.amu.edu.pl/AITech/Szablon/raw/branch/master/Logotyp_AITech1.jpg)\n",
|
||
|
"<div class=\"alert alert-block alert-info\">\n",
|
||
|
"<h1> Modelowanie języka</h1>\n",
|
||
|
"<h2> 02. <i>Języki i ich prawa statystyczne</i> [wykład]</h2> \n",
|
||
|
"<h3> Filip Graliński (2022)</h3>\n",
|
||
|
"</div>\n",
|
||
|
"\n",
|
||
|
"![Logo 2](https://git.wmi.amu.edu.pl/AITech/Szablon/raw/branch/master/Logotyp_AITech2.jpg)\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Języki i ich prawa statystyczne\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Jakim rozkładom statystycznym podlegają języki?\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Język naturalny albo „Pan Tadeusz” w liczbach\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Przygotujmy najpierw „infrastrukturę” do *segmentacji* tekstu na różnego rodzaju jednostki.\n",
|
||
|
"Używać będziemy generatorów.\n",
|
||
|
"\n",
|
||
|
"**Pytanie** Dlaczego generatory zamiast list?\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Księga pierwsza\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"Gospodarstwo\n",
|
||
|
"\n",
|
||
|
"Powrót pani"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import requests\n",
|
||
|
"\n",
|
||
|
"url = 'https://wolnelektury.pl/media/book/txt/pan-tadeusz.txt'\n",
|
||
|
"pan_tadeusz = requests.get(url).content.decode('utf-8')\n",
|
||
|
"\n",
|
||
|
"pan_tadeusz[100:150]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"#### Znaki\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"['K', 's', 'i', 'ę', 'g', 'a', ' ', 'p', 'i', 'e', 'r', 'w', 's', 'z', 'a', '\\r', '\\n', '\\r', '\\n', '\\r', '\\n', '\\r', '\\n', 'G', 'o', 's', 'p', 'o', 'd', 'a', 'r', 's', 't', 'w', 'o', '\\r', '\\n', '\\r', '\\n', 'P', 'o', 'w', 'r', 'ó', 't', ' ', 'p', 'a', 'n', 'i']"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"from itertools import islice\n",
|
||
|
"\n",
|
||
|
"def get_characters(t):\n",
|
||
|
" yield from t\n",
|
||
|
"\n",
|
||
|
"list(islice(get_characters(pan_tadeusz), 100, 150))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Counter({' ': 63444, 'a': 30979, 'i': 29353, 'e': 25343, 'o': 23050, 'z': 22741, 'n': 15505, 'r': 15328, 's': 15255, 'w': 14625, 'c': 14153, 'y': 13732, 'k': 12362, 'd': 11465, '\\r': 10851, '\\n': 10851, 't': 10757, 'm': 10269, 'ł': 10059, ',': 9130, 'p': 8031, 'u': 7699, 'l': 6677, 'j': 6586, 'b': 5753, 'ę': 5534, 'ą': 4794, 'g': 4775, 'h': 3915, 'ż': 3334, 'ó': 3097, 'ś': 2524, '.': 2380, 'ć': 1956, ';': 1445, 'P': 1265, 'W': 1258, ':': 1152, '!': 1083, 'S': 1045, 'T': 971, 'I': 795, 'N': 793, 'Z': 785, 'J': 729, '—': 720, 'A': 698, 'K': 683, 'ń': 651, 'M': 585, 'B': 567, 'O': 567, 'C': 556, 'D': 552, '«': 540, '»': 538, 'R': 489, '?': 441, 'ź': 414, 'f': 386, 'G': 358, 'L': 316, 'H': 309, 'Ż': 219, 'U': 184, '…': 157, '*': 150, '(': 76, ')': 76, 'Ś': 71, 'F': 47, 'é': 43, '-': 33, 'Ł': 24, 'E': 23, '/': 19, 'Ó': 13, '8': 10, '9': 8, '2': 6, 'v': 5, 'Ź': 4, '1': 4, '3': 3, 'x': 3, 'V': 3, '7': 2, '4': 2, '5': 2, 'q': 2, 'æ': 2, 'à': 1, 'Ć': 1, '6': 1, '0': 1})"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"from collections import Counter\n",
|
||
|
"\n",
|
||
|
"c = Counter(get_characters(pan_tadeusz))\n",
|
||
|
"\n",
|
||
|
"c"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Napiszmy pomocniczą funkcję, która zwraca **listę frekwencyjną**.\n",
|
||
|
"\n",
|
||
|
"Counter({' ': 63444, 'a': 30979, 'i': 29353, 'e': 25343, 'o': 23050, 'z': 22741, 'n': 15505, 'r': 15328, 's': 15255, 'w': 14625, 'c': 14153, 'y': 13732, 'k': 12362, 'd': 11465, '\\r': 10851, '\\n': 10851, 't': 10757, 'm': 10269, 'ł': 10059, ',': 9130, 'p': 8031, 'u': 7699, 'l': 6677, 'j': 6586, 'b': 5753, 'ę': 5534, 'ą': 4794, 'g': 4775, 'h': 3915, 'ż': 3334, 'ó': 3097, 'ś': 2524, '.': 2380, 'ć': 1956, ';': 1445, 'P': 1265, 'W': 1258, ':': 1152, '!': 1083, 'S': 1045, 'T': 971, 'I': 795, 'N': 793, 'Z': 785, 'J': 729, '—': 720, 'A': 698, 'K': 683, 'ń': 651, 'M': 585, 'B': 567, 'O': 567, 'C': 556, 'D': 552, '«': 540, '»': 538, 'R': 489, '?': 441, 'ź': 414, 'f': 386, 'G': 358, 'L': 316, 'H': 309, 'Ż': 219, 'U': 184, '…': 157, '\\*': 150, '(': 76, ')': 76, 'Ś': 71, 'F': 47, 'é': 43, '-': 33, 'Ł': 24, 'E': 23, '/': 19, 'Ó': 13, '8': 10, '9': 8, '2': 6, 'v': 5, 'Ź': 4, '1': 4, '3': 3, 'x': 3, 'V': 3, '7': 2, '4': 2, '5': 2, 'q': 2, 'æ': 2, 'à': 1, 'Ć': 1, '6': 1, '0': 1})\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"OrderedDict([(' ', 63444), ('a', 30979), ('i', 29353), ('e', 25343), ('o', 23050), ('z', 22741), ('n', 15505), ('r', 15328)])"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"from collections import Counter\n",
|
||
|
"from collections import OrderedDict\n",
|
||
|
"\n",
|
||
|
"def freq_list(g, top=None):\n",
|
||
|
" c = Counter(g)\n",
|
||
|
"\n",
|
||
|
" if top is None:\n",
|
||
|
" items = c.items()\n",
|
||
|
" else:\n",
|
||
|
" items = c.most_common(top)\n",
|
||
|
"\n",
|
||
|
" return OrderedDict(sorted(items, key=lambda t: -t[1]))\n",
|
||
|
"\n",
|
||
|
"freq_list(get_characters(pan_tadeusz), top=8)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABLAAAAEsCAYAAADTvUpQAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAABiFUlEQVR4nO3de3zP9f//8fvbTma2d7PZZhkpzGEOhRjVFDZyqI9CYYgcIiwk0ifycSg5Fal0QKj1Qb4ptYYPIuehckgH5NBmldmQttmevz+67PXztoNtDnu3btfL5X252PP1eL9ej9fr/Xq9vN6P9/P1fNmMMUYAAAAAAACAkypT0gkAAAAAAAAABaGABQAAAAAAAKdGAQsAAAAAAABOjQIWAAAAAAAAnBoFLAAAAAAAADg1ClgAAAAAAABwahSwAAAAAAAA4NQoYAEAAAAAAMCpUcACAAAAAACAU6OABQAAAAAAAKdGAQsAAAAAAABOjQIWAAAAAAAAnBoFLAAAAAAAADg1ClgAAAAAAABwahSwAAAAAAAA4NQoYAEAAAAAAMCpUcACAAAAAACAU6OABQAAAAAAAKdGAQsAAAAAAABOjQIWAAAAAAAAnBoFLAAAAAAAADg1ClgAAAAAAABwahSwAAAAAAAA4NQoYAEAAAAAAMCpUcACAAAAAACAU6OABQAAAAAAAKdGAQsAAAAAAABOjQIWAAAAAAAAnBoFLAAAAAAAADg1ClgAAAAAAABwahSwAAAAAAAA4NQoYAEAAAAAAMCpUcACAAAAAACAU6OABQAAAAAAAKfmWtIJ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ure>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"from collections import OrderedDict\n",
|
||
|
"\n",
|
||
|
"def rang_freq_with_labels(name, g, top=None):\n",
|
||
|
" freq = freq_list(g, top)\n",
|
||
|
"\n",
|
||
|
" plt.figure(figsize=(12, 3))\n",
|
||
|
" plt.ylabel('liczba wystąpień')\n",
|
||
|
"\n",
|
||
|
" plt.bar(freq.keys(), freq.values())\n",
|
||
|
"\n",
|
||
|
" fname = f'02_Jezyki/{name}.png'\n",
|
||
|
"\n",
|
||
|
" plt.savefig(fname)\n",
|
||
|
"\n",
|
||
|
" return fname\n",
|
||
|
"\n",
|
||
|
"rang_freq_with_labels('pt-chars', get_characters(pan_tadeusz))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"#### Słowa\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Co rozumiemy pod pojęciem słowa czy wyrazu, nie jest oczywiste. W praktyce zależy to od wyboru **tokenizatora**.\n",
|
||
|
"\n",
|
||
|
"Załóżmy, że przez wyraz rozumieć będziemy nieprzerwany ciąg liter bądź cyfr (oraz gwiazdek\n",
|
||
|
"— to za chwilę ułatwi nam analizę pewnego tekstu…).\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"['Ty', 'co', 'gród', 'zamkowy', 'Nowogródzki', 'ochraniasz', 'z', 'jego', 'wiernym', 'ludem', 'Jak', 'mnie', 'dziecko', 'do', 'zdrowia', 'powróciłaś', 'cudem', 'Gdy', 'od', 'płaczącej', 'matki', 'pod', 'Twoją', 'opiekę', 'Ofiarowany', 'martwą', 'podniosłem', 'powiekę', 'I', 'zaraz']"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"from itertools import islice\n",
|
||
|
"import regex as re\n",
|
||
|
"\n",
|
||
|
"def get_words(t):\n",
|
||
|
" for m in re.finditer(r'[\\p{L}0-9\\*]+', t):\n",
|
||
|
" yield m.group(0)\n",
|
||
|
"\n",
|
||
|
"list(islice(get_words(pan_tadeusz), 100, 130))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Zobaczmy 20 najczęstszych wyrazów.\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABLAAAAEsCAYAAADTvUpQAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAABC3UlEQVR4nO3deViU9f7/8dfIruAEmBCJS7mkgktWbhV43FJJO56yo4b2y6OWueCu2YLmUnYUCk+LHk+YS6aWrSdzSUkOrigWaZqmuQTRQihKgHD//ujy/jqCZsVwz9DzcV1zXd6f+z0zrxmYG3zzuT+3zTAMQwAAAAAAAICLqmZ1AAAAAAAAAOBKaGABAAAAAADApdHAAgAAAAAAgEujgQUAAAAAAACXRgMLAAAAAAAALo0GFgAAAAAAAFwaDSwAAAAAAAC4NBpYAAAAAAAAcGk0sAAAAAAAAODSaGABAAAAAADApdHAAgAAAAAAgEujgQUAAAAAAACXRgMLAAAAAAAALo0GFg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nXq1MncHjdunCRp8ODBio+P17vvvitJatWqlcP9Nm/erOjoaElSQkKCPD091a9fPxUUFKhz585KTk6Wh4eHWb98+XKNHj3avFph7969tWDBgqvOCQAAAAAAUNFoYDnRe++9p4EDB+rs2bMKCAgos1j6b2lgRUdHyzCMy+6/0r4LfH19lZSUpKSkpMvWBAUFadmyZVedCwAAAAAAwNlYA6sCrVq1Sl9//bW5PX78eD300EM6c+aMfvrpJ+Xm5pq3H3/80cKkAAAAAAAA7oMGVgX
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"rang_freq_with_labels('pt-words-20', get_words(pan_tadeusz), top=20)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Zobaczmy pełny obraz, już bez etykiet.\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYAAAA10dzkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAwSElEQVR4nO3df3QV9Z3/8dclP64hm1zzo7mXWwKme7LWNSm1wYZEt2CBADWkLt9dtLgp3eWruAg0S/AHx+2Kfk+Tyq7ArqlWWb5CQYyn3xXWs7WRUDWaL6AYyAqIqGsKQXMN+r3cJBBvQjLfPyizvSSAQiZ3bub5OGfOyZ15z+QzfrwnLz4znxmXYRiGAAAA4Bijot0AAAAADC8CIAAAgMMQAAEAAByGAAgAAOAwBEA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MBhCIA25NKZ58AwCRgAAFiBAAgAAOAwBEAAAACHIQACAAA4DAEQAADAYQiAAAAADkMAtCGXK9otAAAAIxkB0MYMgwfBAACAoUcABAAAcBgCIAAAgMMQAAEAAByGAAgAAOAwBEAAAACHIQDaGHOAAQCAFQiAAAAADkMABAAAcBgCIAAAgMMQAAEAABzGdgHwtdde0+zZs+X3++VyubRt2zZzW29vr+677z7l5+crOTlZfr9fP/zhD/Xxxx9HHCMcDmvJkiXKzMxUcnKyysrKdOzYsYiaYDCo8vJyeTweeTwelZeX68SJE8Nwhhfn4mXAAADAQrYLgCdPntSECRNUU1MzYNupU6e0d+9e/eQnP9HevXv1/PPP67333lNZWVlEXUVFhbZu3ara2lo1Njaqq6tLpaWl6uvrM2vmzZun5uZm1dXVqa6uTs3NzSovL7f8/AAAAKItPtoNONesWbM0a9asQbd5PB7V19dHrHvsscf07W9/W0ePHtW4ceMUCoW0fv16bdq0SdOmTZMkbd68WdnZ2dqxY4dmzJihQ4cOqa6uTrt371ZhYaEkad26dSoqKtLhw4d19dVXW3uSX5DBc2AAAIAFbDcC+GWFQiG5XC5deeWVkqSmpib19vaqpKTErPH7/crLy9POnTslSbt27ZLH4zHDnyRNmjRJHo/HrBlMOBxWR0dHxAIAABBrYjoAfv7557r//vs1b948paamSpICgYASExOVlpYWUev1ehUIBMyarKysAcfLysoyawZTXV1t3jPo8XiUnZ09hGcDAAAwPGI2APb29uq2225Tf3+/Hn/88YvWG4YRMblisIkW59aca8WKFQqFQubS2tp6aY0HAACIopgMgL29vZo7d65aWlpUX19vjv5Jks/nU09Pj4LBYMQ+7e3t8nq9Zs0nn3wy4LjHjx83awbjdruVmpoasQAAAMSamAuAZ8Pf+++/rx07digjIyNie0FBgRISEiImi7S1tenAgQMqLi6WJBUVFSkUCunNN980a9544w2FQiGzJpp4CAwAALCS7WYBd3V16YMPPjA/t7S0qLm5Wenp6fL7/fqLv/gL7d27V//xH/+hvr4+85699PR0JSYmyuPxaMGCBaqsrFRGRobS09O1fPly5efnm7OCr7nmGs2cOVN33HGHnnzySUnSnXfeqdLSUtvMAJYkJgEDAAAr2C4AvvXWW7rpppvMz8uWLZMkzZ8/XytXrtQLL7wgSfrmN78Zsd8rr7yiKVOmSJLWrFmj+Ph4zZ07V93d3Zo6dao2bNiguLg4s/6ZZ57R0qVLzdnCZWVlgz57EAAAYKRxGQZPm7tUHR0d8ng8CoVCQ3o/4P9ubNHD//GOZk/w67EfXDdkxwUAANb9/Y4lMXcPIAAAAC4PARAAAMBhCIA2dIFHEQIAAFw2AiAAAIDDEABtjPk5AADACgR
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"from math import log\n",
|
||
|
"\n",
|
||
|
"def rang_freq(name, g):\n",
|
||
|
" freq = freq_list(g)\n",
|
||
|
"\n",
|
||
|
" plt.figure().clear()\n",
|
||
|
" plt.plot(range(1, len(freq.values())+1), freq.values())\n",
|
||
|
"\n",
|
||
|
" fname = f'02_Jezyki/{name}.png'\n",
|
||
|
"\n",
|
||
|
" plt.savefig(fname)\n",
|
||
|
"\n",
|
||
|
" return fname\n",
|
||
|
"\n",
|
||
|
"rang_freq('pt-words', get_words(pan_tadeusz))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Widać, jak różne skale obejmuje ten wykres. Zastosujemy logarytm,\n",
|
||
|
"najpierw tylko do współrzędnej $y$.\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYAAAA10dzkAAAA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ujs7Ixp06bFl770pXjhhRfyLqmqqXoUnAAIANRWsh3AE044IW6++eY4/PDD49VXX42/+Zu/iZNOOilWrFgRBx100Nu+p1KpRKVSqT7v6empW32DHcA+ARAAqLFkO4Bz5syJz3/+8zFjxow444wz4sc//nFERNx00017fM/ChQujo6Oj+ujq6qpbfc0DLUABEACotWQD4O9qa2uLGTNmxMqVK/d4zaWXXhrd3d3Vx5o1a+pWjwAIANRLslPAv6tSqcSzzz4bp5xyyh6vKZfLUS6Xh6UeARAAqJdkO4B/8Rd/EUuWLIkXX3wxHn300fjCF74QPT09MW/evLxLi4hdAdAiEACg1pLtAL700kvx5S9/OV5//fU4+OCD48QTT4ylS5fG1KlT8y4tInYFQBtBAwC1lmwAXLRoUd4l7FVzSQcQAKiPZKeAi66lefAewP6cKwEARhoBsKB2LQLJuRAAYMQRAAtqcApYBxAAqDUBsKB0AAGAehEAC2pXAJQAAYDaEgALykbQAEC9CIAFZSNoAKBeBMCC0gEEAOpFACyocsvOodne6x5AAKC2BMCCKrc0R0TEtt6+nCsBAEYaAbCgyq07h6ayQwcQAKgtAbCgRusAAgB1IgAW1OjWgQCoAwgA1JgAWFCDi0C27dABBABqSwAsqDGjBjuAAiAAUFsCYEHtNxAAt1QEQACgtgTAgtq/3BIREVu39+Z
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"from math import log\n",
|
||
|
"\n",
|
||
|
"def rang_log_freq(name, g):\n",
|
||
|
" freq = freq_list(g)\n",
|
||
|
"\n",
|
||
|
" plt.figure().clear()\n",
|
||
|
" plt.plot(range(1, len(freq.values())+1), [log(y) for y in freq.values()])\n",
|
||
|
"\n",
|
||
|
" fname = f'02_Jezyki/{name}.png'\n",
|
||
|
"\n",
|
||
|
" plt.savefig(fname)\n",
|
||
|
"\n",
|
||
|
" return fname\n",
|
||
|
"\n",
|
||
|
"rang_log_freq('pt-words-log', get_words(pan_tadeusz))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"****Pytanie**** Dlaczego widzimy coraz dłuższe „schodki”?\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"#### Hapax legomena\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Z poprzedniego wykresu możemy odczytać, że ok. 2/3 wyrazów wystąpiło\n",
|
||
|
"dokładnie 1 raz. Słowa występujące jeden raz w danym korpusie noszą\n",
|
||
|
"nazwę *hapax legomena* (w liczbie pojedynczej *hapax legomenon*, ἅπαξ\n",
|
||
|
"λεγόμενον, „raz powiedziane”, żargonowo: „hapaks”).\n",
|
||
|
"\n",
|
||
|
"„Prawdziwe” hapax legomena, słowa, które wystąpiły tylko raz w *całym*\n",
|
||
|
"korpusie tekstów danego języka (np. starożytnego) rzecz jasna\n",
|
||
|
"sprawiają olbrzymie trudności w tłumaczeniu. Przykładem jest greckie\n",
|
||
|
"słowo ἐπιούσιος, przydawka odnosząca się do chleba w modlitwie „Ojcze\n",
|
||
|
"nasz”. Jest to jedyne poświadczenie tego słowa w całym znanym korpusie\n",
|
||
|
"greki (nie tylko z Pisma Świętego). W języku polskim tłumaczymy je na\n",
|
||
|
"„powszedni”, ale na przykład w rosyjskim przyjął się odpowiednik\n",
|
||
|
"„насущный” — o przeciwstawnym do polskiego znaczeniu!\n",
|
||
|
"\n",
|
||
|
"W sumie podobne problemy hapaksy mogą sprawiać metodom statystycznym\n",
|
||
|
"przy przetwarzaniu jakiekolwiek korpusu.\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"#### Wykres log-log\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Jeśli wspomniany wcześniej wykres narysujemy używając skali\n",
|
||
|
"logarytmicznej dla ****obu**** osi, otrzymamy kształt zbliżony do linii prostej.\n",
|
||
|
"\n",
|
||
|
"Tę własność tekstów nazywamy ****prawem Zipfa****.\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYAAAA10dzkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAA9hAAAPYQGoP6dpAAA340lEQVR4nO3deXhU5cH+8fvMJJksZAaSkEBMgLALyI7IDiooWqvVuqLi2mpBRboo2vd1Jz+1tfYtimKtG3WpG6J1w4WALLIrsohsSVjCTiYJZEIy8/sjMBpZAiSZZ2bO93Ndc7VzZgbupqPPneec5zlWIBAICAAAALbhMB0AAAAAoUUBBAAAsBkKIAAAgM1QAAEAAGyGAggAAGAzFEAAAACboQACAADYDAUQAADAZiiAAAAANkMBBAAAsBkKIAAAgM1QAAEAAGyGAggAAGAzFEAAAACboQACAADYDAUQAADAZiiAAAAANkMBBAAAsBkKIAAAgM1QAAEAAGyGAggAAGAzFEAAAACboQACAADYDAUQAADAZiiAAAAANkMBBAAAsBkKIAAAgM1QAAEAAGyGAggAAGAzFEAAAACboQACAADYDAUQAADAZiiAAAAANkMBBAAAsBkKIAAAgM1QAAEAAGyGAggAAGAzFEAAAACboQACAADYDAUQAADAZii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ubjoYwY1mWzuncTMM6pOuV+fn6+2drtLqoRNe9sFA9WzTWncPba2DbNFmWZToqAADHxQrYdArj7rvv1pw5czR79uyT/jO8Xq88Ho+Ki4vldrvrMR3C2Z6yCk36cq2mzs+
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"from math import log\n",
|
||
|
"\n",
|
||
|
"def log_rang_log_freq(name, g):\n",
|
||
|
" freq = freq_list(g)\n",
|
||
|
"\n",
|
||
|
" plt.figure().clear()\n",
|
||
|
" plt.plot([log(x) for x in range(1, len(freq.values())+1)], [log(y) for y in freq.values()])\n",
|
||
|
"\n",
|
||
|
" fname = f'02_Jezyki/{name}.png'\n",
|
||
|
"\n",
|
||
|
" plt.savefig(fname)\n",
|
||
|
"\n",
|
||
|
" return fname\n",
|
||
|
"\n",
|
||
|
"log_rang_log_freq('pt-words-log-log', get_words(pan_tadeusz))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"#### Związek między frekwencją a długością\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Powiązane z prawem Zipfa prawo językowe opisuje zależność między\n",
|
||
|
"częstością użycia słowa a jego długością. Generalnie im krótsze słowo, tym częstsze.\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYAAAA10dzkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZ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GoyAMovGfUKKBuXWD0aArASZOALl2AgQOBAwcK++yEEEII3yMBKLxlwgRgxAjgnnuAv/4C5s4FNm0CPvsMmDMHuPrqwj5DIYQQwvdIABYljh7lfN7evYHGjYHu3YG33gIOHy7sM8sflgWMHAmcey7w1FNAQgL3R0UB550HvPAC8MknnD8shBBCiEJDArCocOAA0KcPcNllFFJnnEEBdf31QNeuwO7dhX2GebNqFbB6NXDddeHXL7kEKFUKmDKlYM9LCCGEECGoCKSoMHw4sHgx8NNPwEknOfv/+IMewauvBr78svDOLz8cOsRtpUrh10uUAMqUcZ4nhBBCiEJBHsCiwJ49wMSJwP33h4o/AGjZEnj6aeCrr4D16wvn/PLLCScAJUsC334bfn3pUmDXLqBFiwI9LSGEEEKEIgFYFFi4EEhNBS68MPz6oEEMC//0U8Ge17GSmAhcfDHw/PPZ8/wOHwbuuAOoWRMYMKBwzk8IIYQQABQCLhpYVu7rxal33qhRwLx5QPv2DFt37Qps3gy88QawbRswbRoQo4+dEEIIUZjIA1gU6NgRiI9nhWw4PvmEIvDkkwv2vNxQuTJbv9xwA/Duu8AFF7AtTNu2wC+/AKeeWthnKIQQQviegGXl5X4SOZGSkoLExEQkJyejbNmyZge77jrgo4+Ar78GunVz9i9bxiKQzp2LfhFIVjIygJQUoHRpIC6usM9GCCGEAODx9buYolh
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"def freq_vs_length(name, g, top=None):\n",
|
||
|
" freq = freq_list(g)\n",
|
||
|
"\n",
|
||
|
" plt.figure().clear()\n",
|
||
|
" plt.scatter([len(x) for x in freq.keys()], [log(y) for y in freq.values()],\n",
|
||
|
" facecolors='none', edgecolors='r')\n",
|
||
|
"\n",
|
||
|
" fname = f'02_Jezyki/{name}.png'\n",
|
||
|
"\n",
|
||
|
" plt.savefig(fname)\n",
|
||
|
"\n",
|
||
|
" return fname\n",
|
||
|
"\n",
|
||
|
"freq_vs_length('pt-lengths', get_words(pan_tadeusz))"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3 (ipykernel)",
|
||
|
"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.10.9"
|
||
|
},
|
||
|
"org": null
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 1
|
||
|
}
|