diff --git a/lab/lab_01.ipynb b/lab/lab_01.ipynb index 8e7aa68..b14a281 100644 --- a/lab/lab_01.ipynb +++ b/lab/lab_01.ipynb @@ -103,7 +103,9 @@ "outputs": [ { "data": { - "text/plain": "['Press the ENTER button']" + "text/plain": [ + "['Press the ENTER button']" + ] }, "execution_count": 7, "metadata": {}, @@ -168,7 +170,9 @@ "outputs": [ { "data": { - "text/plain": "['Press the ENTER button', 'Press the ENTER key']" + "text/plain": [ + "['Press the ENTER button', 'Press the ENTER key']" + ] }, "execution_count": 9, "metadata": {}, @@ -208,7 +212,9 @@ "outputs": [ { "data": { - "text/plain": "[]" + "text/plain": [ + "[]" + ] }, "execution_count": 10, "metadata": {}, @@ -273,7 +279,9 @@ "outputs": [ { "data": { - "text/plain": "[]" + "text/plain": [ + "[]" + ] }, "execution_count": 22, "metadata": {}, @@ -335,7 +343,9 @@ "outputs": [ { "data": { - "text/plain": "[]" + "text/plain": [ + "[]" + ] }, "execution_count": 24, "metadata": {}, @@ -478,7 +488,9 @@ "outputs": [ { "data": { - "text/plain": "[('przycisk', 'button'), ('drukarka', 'printer')]" + "text/plain": [ + "[('przycisk', 'button'), ('drukarka', 'printer')]" + ] }, "execution_count": 28, "metadata": {}, @@ -585,7 +597,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.9.2" }, "subtitle": "1. Podstawowe techniki wspomagania tłumaczenia", "title": "Komputerowe wspomaganie tłumaczenia", diff --git a/lab/lab_02.ipynb b/lab/lab_02.ipynb index e84f1f9..f936e24 100644 --- a/lab/lab_02.ipynb +++ b/lab/lab_02.ipynb @@ -40,9 +40,11 @@ ] }, { - "cell_type": "markdown", - "id": "existing-approval", + "cell_type": "code", + "execution_count": null, + "id": "961796fd-4463-4a17-ac15-afe712b3959e", "metadata": {}, + "outputs": [], "source": [ "Jedną z funkcji dostępnych we wszystkich większych programach do wspomagania tłumaczenia jest znajdowanie bardzo pewnych dopasowań w pamięci tłumaczeń. Są one zwane **ICE** (In-Context Exact match) lub 101% match. Są to takie dopasowania z pamięci tłumaczeń, dla których nie tylko zdanie źródłowe z TM jest identyczne z tłumaczonym, ale także poprzednie zdanie źródłowe z TM zgadza się z poprzednim zdaniem tłumaczonym oraz następne z TM z następnym tłumaczonym." ] @@ -258,21 +260,9 @@ { "cell_type": "code", "execution_count": null, - "id": "4064ce50", + "id": "355e4914-08da-4bd4-b8a2-67b055831c30", "metadata": {}, - "outputs": [ - { - "ename": "ModuleNotFoundError", - "evalue": "No module named 'Levenshtein'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn [2], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mLevenshtein\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m distance \u001b[38;5;28;01mas\u001b[39;00m levenshtein_distance\n\u001b[1;32m 3\u001b[0m levenshtein_distance(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mkotek\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mkotki\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", - "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'Levenshtein'" - ] - } - ], + "outputs": [], "source": [ "from Levenshtein import distance as levenshtein_distance\n", "\n", @@ -349,22 +339,9 @@ ] }, { - "cell_type": "code", - "execution_count": 9, - "id": "invisible-cambodia", + "cell_type": "raw", + "id": "4a47854f-df2e-451f-8e09-99f59210f86f", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "0.631578947368421" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], "source": [ "levenshtein_similarity('Spróbuj wyłączyć i włączyć komputer', 'Nie próbuj wyłączać i włączać drukarki')" ] diff --git a/lab/lab_03.ipynb b/lab/lab_03.ipynb index d379ce0..ec49025 100644 --- a/lab/lab_03.ipynb +++ b/lab/lab_03.ipynb @@ -171,116 +171,34 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 1, "id": "tribal-attention", - "metadata": {}, + "metadata": { + "ExecuteTime": { + "end_time": "2024-04-20T15:23:32.727687100Z", + "start_time": "2024-04-20T15:23:24.826454500Z" + } + }, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - " \n", - "for\n", - "all\n", - "Java\n", - "programmer\n", - ":\n", - "this\n", - "section\n", - "explain\n", - "how\n", - "to\n", - "compile\n", - "and\n", - "run\n", - "a\n", - "swing\n", - "application\n", - "from\n", - "the\n", - "command\n", - "line\n", - ".\n", - "for\n", - "information\n", - "on\n", - "compile\n", - "and\n", - "run\n", - "a\n", - "swing\n", - "application\n", - "use\n", - "NetBeans\n", - "IDE\n", - ",\n", - "see\n", - "Running\n", - "Tutorial\n", - "Examples\n", - "in\n", - "NetBeans\n", - "IDE\n", - ".\n", - "the\n", - "compilation\n", - "instruction\n", - "work\n", - "for\n", - "all\n", - "swing\n", - "program\n", - "—\n", - "applet\n", - ",\n", - "as\n", - "well\n", - "as\n", - "application\n", - ".\n", - "here\n", - "be\n", - "the\n", - "step\n", - "-PRON-\n", - "need\n", - "to\n", - "follow\n", - ":\n", - "install\n", - "the\n", - "late\n", - "release\n", - "of\n", - "the\n", - "Java\n", - "SE\n", - "platform\n", - ",\n", - "if\n", - "-PRON-\n", - "have\n", - "not\n", - "already\n", - "do\n", - "so\n", - ".\n", - "create\n", - "a\n", - "program\n", - "that\n", - "use\n", - "Swing\n", - "component\n", - ".\n", - "compile\n", - "the\n", - "program\n", - ".\n", - "run\n", - "the\n", - "program\n", - ".\n" + "ename": "KeyboardInterrupt", + "evalue": "", + "output_type": "error", + "traceback": [ + "\u001B[1;31m---------------------------------------------------------------------------\u001B[0m", + "\u001B[1;31mKeyboardInterrupt\u001B[0m Traceback (most recent call last)", + "Cell \u001B[1;32mIn[1], line 1\u001B[0m\n\u001B[1;32m----> 1\u001B[0m \u001B[38;5;28;01mimport\u001B[39;00m \u001B[38;5;21;01mspacy\u001B[39;00m\n\u001B[0;32m 2\u001B[0m nlp \u001B[38;5;241m=\u001B[39m spacy\u001B[38;5;241m.\u001B[39mload(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124men_core_web_sm\u001B[39m\u001B[38;5;124m\"\u001B[39m)\n\u001B[0;32m 4\u001B[0m doc \u001B[38;5;241m=\u001B[39m nlp(text)\n", + "File \u001B[1;32mj:\\.AppData\\Python\\Python310\\site-packages\\spacy\\__init__.py:13\u001B[0m\n\u001B[0;32m 10\u001B[0m \u001B[38;5;66;03m# These are imported as part of the API\u001B[39;00m\n\u001B[0;32m 11\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01mthinc\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mapi\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m Config, prefer_gpu, require_cpu, require_gpu \u001B[38;5;66;03m# noqa: F401\u001B[39;00m\n\u001B[1;32m---> 13\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m pipeline \u001B[38;5;66;03m# noqa: F401\u001B[39;00m\n\u001B[0;32m 14\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m util\n\u001B[0;32m 15\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mabout\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m __version__ \u001B[38;5;66;03m# noqa: F401\u001B[39;00m\n", + "File \u001B[1;32mj:\\.AppData\\Python\\Python310\\site-packages\\spacy\\pipeline\\__init__.py:1\u001B[0m\n\u001B[1;32m----> 1\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mattributeruler\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m AttributeRuler\n\u001B[0;32m 2\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mdep_parser\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m DependencyParser\n\u001B[0;32m 3\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01medit_tree_lemmatizer\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m EditTreeLemmatizer\n", + "File \u001B[1;32mj:\\.AppData\\Python\\Python310\\site-packages\\spacy\\pipeline\\attributeruler.py:8\u001B[0m\n\u001B[0;32m 6\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m util\n\u001B[0;32m 7\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01merrors\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m Errors\n\u001B[1;32m----> 8\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mlanguage\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m Language\n\u001B[0;32m 9\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mmatcher\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m Matcher\n\u001B[0;32m 10\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mscorer\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m Scorer\n", + "File \u001B[1;32mj:\\.AppData\\Python\\Python310\\site-packages\\spacy\\language.py:43\u001B[0m\n\u001B[0;32m 41\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mlang\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mtokenizer_exceptions\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m BASE_EXCEPTIONS, URL_MATCH\n\u001B[0;32m 42\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mlookups\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m load_lookups\n\u001B[1;32m---> 43\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mpipe_analysis\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m analyze_pipes, print_pipe_analysis, validate_attrs\n\u001B[0;32m 44\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mschemas\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m (\n\u001B[0;32m 45\u001B[0m ConfigSchema,\n\u001B[0;32m 46\u001B[0m ConfigSchemaInit,\n\u001B[1;32m (...)\u001B[0m\n\u001B[0;32m 49\u001B[0m validate_init_settings,\n\u001B[0;32m 50\u001B[0m )\n\u001B[0;32m 51\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mscorer\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m Scorer\n", + "File \u001B[1;32mj:\\.AppData\\Python\\Python310\\site-packages\\spacy\\pipe_analysis.py:6\u001B[0m\n\u001B[0;32m 3\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01mwasabi\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m msg\n\u001B[0;32m 5\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01merrors\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m Errors\n\u001B[1;32m----> 6\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mtokens\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m Doc, Span, Token\n\u001B[0;32m 7\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mutil\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m dot_to_dict\n\u001B[0;32m 9\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m TYPE_CHECKING:\n\u001B[0;32m 10\u001B[0m \u001B[38;5;66;03m# This lets us add type hints for mypy etc. without causing circular imports\u001B[39;00m\n", + "File \u001B[1;32mj:\\.AppData\\Python\\Python310\\site-packages\\spacy\\tokens\\__init__.py:1\u001B[0m\n\u001B[1;32m----> 1\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01m_serialize\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m DocBin\n\u001B[0;32m 2\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mdoc\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m Doc\n\u001B[0;32m 3\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mmorphanalysis\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m MorphAnalysis\n", + "File \u001B[1;32mj:\\.AppData\\Python\\Python310\\site-packages\\spacy\\tokens\\_serialize.py:14\u001B[0m\n\u001B[0;32m 12\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01merrors\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m Errors\n\u001B[0;32m 13\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mutil\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m SimpleFrozenList, ensure_path\n\u001B[1;32m---> 14\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mvocab\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m Vocab\n\u001B[0;32m 15\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01m_dict_proxies\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m SpanGroups\n\u001B[0;32m 16\u001B[0m \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mdoc\u001B[39;00m \u001B[38;5;28;01mimport\u001B[39;00m DOCBIN_ALL_ATTRS \u001B[38;5;28;01mas\u001B[39;00m ALL_ATTRS\n", + "File \u001B[1;32mj:\\.AppData\\Python\\Python310\\site-packages\\spacy\\vocab.pyx:1\u001B[0m, in \u001B[0;36minit spacy.vocab\u001B[1;34m()\u001B[0m\n", + "File \u001B[1;32mj:\\.AppData\\Python\\Python310\\site-packages\\spacy\\tokens\\doc.pyx:1\u001B[0m, in \u001B[0;36minit spacy.tokens.doc\u001B[1;34m()\u001B[0m\n", + "File \u001B[1;32m:404\u001B[0m, in \u001B[0;36mparent\u001B[1;34m(self)\u001B[0m\n", + "\u001B[1;31mKeyboardInterrupt\u001B[0m: " ] } ], diff --git a/lab/lab_04-05.ipynb b/lab/lab_04-05.ipynb index ef47f3c..85f3d9e 100644 --- a/lab/lab_04-05.ipynb +++ b/lab/lab_04-05.ipynb @@ -77,7 +77,54 @@ "id": "honest-assessment", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "import spacy\n", + "nlp = spacy.load(\"en_core_web_sm\")\n", + "dicts = [\n", + " \"en.txt\",\n", + " \"en(1).txt\",\n", + " \"en(2).txt\",\n", + "]\n", + "dicts_dir = 'data/'\n", + "\n", + "\n", + "def extract_terms(text):\n", + " result = {}\n", + " doc = nlp(text)\n", + " for token in doc:\n", + " if token.pos_ == 'NOUN':\n", + " if result.get(token.lemma_) is None:\n", + " result[token.lemma_] = 1\n", + " else:\n", + " result[token.lemma_] += 1\n", + "\n", + " return result\n", + "\n", + "\n", + "def extract_top(terms, count):\n", + " tops = []\n", + " for i in range(count):\n", + " tops.append((0, None))\n", + " for term, term_value in terms.items():\n", + " for i, top in enumerate(tops):\n", + " if top[0] < term_value:\n", + " tops[i] = (term_value, term)\n", + " break\n", + " return tops\n", + "\n", + "\n", + "for name in dicts:\n", + " file = open(dicts_dir+name, \"r\", encoding=\"utf8\")\n", + " text = file.read()\n", + " print(extract_top(extract_terms(text), 5))\n", + "\n", + "\n", + "\n", + "\n", + "# [(273, 'information'), (215, 'month'), (162, 'income'), (146, 'child'), (130, 'av')]\n", + "# [(81, 'insurance'), (51, 'pension'), (45, '▪'), (23, '%'), (17, 'year')]\n", + "# [(1148, 'child'), (343, 'milk'), (171, 'fish'), (158, 'year'), (138, 'formula')]" + ] }, { "cell_type": "markdown", @@ -143,8 +190,62 @@ "metadata": {}, "outputs": [], "source": [ + "import spacy\n", + "nlp = spacy.load(\"en_core_web_sm\")\n", + "dicts = [\n", + " \"en.txt\",\n", + " \"en(1).txt\",\n", + " \"en(2).txt\",\n", + "]\n", + "dicts_dir = 'data/'\n", + "\n", + "\n", + "def extract_terms(text):\n", + " result = {}\n", + " doc = nlp(text)\n", + " for token in doc:\n", + " if token.pos_ == 'NOUN':\n", + " if result.get(token.lemma_) is None:\n", + " result[token.lemma_] = 1\n", + " else:\n", + " result[token.lemma_] += 1\n", + "\n", + " return result\n", + "\n", + "\n", + "tf_collections = {}\n", + "df_collection = {}\n", + "for name in dicts:\n", + " file = open(dicts_dir + name, \"r\", encoding=\"utf8\")\n", + " text = file.read()\n", + " tf_collections[name] = extract_terms(text)\n", + "\n", + "for name in tf_collections:\n", + " for sentence in tf_collections.get(name):\n", + " if df_collection.get(sentence) is None:\n", + " df_collection[sentence] = 1\n", + " else:\n", + " df_collection[sentence] += 1\n", + "\n", + "\n", "def tfidf_extract():\n", - " return []" + " tfidf_collection = {}\n", + " for name in tf_collections:\n", + " collection = tf_collections.get(name)\n", + " tfidf_collection[name] = {}\n", + " for sentence in collection:\n", + " tfidf_collection[name][sentence] = collection.get(sentence)/df_collection[sentence]\n", + "\n", + " return tfidf_collection\n", + "\n", + "\n", + "tfidf_collections = tfidf_extract()\n", + "for name in tfidf_collections:\n", + " print(sorted(tfidf_collections.get(name).items(), key=lambda item: -item[1])\n", + "\n", + "[('av', 130.0), ('information', 91.0), ('income', 81.0), ('child', 73.0), ('month', 71.66666666666667), ('benefit', 70.0), ('signature', 65.5), ('compensation', 55.5), ('sickness', 55.0), ('partner', 54.0), ('year', 43.0), ('day', 39.0), ('code', 39.0), ('work', 33.666666666666664), ('application', 33.333333333333336), ('support', 31.333333333333332), ('attorney', 31.0), ('tax', 30.5), ('form', 29.666666666666668), ('period', 29.666666666666668), ('employment', 29.5), ('decision', 29.333333333333332), ('kronor', 29.0), ('address', 28.0), ('country', 27.666666666666668), ('no', 27.5), ('payment', 27.0), ('date', 27.0), ('housing', 25.0), ('digit', 25.0), ('injury', 25.0), ('time', 24.333333333333332), ('capacity', 24.0), ('block', 24.0), ('account', 24.0), ('certificate', 23.5), ('case', 23.333333333333332), ('your', 23.0), ('assistance', 23.0), ('residence', 23.0), ('pension', 22.5), ('letter', 22.0), ('section', 21.5), ('detail', 21.5), ('•', 21.0), ('assignment', 21.0), ('number', 20.666666666666668), ('week', 20.0), ('person', 19.666666666666668), ('hour', 19.0), ('debtor', 19.0), ('question', 18.333333333333332), ('amount', 18.333333333333332), ('name', 18.0), ('unemployment', 18.0), ('annuity', 18.0), ('spouse', 18.0), ('expense', 17.5), ('authority', 17.0), ('student', 17.0), ('doctor', 16.333333333333332), ('2570en', 16.0), ('power', 15.5), ('husband', 15.0), ('change', 15.0), ('cost', 14.5), ('area', 14.0), ('consent', 14.0), ('2572en', 14.0), ('employer', 13.5), ('reply', 13.0), ('allowance', 13.0), ('appendix', 13.0), ('daytime', 13.0), ('5069en', 13.0), ('f', 13.0), ('x', 12.5), ('.', 12.0), ('return', 12.0), ('wife', 12.0), ('försäkringskassan', 12.0), ('personregister', 12.0), ('5251en', 12.0), ('5252en', 12.0), ('trustee', 12.0), ('duty', 12.0), ('activity', 11.666666666666666), ('documentation', 11.0), ('example', 11.0), ('offence', 11.0), ('parent', 11.0), ('matter', 11.0), ('forename(s', 10.0), ('car', 10.0), ('living', 10.0), ('agreement', 10.0), ('behalf', 10.0), ('school', 10.0), ('surname', 10.0), ('offense', 10.0), ('omit', 10.0), ('ability', 10.0), ('privatpersoner', 10.0), ('org.nr', 10.0), ('eller', 10.0), ('state', 9.666666666666666), ('internet', 9.5), ('bank', 9.5), ('description', 9.0), ('customer', 9.0), ('treatment', 9.0), ('copy', 9.0), ('county', 9.0), ('court', 9.0), ('working', 8.5), ('today', 8.5), ('city', 8.5), ('evening', 8.5), ('life', 8.0), ('chapter', 8.0), ('telephone', 8.0), ('service', 8.0), ('agency', 8.0), ('examination', 8.0), ('particular', 8.0), ('belief', 8.0), ('database', 8.0), ('7281en', 8.0), ('insurance', 7.5), ('deduction', 7.5), ('fund', 7.5), ('reason', 7.0), ('basis', 7.0), ('a.', 7.0), ('d.', 7.0), ('centre', 7.0), ('medication', 7.0), ('position', 7.0), ('debt', 7.0), ('home', 7.0), ('physician', 7.0), ('contractor', 7.0), ('principal', 7.0), ('rehabilitation', 7.0), ('kap', 7.0), ('gäller', 7.0), ('det', 7.0), ('3030en', 7.0), ('family', 6.5), ('asset', 6.5), ('document', 6.333333333333333), ('embassy', 6.0), ('consulate', 6.0), ('self', 6.0), ('circumstance', 6.0), ('capital', 6.0), ('birth', 6.0), ('reconsideration', 6.0), ('company', 6.0), ('childcare', 6.0), ('currency', 6.0), ('ange', 6.0), ('health', 5.666666666666667), ('business', 5.666666666666667), ('computer', 5.5), ('system', 5.333333333333333), ('supplement', 5.333333333333333), ('police', 5.0), ('provision', 5.0), ('identity', 5.0), ('investigation', 5.0), ('brochure', 5.0), ('impediment', 5.0), ('complaint', 5.0), ('file', 5.0), ('figure', 5.0), ('salary', 5.0), ('table', 5.0), ('applicant', 5.0), ('%', 5.0), ('care', 5.0), ('hobby', 5.0), ('som', 5.0), ('ska', 5.0), ('answer', 5.0), ('kind', 4.666666666666667), ('phone', 4.5), ('administrator', 4.5), ('register', 4.5), ('task', 4.5), ('right', 4.5), ('contact', 4.333333333333333), ('value', 4.0), ('request', 4.0), ('order', 4.0), ('job', 4.0), ('opinion', 4.0), ('extent', 4.0), ('alternative', 4.0), ('leisure', 4.0), ('gardening', 4.0), ('relative', 4.0), ('help', 4.0), ('½', 4.0), ('calendar', 4.0), ('wage', 4.0), ('fee', 4.0), ('viktigaste', 4.0), ('framkommit', 4.0), ('ligger', 4.0), ('beslutet', 4.0), ('farm', 4.0), ('up', 4.0), ('overtime', 4.0), ('lodger', 4.0), ('transportation', 4.0), ('part', 3.6666666666666665), ('type', 3.6666666666666665), ('statement', 3.5), ('resident', 3.5), ('employee', 3.5), ('meeting', 3.5), ('increase', 3.3333333333333335), ('condition', 3.3333333333333335), ('line', 3.0), ('situation', 3.0), ('train', 3.0), ('bus', 3.0), ('caravan', 3.0), ('starting', 3.0), ('deputy', 3.0), ('correspondence', 3.0), ('illness', 3.0), ('member', 3.0), ('recalculation', 3.0), ('appointment', 3.0), ('patient', 3.0), ('possibility', 3.0), ('apartment', 3.0), ('house', 3.0), ('aid', 3.0), ('bond', 3.0), ('knowledge', 2.6666666666666665), ('interest', 2.6666666666666665), ('page', 2.5), ('picture', 2.5), ('attention', 2.5), ('street', 2.5), ('property', 2.5), ('study', 2.5), ('word', 2.5), ('receipt', 2.5), ('education', 2.5), ('view', 2.5), ('share', 2.5), ('age', 2.3333333333333335), ('access', 2.3333333333333335), ('people', 2.3333333333333335), ('public', 2.0), ('institution', 2.0), ('regulation', 2.0), ('option', 2.0), ('waiver', 2.0), ('travel', 2.0), ('km', 2.0), ('population', 2.0), ('registration', 2.0), ('provider', 2.0), ('doctor(s', 2.0), ('provider(s', 2.0), ('occupation', 2.0), ('household', 2.0), ('caregiver', 2.0), ('caregiver(s', 2.0), ('housework', 2.0), ('preference', 2.0), ('authorisation', 2.0), ('signatory', 2.0), ('custodian', 2.0), ('bort', 2.0), ('place', 2.0), ('transition', 2.0), ('sheet', 2.0), ('om', 2.0), ('helt', 2.0), ('purpose', 2.0), ('företagare', 2.0), ('den', 2.0), ('paragrafer', 2.0), ('all', 2.0), ('tremånadersregeln', 2.0), ('weekday', 2.0), ('leave', 2.0), ('sakna', 2.0), ('result', 2.0), ('datum', 2.0), ('reminder', 2.0), ('hälsningsfra', 2.0), ('xxxxx', 2.0), ('seafarer', 2.0), ('sjömän', 2.0), ('land', 2.0), ('assistant', 2.0), ('follow', 2.0), ('incl', 2.0), ('receive(s', 2.0), ('subsistence', 2.0), ('extension', 2.0), ('maintenance', 2.0), ('repayment', 2.0), ('mortgage', 2.0), ('loan', 2.0), ('metre', 2.0), ('electricity', 2.0), ('sewage', 2.0), ('sweeping', 2.0), ('site', 2.0), ('leasehold', 2.0), ('ownership', 2.0), ('householder', 2.0), ('record', 2.0), ('diem', 2.0), ('receivables', 2.0), ('guardian', 2.0), ('bill', 2.0), ('invoice', 2.0), ('deposit', 2.0), ('country´s', 2.0), ('honour', 2.0), ('location', 2.0), ('security', 1.6666666666666667), ('connection', 1.6666666666666667), ('assessment', 1.5), ('boat', 1.5), ('extract', 1.5), ('procedure', 1.5), ('cell', 1.5), ('equivalent', 1.5), ('association', 1.5), ('opportunity', 1.5), ('disability', 1.5), ('point', 1.3333333333333333), ('level', 1.3333333333333333), ('coordination', 1.3333333333333333), ('collection', 1.3333333333333333), ('town', 1.0), ('it´s', 1.0), ('arrangement', 1.0), ('postcode', 1.0), ('client', 1.0), ('occupational', 1.0), ('type(s', 1.0), ('report', 1.0), ('force', 1.0), ('instruction', 1.0), ('representative', 1.0), ('component', 1.0), ('svaret', 1.0), ('determination', 1.0), ('servant', 1.0), ('objection', 1.0), ('article', 1.0), ('concern', 1.0), ('status', 1.0), ('övervägande', 1.0), ('alla', 1.0), ('försäkrade', 1.0), ('bedömer', 1.0), ('efter', 1.0), ('haft', 1.0), ('vår', 1.0), ('bedömning', 1.0), ('quarter', 1.0), ('labour', 1.0), ('market', 1.0), ('egna', 1.0), ('erbjuda', 1.0), ('gjort', 1.0), ('bedömningen', 1.0), ('hänvisning', 1.0), ('och', 1.0), ('alltid', 1.0), ('finna', 1.0), ('måste', 1.0), ('anställd', 1.0), ('egen', 1.0), ('arbetslös', 1.0), ('sjukersättning', 1.0), ('möjlighet', 1.0), ('b', 1.0), ('anställda', 1.0), ('förbrukat', 1.0), ('finn', 1.0), ('seeker', 1.0), ('touch', 1.0), ('vänlig', 1.0), ('hälsning', 1.0), ('underskrift', 1.0), ('restriction', 1.0), ('sick', 1.0), ('listing', 1.0), ('ärenden', 1.0), ('attachment', 1.0), ('……', 1.0), ('retraining', 1.0), ('pay', 1.0), ('rent', 1.0), ('water', 1.0), ('chimney', 1.0), ('policy', 1.0), ('People', 1.0), ('dividend', 1.0), ('kilometre', 1.0), ('start', 1.0), ('contract', 1.0), ('www.forsakringskassan.se', 1.0), ('tv', 1.0), ('licence', 1.0), ('instance', 1.0), ('enterprise', 1.0), ('executor', 1.0), ('escort', 1.0), ('inheritance', 1.0), ('directorship', 1.0), ('nature', 0.6666666666666666), ('scope', 0.6666666666666666), ('regard', 0.6666666666666666), ('board', 0.6666666666666666), ('rule', 0.6666666666666666), ('mean', 0.6666666666666666), ('claim', 0.6666666666666666), ('size', 0.5), ('administration', 0.5), ('1st', 0.5), ('expert', 0.5), ('thing', 0.5), ('field', 0.5), ('guideline', 0.5), ('entitlement', 0.5), ('use', 0.5), ('gain', 0.5), ('sale', 0.5), ('grant', 0.5), ('food', 0.5), ('clothing', 0.5), ('term', 0.3333333333333333), ('legislation', 0.3333333333333333), ('measure', 0.3333333333333333), ('programme', 0.3333333333333333), ('development', 0.3333333333333333), ('end', 0.3333333333333333), ('half', 0.3333333333333333), ('principle', 0.3333333333333333), ('recommendation', 0.3333333333333333)]\n", + "[('▪', 45.0), ('insurance', 40.5), ('contribution', 35.0), ('pension', 25.5), ('benefit', 22.0), ('zus', 19.0), ('expenditure', 18.0), ('zu', 14.0), ('branch', 14.0), ('task', 13.5), ('fund', 13.0), ('%', 11.5), ('payer', 11.0), ('unit', 10.0), ('cooperation', 9.0), ('institution', 9.0), ('respect', 9.0), ('incapacity', 9.0), ('fus', 9.0), ('resource', 8.0), ('performance', 7.0), ('implementation', 7.0), ('employee', 6.5), ('client', 6.5), ('payment', 6.5), ('income', 6.5), ('operation', 6.5), ('agreement', 6.5), ('retirement', 6.0), ('prevention', 6.0), ('accident', 6.0), ('obligation', 6.0), ('transfer', 6.0), ('staff', 6.0), ('work', 5.666666666666667), ('year', 5.666666666666667), ('disability', 5.5), ('system', 5.333333333333333), ('age', 5.333333333333333), ('cost', 5.0), ('budget', 5.0), ('framework', 5.0), ('administration', 5.0), ('recipient', 5.0), ('account', 5.0), ('finance', 5.0), ('reform', 5.0), ('cash', 5.0), ('field', 4.5), ('member', 4.5), ('training', 4.5), ('allowance', 4.5), ('day', 4.333333333333333), ('history', 4.0), ('realisation', 4.0), ('worker', 4.0), ('person', 4.0), ('convention', 4.0), ('charge', 4.0), ('participant', 4.0), ('conference', 4.0), ('head', 4.0), ('ul', 4.0), ('structure', 3.5), ('source', 3.5), ('activity', 3.3333333333333335), ('information', 3.3333333333333335), ('service', 3.0), ('pillar', 3.0), ('state', 3.0), ('statute', 3.0), ('war', 3.0), ('law', 3.0), ('collar', 3.0), ('sickness', 3.0), ('voivodeship', 3.0), ('division', 3.0), ('inspectorate', 3.0), ('role', 3.0), ('plan', 3.0), ('evaluation', 3.0), ('proposal', 3.0), ('representative', 3.0), ('p.', 3.0), ('eligibility', 3.0), ('refund', 3.0), ('education', 3.0), ('participation', 3.0), ('allocation', 3.0), ('survivor', 3.0), ('funeral', 3.0), ('consultation', 3.0), ('country', 2.6666666666666665), ('e', 2.5), ('-', 2.5), ('office', 2.5), ('meeting', 2.5), ('access', 2.3333333333333335), ('time', 2.3333333333333335), ('use', 2.0), ('technology', 2.0), ('potential', 2.0), ('individual', 2.0), ('purpose', 2.0), ('security', 2.0), ('issue', 2.0), ('check', 2.0), ('rehabilitation', 2.0), ('collection', 2.0), ('aim', 2.0), ('relation', 2.0), ('solution', 2.0), ('party', 2.0), ('pensioner', 2.0), ('claimant', 2.0), ('need', 2.0), ('basis', 2.0), ('establishment', 2.0), ('change', 2.0), ('event', 2.0), ('maternity', 2.0), ('period', 2.0), ('loss', 2.0), ('organisation', 2.0), ('revenue', 2.0), ('competence', 2.0), ('body', 2.0), ('addition', 2.0), ('spending', 2.0), ('creation', 2.0), ('challenge', 2.0), ('emerytalne', 2.0), ('fulfilment', 2.0), ('certification', 2.0), ('forecast', 2.0), ('bank', 2.0), ('behalf', 2.0), ('minister', 2.0), ('qualification', 2.0), ('communication', 2.0), ('beneficiary', 2.0), ('skill', 2.0), ('deficit', 2.0), ('carer', 2.0), ('reimbursement', 2.0), ('entity', 2.0), ('coordination', 2.0), ('exchange', 2.0), ('seminar', 2.0), ('resident', 2.0), ('community', 2.0), ('function', 2.0), ('subject', 2.0), ('paper', 2.0), ('+48', 2.0), ('regulation', 1.6666666666666667), ('mean', 1.6666666666666667), ('contact', 1.6666666666666667), ('form', 1.6666666666666667), ('management', 1.5), ('matter', 1.5), ('capital', 1.5), ('employer', 1.5), ('risk', 1.5), ('investigation', 1.5), ('goal', 1.5), ('datum', 1.5), ('internet', 1.5), ('experience', 1.5), ('right', 1.5), ('analysis', 1.5), ('share', 1.5), ('grant', 1.5), ('deduction', 1.5), ('expert', 1.5), ('condition', 1.3333333333333333), ('doctor', 1.3333333333333333), ('decision', 1.3333333333333333), ('health', 1.3333333333333333), ('scope', 1.3333333333333333), ('number', 1.3333333333333333), ('claim', 1.3333333333333333), ('compendium', 1.0), ('status', 1.0), ('mission', 1.0), ('user', 1.0), ('force', 1.0), ('principle', 1.0), ('month', 1.0), ('amount', 1.0), ('award', 1.0), ('type', 1.0), ('subsidy', 1.0), ('support', 1.0), ('entitlement', 1.0), ('validity', 1.0), ('result', 1.0), ('place', 1.0), ('employment', 1.0), ('recording', 1.0), ('monie', 1.0), ('advance', 1.0), ('taxation', 1.0), ('series', 1.0), ('one', 1.0), ('satisfaction', 1.0), ('development', 1.0), ('trust', 1.0), ('leader', 1.0), ('district', 1.0), ('face', 1.0), ('submitting', 1.0), ('application', 1.0), ('device', 1.0), ('computer', 1.0), ('am', 1.0), ('pm', 1.0), ('flow', 1.0), ('waiting', 1.0), ('order', 1.0), ('society', 1.0), ('power', 1.0), ('image', 1.0), ('manner', 1.0), ('publication', 1.0), ('reader', 1.0), ('personality', 1.0), ('ordinance', 1.0), ('rule', 1.0), ('sector', 1.0), ('accountancy', 1.0), ('procurement', 1.0), ('compliance', 1.0), ('studio', 1.0), ('centralisation', 1.0), ('operating', 1.0), ('headquarters', 1.0), ('region', 1.0), ('autonomy', 1.0), ('reorganisation', 1.0), ('fullrange', 1.0), ('trade', 1.0), ('union', 1.0), ('latter', 1.0), ('unity', 1.0), ('stability', 1.0), ('act', 1.0), ('group', 1.0), ('province', 1.0), ('decentralisation', 1.0), ('range', 1.0), ('adoption', 1.0), ('financing', 1.0), ('majority', 1.0), ('indexation', 1.0), ('privilege', 1.0), ('ease', 1.0), ('link', 1.0), ('turn', 1.0), ('register', 1.0), ('improvement', 1.0), ('functionality', 1.0), ('servicing', 1.0), ('perspective', 1.0), ('decade', 1.0), ('commencement', 1.0), ('architect', 1.0), ('modernism', 1.0), ('following', 1.0), ('settlement', 1.0), ('control', 1.0), ('study', 1.0), ('dissemination', 1.0), ('knowledge', 1.0), ('sense', 1.0), ('collect', 1.0), ('membership', 1.0), ('tax', 1.0), ('recruitment', 1.0), ('economy', 1.0), ('supervision', 1.0), ('headquarter', 1.0), ('nation', 1.0), ('interpretation', 1.0), ('print', 1.0), ('out', 1.0), ('asset', 1.0), ('network', 1.0), ('map', 1.0), ('publishing', 1.0), ('chart', 1.0), ('side', 1.0), ('woman', 1.0), ('element', 1.0), ('strategy', 1.0), ('advisor', 1.0), ('internship', 1.0), ('gender', 1.0), ('man', 1.0), ('liability', 1.0), ('proceed', 1.0), ('item', 1.0), ('absenteeism', 1.0), ('connection', 1.0), ('lump', 1.0), ('sum', 1.0), ('effectiveness', 1.0), ('recourse', 1.0), ('core', 1.0), ('amortisation', 1.0), ('depreciation', 1.0), ('taxis', 1.0), ('scale', 1.0), ('accord', 1.0), ('sphere', 1.0), ('directive', 1.0), ('foreigner', 1.0), ('project', 1.0), ('concept', 1.0), ('simplification', 1.0), ('acquisition', 1.0), ('committee', 1.0), ('president', 1.0), ('sitting', 1.0), ('5th', 1.0), ('6th', 1.0), ('session', 1.0), ('limitation', 1.0), ('undertaking', 1.0), ('expertise', 1.0), ('popularising', 1.0), ('mail', 1.0), ('landline', 1.0), ('call', 1.0), ('telecommunications', 1.0), ('fax', 1.0), ('www.zus.pl', 1.0), ('compilation', 1.0), ('language', 1.0), ('verification', 1.0), ('formatting', 1.0), ('25a', 1.0), ('photo', 1.0), ('egzemplarzy', 1.0), ('people', 0.6666666666666666), ('term', 0.6666666666666666), ('nature', 0.6666666666666666), ('programme', 0.6666666666666666), ('document', 0.6666666666666666), ('question', 0.6666666666666666), ('legislation', 0.6666666666666666), ('company', 0.6666666666666666), ('part', 0.6666666666666666), ('centre', 0.6666666666666666), ('level', 0.6666666666666666), ('board', 0.6666666666666666), ('interest', 0.6666666666666666), ('vision', 0.5), ('certificate', 0.5), ('ability', 0.5), ('pre', 0.5), ('possibility', 0.5), ('signature', 0.5), ('component', 0.5), ('telephone', 0.5), ('research', 0.5), ('beginning', 0.5), ('policy', 0.5), ('disease', 0.5), ('unemployment', 0.5), ('property', 0.5), ('way', 0.5), ('rhythm', 0.5), ('city', 0.5), ('population', 0.5), ('administrator', 0.5), ('identification', 0.5), ('assessment', 0.5), ('determination', 0.5), ('cause', 0.5), ('department', 0.5), ('model', 0.5), ('approach', 0.5), ('course', 0.5), ('calendar', 0.5), ('pay', 0.5), ('expense', 0.5), ('compensation', 0.5), ('profit', 0.5), ('chapter', 0.5), ('material', 0.5), ('energy', 0.5), ('salary', 0.5), ('organism', 0.5), ('working', 0.5), ('association', 0.5), ('post', 0.5), ('effect', 0.5), ('1st', 0.5), ('conjunction', 0.5), ('correspondence', 0.5), ('reply', 0.5), ('phone', 0.5), ('operator', 0.5), ('text', 0.5), ('illness', 0.3333333333333333), ('increase', 0.3333333333333333), ('area', 0.3333333333333333), ('home', 0.3333333333333333), ('self', 0.3333333333333333), ('point', 0.3333333333333333), ('situation', 0.3333333333333333), ('provision', 0.3333333333333333), ('customer', 0.3333333333333333), ('case', 0.3333333333333333), ('half', 0.3333333333333333), ('regard', 0.3333333333333333), ('supplement', 0.3333333333333333), ('end', 0.3333333333333333), ('kind', 0.3333333333333333), ('measure', 0.3333333333333333), ('business', 0.3333333333333333), ('fee', 0.3333333333333333), ('recommendation', 0.3333333333333333)]\n", + "[('child', 574.0), ('food', 409.5), ('milk', 343.0), ('fish', 171.0), ('vitamin', 153.0), ('meat', 140.0), ('formula', 138.0), ('breast', 122.0), ('product', 122.0), ('vegetable', 110.0), ('water', 78.5), ('bacteria', 78.0), ('adult', 77.0), ('fruit', 76.0), ('salt', 76.0), ('substance', 71.0), ('drink', 70.0), ('fibre', 70.0), ('meal', 70.0), ('allergy', 70.0), ('advice', 69.0), ('fat', 68.0), ('hand', 65.0), ('porridge', 64.0), ('mineral', 62.0), ('iron', 60.0), ('chicken', 60.0), ('snack', 59.0), ('lot', 59.0), ('sugar', 58.0), ('nutrient', 57.0), ('bean', 57.0), ('lentil', 57.0), ('nutrition', 56.0), ('oil', 55.0), ('d', 54.0), ('year', 52.666666666666664), ('example', 52.0), ('blood', 49.0), ('potato', 48.0), ('breakfast', 44.0), ('idea', 44.0), ('gruel', 44.0), ('dairy', 43.0), ('salmon', 42.0), ('bread', 42.0), ('dinner', 42.0), ('keyhole', 42.0), ('time', 39.333333333333336), ('egg', 39.0), ('bottle', 38.0), ('yoghurt', 38.0), ('portion', 38.0), ('rice', 37.0), ('piece', 37.0), ('protein', 36.0), ('refrigerator', 35.0), ('cheese', 35.0), ('bit', 35.0), ('amount', 34.333333333333336), ('taste', 34.0), ('stomach', 34.0), ('other', 34.0), ('source', 33.0), ('hygiene', 31.0), ('berry', 30.0), ('couple', 30.0), ('flavour', 30.0), ('tofu', 30.0), ('risk', 29.5), ('month', 29.333333333333332), ('dish', 29.0), ('margarine', 28.0), ('trout', 28.0), ('weight', 28.0), ('mealtime', 28.0), ('rapeseed', 28.0), ('iodine', 27.0), ('way', 26.0), ('cereal', 26.0), ('inspection', 26.0), ('day', 25.0), ('packaging', 25.0), ('lunch', 25.0), ('virus', 24.0), ('pasta', 24.0), ('nut', 24.0), ('infant', 24.0), ('temperature', 23.0), ('grain', 23.0), ('root', 23.0), ('drop', 23.0), ('drinking', 22.0), ('mind', 22.0), ('cooking', 22.0), ('well', 22.0), ('store', 22.0), ('infection', 22.0), ('nurse', 21.0), ('foodstuff', 21.0), ('calcium', 21.0), ('label', 21.0), ('mix', 21.0), ('authority', 20.5), ('business', 20.333333333333332), ('coffee', 19.0), ('nourishment', 19.0), ('kind', 19.0), ('pudding', 19.0), ('mercury', 19.0), ('week', 19.0), ('breastfeeding', 19.0), ('type', 18.666666666666668), ('room', 18.0), ('ice', 18.0), ('tooth', 18.0), ('herring', 18.0), ('sandwich', 18.0), ('herb', 18.0), ('feeding', 18.0), ('spoon', 18.0), ('pregnancy', 17.0), ('wholegrain', 17.0), ('tea', 17.0), ('green', 17.0), ('consistency', 17.0), ('chickpea', 16.0), ('shellfish', 16.0), ('dioxin', 16.0), ('cream', 16.0), ('slice', 16.0), ('vegetarian', 16.0), ('equipment', 16.0), ('balance', 16.0), ('package', 16.0), ('wheat', 16.0), ('labelling', 16.0), ('premise', 16.0), ('website', 15.0), ('total', 15.0), ('specie', 15.0), ('symbol', 15.0), ('mouth', 15.0), ('freezer', 15.0), ('caffeine', 15.0), ('candy', 15.0), ('mother', 15.0), ('acid', 14.0), ('calorie', 14.0), ('diet', 14.0), ('family', 14.0), ('microwave', 14.0), ('juice', 14.0), ('routine', 14.0), ('control', 14.0), ('teaspoon', 14.0), ('consumer', 14.0), ('thing', 13.5), ('parent', 13.5), ('need', 13.5), ('life', 13.0), ('people', 13.0), ('recipe', 13.0), ('additive', 13.0), ('kitchen', 13.0), ('age', 13.0), ('closeness', 13.0), ('production', 13.0), ('texture', 13.0), ('dill', 13.0), ('plate', 13.0), ('information', 12.666666666666666), ('rest', 12.0), ('leftover', 12.0), ('dietician', 12.0), ('responsibility', 12.0), ('damage', 12.0), ('animal', 12.0), ('vegan', 12.0), ('rash', 12.0), ('hypersensitivity', 12.0), ('cutting', 12.0), ('gluten', 12.0), ('wafer', 12.0), ('fork', 12.0), ('processor', 12.0), ('requirement', 12.0), ('health', 11.333333333333334), ('omega', 11.0), ('liver', 11.0), ('environment', 11.0), ('baby', 11.0), ('carrot', 11.0), ('problem', 11.0), ('parsley', 11.0), ('tap', 10.0), ('difference', 10.0), ('pollutant', 10.0), ('skin', 10.0), ('kidney', 10.0), ('pressure', 10.0), ('intolerance', 10.0), ('g', 10.0), ('peanut', 10.0), ('parasite', 9.0), ('municipality', 9.0), ('folic', 9.0), ('habit', 9.0), ('carbohydrate', 9.0), ('bun', 9.0), ('pea', 9.0), ('vomiting', 9.0), ('diarrhoea', 9.0), ('proportion', 9.0), ('supplement', 8.666666666666666), ('number', 8.666666666666666), ('page', 8.5), ('energy', 8.5), ('rule', 8.333333333333334), ('term', 8.333333333333334), ('mackerel', 8.0), ('pâté', 8.0), ('selenium', 8.0), ('tuna', 8.0), ('cake', 8.0), ('charcuterie', 8.0), ('content', 8.0), ('body', 8.0), ('cookie', 8.0), ('stool', 8.0), ('experiment', 8.0), ('skeleton', 8.0), ('butter', 8.0), ('rate', 8.0), ('safety', 8.0), ('plenty', 8.0), ('poisoning', 8.0), ('brook', 8.0), ('campylobacter', 8.0), ('pain', 8.0), ('www.1177.se', 8.0), ('council', 8.0), ('gastroenteritis', 8.0), ('solid', 8.0), ('thyme', 8.0), ('grater', 8.0), ('pace', 8.0), ('café', 8.0), ('brochure', 7.5), ('woman', 7.5), ('case', 7.333333333333333), ('halibut', 7.0), ('list', 7.0), ('alcohol', 7.0), ('wash', 7.0), ('soy', 7.0), ('copper', 7.0), ('pipe', 7.0), ('colour', 7.0), ('can', 7.0), ('broccoli', 7.0), ('tomato', 7.0), ('corn', 7.0), ('apple', 7.0), ('banana', 7.0), ('choice', 7.0), ('nausea', 7.0), ('puff', 7.0), ('middle', 7.0), ('quality', 7.0), ('appetite', 7.0), ('height', 7.0), ('curve', 7.0), ('onion', 7.0), ('pepper', 7.0), ('garlic', 7.0), ('lemon', 7.0), ('mug', 7.0), ('pork', 7.0), ('flavouring', 7.0), ('midwife', 7.0), ('cup', 7.0), ('hour', 6.5), ('rhythm', 6.5), ('registration', 6.5), ('order', 6.333333333333333), ('track', 6.0), ('frozen', 6.0), ('char', 6.0), ('dose', 6.0), ('tablet', 6.0), ('variety', 6.0), ('deal', 6.0), ('seed', 6.0), ('litre', 6.0), ('finger', 6.0), ('tbsp', 6.0), ('ailment', 6.0), ('transport', 6.0), ('sample', 6.0), ('legislation', 6.0), ('allergen', 6.0), ('space', 6.0), ('origin', 6.0), ('contain', 6.0), ('research', 5.5), ('attention', 5.5), ('reason', 5.0), ('minute', 5.0), ('help', 5.0), ('oat', 5.0), ('web', 5.0), ('plant', 5.0), ('brand', 5.0), ('fact', 5.0), ('contaminant', 5.0), ('instruction', 5.0), ('beef', 5.0), ('mash', 5.0), ('tsp', 5.0), ('coarser', 5.0), ('c', 5.0), ('like', 5.0), ('honey', 5.0), ('biscuit', 5.0), ('-', 5.0), ('good', 5.0), ('guideline', 5.0), ('fee', 5.0), ('border', 5.0), ('pest', 5.0), ('e', 4.5), ('container', 4.0), ('salad', 4.0), ('angler', 4.0), ('shop', 4.0), ('pollock', 4.0), ('mussel', 4.0), ('exercise', 4.0), ('sweet', 4.0), ('treat', 4.0), ('quantity', 4.0), ('effect', 4.0), ('listeria', 4.0), ('guide', 4.0), ('toilet', 4.0), ('whole', 4.0), ('course', 4.0), ('occasion', 4.0), ('analysis', 4.0), ('home', 4.0), ('fun', 4.0), ('cookbook', 4.0), ('brain', 4.0), ('ache', 4.0), ('cut', 4.0), ('cucumber', 4.0), ('stick', 4.0), ('hunger', 4.0), ('cabbage', 4.0), ('sauce', 4.0), ('stew', 4.0), ('helping', 4.0), ('sake', 4.0), ('gratin', 4.0), ('lacto', 4.0), ('diagnosis', 4.0), ('explanation', 4.0), ('trouble', 4.0), ('board', 4.0), ('pcb', 4.0), ('girl', 4.0), ('boy', 4.0), ('perch', 4.0), ('burbot', 4.0), ('shark', 4.0), ('ray', 4.0), ('cola', 4.0), ('heartbeat', 4.0), ('farm', 4.0), ('metabolism', 4.0), ('solanine', 4.0), ('sweetener', 4.0), ('curd', 4.0), ('retrospect', 4.0), ('fantastic', 4.0), ('beginning', 4.0), ('sleeping', 4.0), ('exception', 4.0), ('hospital', 4.0), ('clinic', 4.0), ('ear', 4.0), ('diabetes', 4.0), ('protection', 4.0), ('growth', 4.0), ('teat', 4.0), ('method', 4.0), ('comfort', 4.0), ('tool', 4.0), ('pinch', 4.0), ('tongue', 4.0), ('decrease', 4.0), ('bite', 4.0), ('spoonful', 4.0), ('introduction', 4.0), ('process', 4.0), ('mush', 4.0), ('ground', 4.0), ('difficulty', 4.0), ('purée', 4.0), ('parsnip', 4.0), ('pot', 4.0), ('press', 4.0), ('strainer', 4.0), ('blender', 4.0), ('heat', 4.0), ('runoff', 4.0), ('knife', 4.0), ('raisin', 4.0), ('carriage', 4.0), ('soother', 4.0), ('lettuce', 4.0), ('rocket', 4.0), ('spinach', 4.0), ('nitrate', 4.0), ('oxygen', 4.0), ('potoatoe', 4.0), ('spore', 4.0), ('intestine', 4.0), ('botulin', 4.0), ('poison', 4.0), ('coriander', 4.0), ('sausage', 4.0), ('rosehip', 4.0), ('soup', 4.0), ('jelly', 4.0), ('marmalade', 4.0), ('soda', 4.0), ('redness', 4.0), ('bottom', 4.0), ('menu', 4.0), ('approval', 4.0), ('operator', 4.0), ('supplier', 4.0), ('smoke', 4.0), ('traceability', 4.0), ('permit', 4.0), ('utensil', 4.0), ('spina', 4.0), ('foetus', 4.0), ('sushi', 4.0), ('filling', 4.0), ('maize', 4.0), ('foto', 4.0), ('period', 3.6666666666666665), ('interest', 3.6666666666666665), ('following', 3.5), ('staff', 3.5), ('one', 3.5), ('material', 3.5), ('issue', 3.5), ('post', 3.5), ('procedure', 3.5), ('date', 3.5), ('suspicion', 3.0), ('saucepan', 3.0), ('kettle', 3.0), ('jug', 3.0), ('maker', 3.0), ('boiling', 3.0), ('rinse', 3.0), ('shower', 3.0), ('question', 3.0), ('healthcare', 3.0), ('remedy', 3.0), ('ginseng', 3.0), ('percent', 3.0), ('washing', 3.0), ('clothe', 3.0), ('recommendation', 3.0), ('thumb', 3.0), ('range', 3.0), ('chance', 3.0), ('curiosity', 3.0), ('pak', 3.0), ('legume', 3.0), ('skim', 3.0), ('sensitivity', 3.0), ('consideration', 3.0), ('limit', 3.0), ('pesticide', 3.0), ('wild', 3.0), ('producer', 3.0), ('bacterium', 3.0), ('chip', 3.0), ('night', 3.0), ('follow', 3.0), ('department', 3.0), ('opportunity', 3.0), ('pear', 3.0), ('floret', 3.0), ('bell', 3.0), ('clove', 3.0), ('filet', 3.0), ('cube', 3.0), ('tray', 3.0), ('hurry', 3.0), ('base', 3.0), ('mealti-', 3.0), ('me', 3.0), ('cavity', 3.0), ('dessert', 3.0), ('ingredient', 3.0), ('reaction', 3.0), ('storage', 3.0), ('handling', 3.0), ('objective', 3.0), ('sore', 3.0), ('contamination', 3.0), ('delivery', 3.0), ('inspector', 3.0), ('importance', 3.0), ('intake', 3.0), ('poultry', 3.0), ('game', 3.0), ('rind', 3.0), ('chèvre', 3.0), ('vacherol', 3.0), ('garden', 3.0), ('cat', 3.0), ('faece', 3.0), ('www.sva.se', 3.0), ('www.slv.se', 3.0), ('model', 3.0), ('left', 3.0), ('chocolate', 3.0), ('ball', 3.0), ('lid', 3.0), ('min', 3.0), ('imitation', 3.0), ('situation', 2.6666666666666665), ('face', 2.5), ('goal', 2.5), ('sale', 2.5), ('letter', 2.5), ('point', 2.0), ('tank', 2.0), ('breastfeed', 2.0), ('level', 2.0), ('box', 2.0), ('flesh', 2.0), ('gym', 2.0), ('walk', 2.0), ('speed', 2.0), ('complication', 2.0), ('dietitian', 2.0), ('toxoplasma', 2.0), ('bath', 2.0), ('dishwasher', 2.0), ('surface', 2.0), ('flower', 2.0), ('road', 2.0), ('muesli', 2.0), ('culture', 2.0), ('group', 2.0), ('vision', 2.0), ('boat', 2.0), ('section', 2.0), ('development', 2.0), ('pigment', 2.0), ('summer', 2.0), ('arm', 2.0), ('leg', 2.0), ('extract', 2.0), ('structure', 2.0), ('maternity', 2.0), ('knowledge', 2.0), ('approach', 2.0), ('dl', 2.0), ('evening', 2.0), ('exemple', 2.0), ('item', 2.0), ('trading', 2.0), ('facility', 2.0), ('identity', 2.0), ('monitoring', 2.0), ('preparation', 2.0), ('batch', 2.0), ('openness', 2.0), ('recall', 2.0), ('station', 2.0), ('notification', 2.0), ('trace', 2.0), ('industry', 2.0), ('demand', 2.0), ('waste', 2.0), ('rise', 2.0), ('symptom', 2.0), ('plaster', 2.0), ('area', 2.0), ('cleaning', 2.0), ('chain', 2.0), ('prawn', 2.0), ('crown', 2.0), ('average', 2.0), ('longing', 2.0), ('tiredness', 2.0), ('diabete', 2.0), ('flounder', 2.0), ('dab', 2.0), ('algae', 2.0), ('linseed', 2.0), ('stimulation', 2.0), ('while', 2.0), ('bib', 2.0), ('a', 2.0), ('miscarriage', 2.0), ('milligram', 2.0), ('arsenic', 2.0), ('trap', 2.0), ('part', 1.6666666666666667), ('end', 1.6666666666666667), ('option', 1.5), ('side', 1.5), ('office', 1.5), ('name', 1.5), ('address', 1.5), ('description', 1.5), ('start', 1.5), ('centre', 1.3333333333333333), ('form', 1.3333333333333333), ('half', 1.3333333333333333), ('support', 1.3333333333333333), ('security', 1.3333333333333333), ('illness', 1.3333333333333333), ('connection', 1.3333333333333333), ('regulation', 1.3333333333333333), ('work', 1.3333333333333333), ('company', 1.3333333333333333), ('system', 1.3333333333333333), ('customer', 1.3333333333333333), ('claim', 1.3333333333333333), ('purpose', 1.3333333333333333), ('access', 1.0), ('birth', 1.0), ('care', 1.0), ('beverage', 1.0), ('glass', 1.0), ('wine', 1.0), ('center', 1.0), ('parenthood', 1.0), ('doctor', 1.0), ('note', 1.0), ('sprinkler', 1.0), ('pool', 1.0), ('clothing', 1.0), ('basis', 1.0), ('today', 1.0), ('*', 1.0), ('service', 1.0), ('overview', 1.0), ('back', 1.0), ('place', 1.0), ('consumption', 1.0), ('advertisement', 1.0), ('presentation', 1.0), ('size', 1.0), ('complexity', 1.0), ('duration', 1.0), ('=', 1.0), ('decision', 1.0), ('followup', 1.0), ('self-', 1.0), ('novel', 1.0), ('waybill', 1.0), ('country', 1.0), ('notice', 1.0), ('Pre', 1.0), ('derive', 1.0), ('www.livsmedelsverket.se', 1.0), ('entrepreneurship', 1.0), ('feed', 1.0), ('definition', 1.0), ('’s', 1.0), ('continuity', 1.0), ('beer', 1.0), ('cafés', 1.0), ('medium', 1.0), ('building', 1.0), ('permission', 1.0), ('drainage', 1.0), ('grease', 1.0), ('separation', 1.0), ('ventilation', 1.0), ('garbage', 1.0), ('recycling', 1.0), ('pie', 1.0), ('baking', 1.0), ('reference', 1.0), ('obstacle', 1.0), ('route', 1.0), ('throat', 1.0), ('cold', 1.0), ('glove', 1.0), ('dirt', 1.0), ('crossflow', 1.0), ('basin', 1.0), ('floor', 1.0), ('rodent', 1.0), ('insect', 1.0), ('bird', 1.0), ('carrier', 1.0), ('disease', 1.0), ('break', 1.0), ('dog', 1.0), ('refrigeration', 1.0), ('thaw', 1.0), ('guest', 1.0), ('ham', 1.0), ('informatio', 1.0), ('decoration', 1.0), ('sign', 1.0), ('shelf', 1.0), ('costumer', 1.0), ('distribution', 1.0), ('thank', 1.0), ('personnel', 1.0), ('entrepreneur', 1.0), ('comment', 1.0), ('deviation', 1.0), ('visit', 1.0), ('bakery', 1.0), ('alternative', 1.0), ('cell', 1.0), ('tel', 1.0), ('crop', 1.0), ('swede', 1.0), ('celeriac', 1.0), ('casserole', 1.0), ('category', 1.0), ('decilitre', 1.0), ('om', 1.0), ('livsmedelsverket@slv.se', 1.0), ('folate', 1.0), ('placenta', 1.0), ('cl', 1.0), ('ml', 1.0), ('dosage', 1.0), ('toxoplasmosis', 1.0), ('run', 1.0), ('barley', 1.0), ('rye', 1.0), ('hassle', 1.0), ('word', 1.0), ('change', 0.6666666666666666), ('programme', 0.6666666666666666), ('coordination', 0.6666666666666666), ('scope', 0.6666666666666666), ('application', 0.6666666666666666), ('contact', 0.6666666666666666), ('mean', 0.6666666666666666), ('increase', 0.6666666666666666), ('photo', 0.5), ('equivalent', 0.5), ('experience', 0.5), ('aim', 0.5), ('x', 0.5), ('operation', 0.5), ('travel', 0.5), ('identification', 0.5), ('statement', 0.5), ('no', 0.5), ('organism', 0.5), ('market', 0.5), ('receipt', 0.5), ('trade', 0.5), ('pre', 0.5), ('organisation', 0.5), ('public', 0.5), ('request', 0.5), ('street', 0.5), ('chimney', 0.5), ('cause', 0.5), ('training', 0.5), ('view', 0.5), ('flow', 0.5), ('management', 0.5), ('text', 0.5), ('picture', 0.5), ('conjunction', 0.5), ('documentation', 0.5), ('report', 0.5), ('detail', 0.5), ('establishment', 0.5), ('profit', 0.5), ('mail', 0.5), ('gain', 0.5), ('extent', 0.5), ('activity', 0.3333333333333333), ('self', 0.3333333333333333), ('state', 0.3333333333333333), ('measure', 0.3333333333333333), ('condition', 0.3333333333333333), ('nature', 0.3333333333333333), ('collection', 0.3333333333333333), ('regard', 0.3333333333333333), ('person', 0.3333333333333333), ('document', 0.3333333333333333), ('principle', 0.3333333333333333), ('provision', 0.3333333333333333)]" ] }, { @@ -238,8 +339,27 @@ "metadata": {}, "outputs": [], "source": [ + "from wordcloud import WordCloud\n", + "import spacy\n", + "nlp = spacy.load(\"en_core_web_sm\")\n", + "dicts = [\n", + " \"en.txt\",\n", + " \"en(1).txt\",\n", + " \"en(2).txt\",\n", + "]\n", + "dicts_dir = 'data/'\n", + "\n", + "text = \"\"\n", + "for name in dicts:\n", + " file = open(dicts_dir + name, \"r\", encoding=\"utf8\")\n", + " text += file.read()\n", + "\n", + "\n", "def my_word_cloud():\n", - " pass" + " wordcloud = WordCloud(background_color=\"white\", max_words=50000000, contour_width=3, contour_color='steelblue')\n", + " wordcloud.generate(text)\n", + " return wordcloud.to_image()\n", + "\n" ] }, { @@ -263,7 +383,7 @@ "author": "Rafał Jaworski", "email": "rjawor@amu.edu.pl", "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -278,7 +398,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.9.2" }, "subtitle": "4,5. Klasyfikacja tematyczna (terminologii ciąg dalszy)", "title": "Komputerowe wspomaganie tłumaczenia", diff --git a/lab/lab_06-07.ipynb b/lab/lab_06-07.ipynb index 3b0a71a..2888dcf 100644 --- a/lab/lab_06-07.ipynb +++ b/lab/lab_06-07.ipynb @@ -60,8 +60,14 @@ "metadata": {}, "outputs": [], "source": [ + "import regex\n", + "\n", + "\n", "def find_tags(text):\n", - " return []" + " result = []\n", + " for occurance in regex.finditer(\"(\\)\", text, regex.IGNORECASE):\n", + " result.append(occurance.span())\n", + " return result" ] }, { @@ -79,8 +85,12 @@ "metadata": {}, "outputs": [], "source": [ + "import regex\n", + "\n", + "\n", + "# Assuming text is a single word\n", "def is_translatable(text):\n", - " return True" + " return regex.fullmatch(\"[A-Z\\-]+\", text, regex.IGNORECASE) is not None" ] }, { @@ -98,8 +108,26 @@ "metadata": {}, "outputs": [], "source": [ + "import regex\n", + "\n", + "\n", "def find_dates(text):\n", - " return []" + " regex_format = regex.compile(\"(?P[0-9]{1,2})[/.-](?P[0-9]{1,2})[/.-](?P[0-9]{4})\")\n", + " matches = regex.match(regex_format, text)\n", + " result = {\n", + " 'day': int(matches.group('day')),\n", + " 'month': int(matches.group('month')),\n", + " 'year': int(matches.group('year')),\n", + " }\n", + "\n", + " return result\n", + "\n", + "\n", + "print(find_dates(\"01/02/1970\"))\n", + "print(find_dates(\"01.02.1970\"))\n", + "print(find_dates(\"01-02-1970\"))\n", + "print(find_dates(\"1/2/1970\"))\n", + "print(find_dates(\"1.2.1970\"))" ] }, { @@ -130,8 +158,22 @@ "metadata": {}, "outputs": [], "source": [ + "formats = {\n", + " 'd/m/y': lambda date: f\"{date['day']}/{date['month']}/{date['year']}\",\n", + " 'y-m-d': lambda date: f\"{date['year']}-{date['month']}-{date['day']}\",\n", + "}\n", + "\n", + "\n", "def correct_dates(source_segment, target_segment, date_format):\n", - " return ''" + " source_date = find_dates(source_segment)\n", + " target_date = find_dates(target_segment)\n", + " if target_date != source_date:\n", + " print('Dates differ')\n", + "\n", + " return formats[date_format](source_date)\n", + "\n", + "\n", + "print(correct_dates(\"1.2.1970\", \"1.2.1970\", 'y-m-d'))" ] }, { @@ -190,7 +232,7 @@ "author": "Rafał Jaworski", "email": "rjawor@amu.edu.pl", "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -205,7 +247,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.9.2" }, "subtitle": "6,7. Preprocessing i postprocessing", "title": "Komputerowe wspomaganie tłumaczenia", diff --git a/lab/lab_09-10.ipynb b/lab/lab_09-10.ipynb index 683cdfa..a7077b0 100644 --- a/lab/lab_09-10.ipynb +++ b/lab/lab_09-10.ipynb @@ -50,37 +50,36 @@ "name": "stdout", "output_type": "stream", "text": [ - "Nastolatek ukradł znajomemu 4500 złotych. Wcześniej pił z nim alkohol\n", - "Czekają nas kolejne podwyżki rachunków. Tym razem za ogrzewanie i ciepłą wodę\n", - "Nie żyje Piotr Ś. Czyściciel kamienic miał 47 lat\n", - "Maciej Skorża nie zmienił zdania o systemie na mecz z Rakowem. Kolejorz ma szybką okazję do rehabilitacji\n", - "Kto zabił Kazimierę Kurkowiak? Poznańskie Archiwum X wraca do sprawy sprzed 30 lat\n", - "Mieszkańcy osiedla Kwiatowego zyskają nowy chodnik\n", - "Poznańskie ZOO ponownie się otwiera i apeluje o kupowanie biletów online\n", - "1700 zł mandatu dla motocyklisty: nie ma prawa jazdy, jechał za szybko\n", - "Plac Wolności ma tętnić życiem. Jest koncepcja zagospodarowania\n", - "Dzikie wysypisko w Wielkopolskim Parku Narodowym, a w nim paczka z telefonem odbiorcy\n", - "Dobre wieści z Łazarza! \"Zielona Perła\" sprzedana!\n", - "Sokoły wędrowne w gnieździe na kominie poznańskiej elektrociepłowni! Są 4 młode\n", - "720 nowych zakażeń w Wielkopolsce\n", - "Uderzył kobietę w sklepie: \"sprawca będzie rozliczony\"\n", - "Zespół Szkół Geodezyjno- Drogowych. Przyszłość rysuje się w kolorowych barwach!\n", - "Tajemniczy wypadek i pożar pod Kwilczem. Auto spłonęło, w środku nikogo nie było\n", - "Nad Jeziorem Maltańskim powstanie duży hotel? \"Ma uzupełniać infrastrukturę sportową\"\n", - "Śmiertelny wypadek na trasie S8: samochód potrącił rowerzystę\n", - "Specjaliści o poszukiwaniu Natalii Lick: \"niestety trop psa prowadził na Wartostradę\"\n", - "Korki przy skrzyżowaniu Grochowska / Grunwaldzka: ruszyły prace!\n", - "Restauracja w Kaliszu przyjmuje klientów: sanepid i policja \"odwiedzili\" lokal\n", - "Ile kosztuje wywóz odpadów?\n", - "Dachowanie auta na trasie Konin - Turek\n", - "Kierowca BMW pod wpływem narkotyków, pasażer w ich posiadaniu. Obaj zostali zatrzymani\n", - "Leszno: mężczyzna uderzył klientkę sklepu. Poszło o maseczkę?\n", - "Od poniedziałku zapłacimy za parkowanie na kolejnych ulicach\n", - "Włamał się do obiektu handlowego. Grozi mu nawet 15 lat więzienia\n", - "Rondo Śródka: kolizja z udziałem dwóch pojazdów\n", - "Europoseł PSL: oświadczenie Episkopatu ma wpływ na proces szczepień. \"Bardzo dużo ludzi zrezygnowało\"\n", - "Bezcenna wygrana Enea Energetyka. Poznanianki zagrają w fazie play-off\n", - "No to w drogę! Po odmienionych trasach w Wielkopolsce\n" + "W Poznaniu uroczyście odsłonięto monument upamiętniający cmentarz żydowski założony jeszcze w XIX wieku\n", + "Przez ulice Poznania przejdzie Marsz dla Życia. Będą utrudnienia\n", + "Sierść psa zatopiona w żywicy? Taką biżuterię pamiątkową zlecają właściciele czworonożnych pociech\n", + "Nagrał film w jednej z poznańskich \"Biedronek\". Kilka spleśniałych cytryn w kartonie. \"Nikt się tym nie przejmuje\"\n", + "Gniezno: poszkodowani po ulewie będą mogli ubiegać się o pomoc w ZUS i US. Powstała również specjalna infolinia\n", + "Zostawiła jedzenie dla potrzebujących. Coraz więcej głodnych osób, którym nie wystarcza pieniędzy po opłaceniu rachunków\n", + "Kolejne ostrzeżenie I stopnia od IMGW. Oprócz burz może wystąpić również grad\n", + "Lech przegrał Koroną. Na trybunach marsz żałobny i 'mamy k**** dość'\n", + "Warta Poznań po przegranej z Jagielonią Białystok spada do I ligi\n", + "Mieszkańcy skarżą się na właściciela samochodu, w którym notorycznie włącza się alarm. \"Uprzykrza nam to życie!\"\n", + "Leśne Placówki Montessori\n", + "Na autostradzie samochód wpadł w poślizg i stanął w poprzek. Są spore utrudnienia\n", + "Wróciła plaga kradzieży katalizatorów. Zmora dla kierowców, którzy nie mogą garażować auta\n", + "Nowy basen w Kiekrzu? W tunelu wody przybyło po same kolana\n", + "Pierożki Dim Sum z Para Bar Rataje ze specjalną zniżką!\n", + "Wielka głowa Darii Zawiałow zablokowała przez chwilę przejście dla pieszych na jednej z poznańskich ulic\n", + "Fałszywy pożar w centrum Poznania. Kłęby dymu w kamienicy?\n", + "Jest kolejne ostrzeżenie pierwszego stopnia, tym razem hydrologiczne. Gwałtowny wzrost stanu wody\n", + "Uwaga. Utrudnienia na drodze i ograniczenie prędkości. Potrwa to około 5 godzin\n", + "Chcą pobić rekord w kręceniu lodów. Tona lodów w ciągu doby\n", + "Jest ostrzeżenie IMGW dla Wielkopolski. Lepiej schować przedmioty, które mogą przemieścić się pod wypływem silnego wiatru\n", + "Nowe Centrum Medyczne Bizpark już w sprzedaży. Znajdź idealny lokal pod swoją działalność medyczną\n", + "Rondo Obornickie: zderzenie samochodu z motocyklem. Poszkodowany został odwieziony do szpitala. Chwilowe utrudnienia\n", + "Policjanci publikują wizerunek i szukają tego mężczyzny\n", + "Grupa Stonewall będzie miała program na antenie TVP3 Poznań. \"To będzie odtrutka na lata dezinformacji\"\n", + "Ruszył remont ważnego mostu. Co z kłódkami zakochanych?\n", + "Mieszkaniec spotkał wilka w Poznaniu?\n", + "Włamanie do... lokomotywy\n", + "W nadwarciański krajobraz wpisały się... żurawie. \"Jeden jest największy na świecie\"\n", + "Robisz remont? Za to możesz słono zapłacić!\n" ] } ], @@ -108,13 +107,51 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 10, "id": "moving-clothing", "metadata": {}, "outputs": [], "source": [ - "def get_names(article_type):\n", - " return []" + "from bs4 import element\n", + "\n", + "def get_names(article_type, page_nr: int = 0):\n", + " url = 'https://www.ceneo.pl/;szukaj-' + article_type + ';0020-30-0-0-' + str(page_nr) + '.htm'\n", + " page = requests.get(url)\n", + " if page_nr != 0 and url != page.url:\n", + " return []\n", + " soup = BeautifulSoup(page.content, 'html.parser')\n", + " result = []\n", + "\n", + " def is_product_title_container(tag: element.Tag) -> bool:\n", + " if not tag.has_attr('class'):\n", + " return False\n", + "\n", + " classes = tag.attrs['class']\n", + " if len(classes) != 1:\n", + " return False\n", + "\n", + " return classes[0] == 'cat-prod-row__name'\n", + "\n", + " def is_product_title(tag: element.Tag) -> bool:\n", + " if not tag.has_attr('class'):\n", + " return True\n", + "\n", + " classes = tag.attrs['class']\n", + " if len(classes) != 1:\n", + " return False\n", + "\n", + " return classes[0] == 'font-bold'\n", + "\n", + " for tag in soup.find_all(is_product_title_container):\n", + " href = tag.find('a')\n", + " if type(href) is not element.Tag:\n", + " continue\n", + " spans = href.find_all('span')\n", + " for span in spans:\n", + " if is_product_title(span):\n", + " result.append(span.text)\n", + "\n", + " return result" ] }, { @@ -135,13 +172,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "german-dispute", "metadata": {}, "outputs": [], "source": [ "def scrape_names():\n", - " return []" + " result = []\n", + " search = 'laptop'\n", + " page = 0\n", + " while True:\n", + " local_result = get_names(search, page)\n", + " if len(local_result) == 0:\n", + " return result\n", + " result = result + local_result\n", + " page += 1" ] }, { @@ -197,13 +242,39 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "regulation-sheriff", "metadata": {}, "outputs": [], "source": [ "def scrape_wmi():\n", - " return []" + " def get_text(soup_l: BeautifulSoup) -> str:\n", + " for trash in soup_l(['script', 'style']):\n", + " trash.extract()\n", + "\n", + " text = soup_l.get_text()\n", + "\n", + " return re.sub(r'\\s+', ' ', text)\n", + "\n", + " result = []\n", + "\n", + " base_url = 'https://wmi.amu.edu.pl/'\n", + " page = requests.get(base_url)\n", + " soup = BeautifulSoup(page.content, 'html.parser')\n", + " result.append(get_text(soup))\n", + " for href in soup.find_all('a'):\n", + " if type(href) != element.Tag:\n", + " continue\n", + "\n", + " if not href.has_attr('href'):\n", + " continue\n", + "\n", + " if base_url in href.attrs['href']:\n", + " sub_page = requests.get(href.attrs['href'])\n", + " result.append(get_text(BeautifulSoup(sub_page.content, 'html.parser')))\n", + "\n", + "\n", + " return result" ] }, { @@ -222,30 +293,97 @@ "### Ćwiczenie 4: Pobierz jak najwięcej słów w języku albańskim z serwisu glosbe.com." ] }, + { + "cell_type": "markdown", + "id": "706d6cba-c7a7-4d1b-9c2f-eb2119f859b5", + "metadata": {}, + "source": [ + "Nie jest to rozwiązanie zbalansowane, ale pobierze najwięcej słów (Przy odpowiedniej rotacji adresów IP, z których korzystamy, ale założyłem, że kwestia infrastruktury i tego jak strona jest chroniona przed atakami DOS, jest poza zakresem tego zadania)" + ] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "surgical-ozone", "metadata": {}, "outputs": [], "source": [ "def scrape_shqip():\n", - " return []" + " import string\n", + "\n", + " result = []\n", + " letters = list(string.ascii_lowercase)\n", + " letters_count = len(letters)\n", + " longest_sensible_english_word_len = 28\n", + " base_url = 'https://glosbe.com/en/sq/'\n", + "\n", + " def get_words(word_l: str) -> list[str]:\n", + " def is_translated_word(tag: element.Tag) -> bool:\n", + " if not tag.has_attr('id') or not tag.has_attr('lang'):\n", + " return False\n", + "\n", + " if not 'translation__' in tag.attrs['id'] or 'sq' != tag.attrs['lang']:\n", + " return False\n", + "\n", + " return True\n", + "\n", + " result_l = []\n", + " page = requests.get(base_url + word_l)\n", + " soup = BeautifulSoup(page.content, 'html.parser')\n", + " words_l = soup.find_all(is_translated_word)\n", + " for word_l in words_l:\n", + " text = word_l.text\n", + " result_l.append(re.sub(r'\\s+', ' ', text))\n", + "\n", + " return result_l\n", + "\n", + " def trans(word_l: list[int]) -> str:\n", + " result_l = ''\n", + " for letter_l in word_l:\n", + " result_l += letters[letter_l]\n", + "\n", + " return result_l\n", + "\n", + " def increment(word_l: list[int]) -> list[int]:\n", + " done = False\n", + " result_l = []\n", + " for letter_l in word_l:\n", + " if done:\n", + " result_l.append(letter_l)\n", + " continue\n", + " next_letter_l = letter_l + 1\n", + " if next_letter_l == letters_count:\n", + " result_l.append(0)\n", + " continue\n", + "\n", + " result_l.append(next_letter_l)\n", + " done = True\n", + "\n", + " return result_l\n", + "\n", + " for length in range(longest_sensible_english_word_len - 1):\n", + " length += 1\n", + " combos = pow(length, letters_count)\n", + " word = []\n", + " for pos in range(length):\n", + " word.append(0)\n", + " for i in range(combos):\n", + " result.append(get_words(trans(word)))\n", + " word = increment(word)\n", + "\n", + " return result" ] } ], "metadata": { "author": "Rafał Jaworski", "email": "rjawor@amu.edu.pl", - "lang": "pl", - "subtitle": "9,10. Web scraping", - "title": "Komputerowe wspomaganie tłumaczenia", - "year": "2021", "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, + "lang": "pl", "language_info": { "codemirror_mode": { "name": "ipython", @@ -256,8 +394,11 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" - } + "version": "3.10.4" + }, + "subtitle": "9,10. Web scraping", + "title": "Komputerowe wspomaganie tłumaczenia", + "year": "2021" }, "nbformat": 4, "nbformat_minor": 5