diff --git a/doc/References.bib b/doc/References.bib index a90b4d1..09d9930 100644 --- a/doc/References.bib +++ b/doc/References.bib @@ -121,3 +121,9 @@ +@unpublished{spacy2, + AUTHOR = {Honnibal, Matthew and Montani, Ines}, + TITLE = {{spaCy 2}: Natural language understanding with {B}loom embeddings, convolutional neural networks and incremental parsing}, + YEAR = {2017}, + Note = {spaCy excels at large-scale information extraction tasks.} +} \ No newline at end of file diff --git a/doc/chapters/chapter1.tex b/doc/chapters/chapter1.tex index ee08d29..34f3a60 100644 --- a/doc/chapters/chapter1.tex +++ b/doc/chapters/chapter1.tex @@ -25,12 +25,13 @@ In linguistics and \acs{nlp}, corpus refers to a collection of texts. This paper Wikipedia\footnote{https://www.wikipedia.org/} is primarily an encyclopedia with the additional benefit of heavy linking between articles and without the size constraints of paper articles \cite{TorstenZesch}. Wikipedia API \footnote{https://pypi.org/project/Wikipedia-API/} +\section{spaCy - Dependency Parsing} +spaCy\cite{spacy2} features neural models for parsing and entity recognition. These models can be trained for \acf{ner} , tagging and parsing. Its official page on usage\footnote {https://v2.spacy.io/usage/} provides in-depth code example for information extraction. - -\begin{figure}[h!] - \centering - \includesvg{pronoun.svg} +\begin{figure}[htp!] + \centering + \includesvg[scale=0.16]{dependency-parser.svg} \caption{kuch kar bhai} \label{fig:propn} \end{figure} diff --git a/doc/images/dependency-parser.svg b/doc/images/dependency-parser.svg new file mode 100644 index 0000000..a7c35f7 --- /dev/null +++ b/doc/images/dependency-parser.svg @@ -0,0 +1,266 @@ + + + Motor + NOUN + + + + oil, + NOUN + + + + engine + NOUN + + + + oil, + NOUN + + + + or + CCONJ + + + + engine + NOUN + + + + lubricant + NOUN + + + + is + AUX + + + + any + DET + + + + one + NUM + + + + of + ADP + + + + various + ADJ + + + + substances + NOUN + + + + used + VERB + + + + for + ADP + + + + the + DET + + + + lubrication + NOUN + + + + of + ADP + + + + internal + ADJ + + + + combustion + NOUN + + + + engines + NOUN + + + + + + compound + + + + + + + + nsubj + + + + + + + + compound + + + + + + + + conj + + + + + + + + cc + + + + + + + + compound + + + + + + + + conj + + + + + + + + det + + + + + + + + attr + + + + + + + + prep + + + + + + + + amod + + + + + + + + pobj + + + + + + + + acl + + + + + + + + prep + + + + + + + + det + + + + + + + + pobj + + + + + + + + prep + + + + + + + + amod + + + + + + + + compound + + + + + + + + pobj + + + + \ No newline at end of file diff --git a/doc/preliminary/acronyms.tex b/doc/preliminary/acronyms.tex index 14a50fb..0d2036c 100644 --- a/doc/preliminary/acronyms.tex +++ b/doc/preliminary/acronyms.tex @@ -13,5 +13,7 @@ \acro{qg}[QG]{Question generation} +\acro{ner}[NER]{Named Entity Recognition} + \end{acronym} diff --git a/knowledgegraph/spacy.ipynb b/knowledgegraph/spacy.ipynb index e0ad010..9cec659 100644 --- a/knowledgegraph/spacy.ipynb +++ b/knowledgegraph/spacy.ipynb @@ -1,53 +1,5 @@ { "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Requirement already satisfied: spacy in /home/shoney/dev/.venv/lib/python3.9/site-packages (3.5.3)\n", - "Requirement already satisfied: typer<0.8.0,>=0.3.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (0.7.0)\n", - "Requirement already satisfied: jinja2 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (3.1.2)\n", - "Requirement already satisfied: setuptools in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (57.4.0)\n", - "Requirement already satisfied: numpy>=1.15.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (1.24.3)\n", - "Requirement already satisfied: spacy-legacy<3.1.0,>=3.0.11 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (3.0.12)\n", - "Requirement already satisfied: packaging>=20.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (23.1)\n", - "Requirement already satisfied: requests<3.0.0,>=2.13.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (2.31.0)\n", - "Requirement already satisfied: pydantic!=1.8,!=1.8.1,<1.11.0,>=1.7.4 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (1.10.8)\n", - "Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (4.65.0)\n", - "Requirement already satisfied: thinc<8.2.0,>=8.1.8 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (8.1.10)\n", - "Requirement already satisfied: spacy-loggers<2.0.0,>=1.0.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (1.0.4)\n", - "Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (1.0.9)\n", - "Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (3.0.8)\n", - "Requirement already satisfied: catalogue<2.1.0,>=2.0.6 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (2.0.8)\n", - "Requirement already satisfied: langcodes<4.0.0,>=3.2.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (3.3.0)\n", - "Requirement already satisfied: pathy>=0.10.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (0.10.1)\n", - "Requirement already satisfied: wasabi<1.2.0,>=0.9.1 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (1.1.1)\n", - "Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (2.0.7)\n", - "Requirement already satisfied: smart-open<7.0.0,>=5.2.1 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (6.3.0)\n", - "Requirement already satisfied: srsly<3.0.0,>=2.4.3 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy) (2.4.6)\n", - "Requirement already satisfied: typing-extensions>=4.2.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from pydantic!=1.8,!=1.8.1,<1.11.0,>=1.7.4->spacy) (4.6.1)\n", - "Requirement already satisfied: idna<4,>=2.5 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from requests<3.0.0,>=2.13.0->spacy) (3.4)\n", - "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from requests<3.0.0,>=2.13.0->spacy) (2.0.2)\n", - "Requirement already satisfied: charset-normalizer<4,>=2 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from requests<3.0.0,>=2.13.0->spacy) (3.1.0)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from requests<3.0.0,>=2.13.0->spacy) (2023.5.7)\n", - "Requirement already satisfied: blis<0.8.0,>=0.7.8 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from thinc<8.2.0,>=8.1.8->spacy) (0.7.9)\n", - "Requirement already satisfied: confection<1.0.0,>=0.0.1 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from thinc<8.2.0,>=8.1.8->spacy) (0.0.4)\n", - "Requirement already satisfied: click<9.0.0,>=7.1.1 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from typer<0.8.0,>=0.3.0->spacy) (8.1.3)\n", - "Requirement already satisfied: MarkupSafe>=2.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from jinja2->spacy) (2.1.2)\n", - "\u001b[33mWARNING: You are using pip version 21.2.3; however, version 23.1.2 is available.\n", - "You should consider upgrading via the '/home/shoney/dev/.venv/bin/python -m pip install --upgrade pip' command.\u001b[0m\n" - ] - } - ], - "source": [ - "!python -m pip install spacy" - ] - }, { "cell_type": "code", "execution_count": 2, @@ -57,53 +9,138 @@ "name": "stdout", "output_type": "stream", "text": [ + "Defaulting to user installation because normal site-packages is not writeable\n", + "Collecting spacy\n", + " Downloading spacy-3.5.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.6 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m6.6/6.6 MB\u001b[0m \u001b[31m5.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", + "\u001b[?25hCollecting pathy>=0.10.0\n", + " Downloading pathy-0.10.1-py3-none-any.whl (48 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m48.9/48.9 KB\u001b[0m \u001b[31m5.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hCollecting preshed<3.1.0,>=3.0.2\n", + " Downloading preshed-3.0.8-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (124 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m124.7/124.7 KB\u001b[0m \u001b[31m5.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hCollecting cymem<2.1.0,>=2.0.2\n", + " Downloading cymem-2.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (34 kB)\n", + "Collecting tqdm<5.0.0,>=4.38.0\n", + " Downloading tqdm-4.65.0-py3-none-any.whl (77 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m77.1/77.1 KB\u001b[0m \u001b[31m7.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hCollecting spacy-loggers<2.0.0,>=1.0.0\n", + " Downloading spacy_loggers-1.0.4-py3-none-any.whl (11 kB)\n", + "Requirement already satisfied: jinja2 in /home/shoney/.local/lib/python3.10/site-packages (from spacy) (3.1.2)\n", + "Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from spacy) (59.6.0)\n", + "Collecting catalogue<2.1.0,>=2.0.6\n", + " Downloading catalogue-2.0.8-py3-none-any.whl (17 kB)\n", + "Requirement already satisfied: numpy>=1.15.0 in /home/shoney/.local/lib/python3.10/site-packages (from spacy) (1.24.3)\n", + "Collecting murmurhash<1.1.0,>=0.28.0\n", + " Downloading murmurhash-1.0.9-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21 kB)\n", + "Collecting spacy-legacy<3.1.0,>=3.0.11\n", + " Downloading spacy_legacy-3.0.12-py2.py3-none-any.whl (29 kB)\n", + "Collecting requests<3.0.0,>=2.13.0\n", + " Downloading requests-2.31.0-py3-none-any.whl (62 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m62.6/62.6 KB\u001b[0m \u001b[31m12.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hCollecting typer<0.8.0,>=0.3.0\n", + " Downloading typer-0.7.0-py3-none-any.whl (38 kB)\n", + "Requirement already satisfied: packaging>=20.0 in /home/shoney/.local/lib/python3.10/site-packages (from spacy) (23.1)\n", + "Collecting langcodes<4.0.0,>=3.2.0\n", + " Downloading langcodes-3.3.0-py3-none-any.whl (181 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m181.6/181.6 KB\u001b[0m \u001b[31m7.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", + "\u001b[?25hCollecting srsly<3.0.0,>=2.4.3\n", + " Downloading srsly-2.4.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (492 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m492.2/492.2 KB\u001b[0m \u001b[31m6.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", + "\u001b[?25hCollecting smart-open<7.0.0,>=5.2.1\n", + " Downloading smart_open-6.3.0-py3-none-any.whl (56 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m56.8/56.8 KB\u001b[0m \u001b[31m8.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hCollecting thinc<8.2.0,>=8.1.8\n", + " Downloading thinc-8.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (913 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m913.3/913.3 KB\u001b[0m \u001b[31m6.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", + "\u001b[?25hCollecting wasabi<1.2.0,>=0.9.1\n", + " Downloading wasabi-1.1.2-py3-none-any.whl (27 kB)\n", + "Collecting pydantic!=1.8,!=1.8.1,<1.11.0,>=1.7.4\n", + " Downloading pydantic-1.10.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.1/3.1 MB\u001b[0m \u001b[31m4.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", + "\u001b[?25hCollecting typing-extensions>=4.2.0\n", + " Downloading typing_extensions-4.6.3-py3-none-any.whl (31 kB)\n", + "Requirement already satisfied: idna<4,>=2.5 in /home/shoney/.local/lib/python3.10/site-packages (from requests<3.0.0,>=2.13.0->spacy) (3.4)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/shoney/.local/lib/python3.10/site-packages (from requests<3.0.0,>=2.13.0->spacy) (1.26.16)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /home/shoney/.local/lib/python3.10/site-packages (from requests<3.0.0,>=2.13.0->spacy) (2023.5.7)\n", + "Collecting charset-normalizer<4,>=2\n", + " Downloading charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (199 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m199.3/199.3 KB\u001b[0m \u001b[31m5.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", + "\u001b[?25hCollecting confection<1.0.0,>=0.0.1\n", + " Downloading confection-0.0.4-py3-none-any.whl (32 kB)\n", + "Collecting blis<0.8.0,>=0.7.8\n", + " Downloading blis-0.7.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.2 MB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m10.2/10.2 MB\u001b[0m \u001b[31m5.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m0:01\u001b[0m\n", + "\u001b[?25hCollecting click<9.0.0,>=7.1.1\n", + " Downloading click-8.1.3-py3-none-any.whl (96 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m96.6/96.6 KB\u001b[0m \u001b[31m4.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hRequirement already satisfied: MarkupSafe>=2.0 in /home/shoney/.local/lib/python3.10/site-packages (from jinja2->spacy) (2.1.3)\n", + "Installing collected packages: cymem, wasabi, typing-extensions, tqdm, spacy-loggers, spacy-legacy, smart-open, murmurhash, langcodes, click, charset-normalizer, catalogue, blis, typer, srsly, requests, pydantic, preshed, pathy, confection, thinc, spacy\n", + "Successfully installed blis-0.7.9 catalogue-2.0.8 charset-normalizer-3.1.0 click-8.1.3 confection-0.0.4 cymem-2.0.7 langcodes-3.3.0 murmurhash-1.0.9 pathy-0.10.1 preshed-3.0.8 pydantic-1.10.9 requests-2.31.0 smart-open-6.3.0 spacy-3.5.3 spacy-legacy-3.0.12 spacy-loggers-1.0.4 srsly-2.4.6 thinc-8.1.10 tqdm-4.65.0 typer-0.7.0 typing-extensions-4.6.3 wasabi-1.1.2\n" + ] + } + ], + "source": [ + "!python3 -m pip install spacy" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Defaulting to user installation because normal site-packages is not writeable\n", "Collecting en-core-web-sm==3.5.0\n", " Downloading https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0-py3-none-any.whl (12.8 MB)\n", - "\u001b[K |████████████████████████████████| 12.8 MB 625 kB/s eta 0:00:01\n", - "\u001b[?25hRequirement already satisfied: spacy<3.6.0,>=3.5.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from en-core-web-sm==3.5.0) (3.5.3)\n", - "Requirement already satisfied: numpy>=1.15.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (1.24.3)\n", - "Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (3.0.8)\n", - "Requirement already satisfied: packaging>=20.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (23.1)\n", - "Requirement already satisfied: pathy>=0.10.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (0.10.1)\n", - "Requirement already satisfied: smart-open<7.0.0,>=5.2.1 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (6.3.0)\n", - "Requirement already satisfied: spacy-loggers<2.0.0,>=1.0.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (1.0.4)\n", - "Requirement already satisfied: spacy-legacy<3.1.0,>=3.0.11 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (3.0.12)\n", - "Requirement already satisfied: typer<0.8.0,>=0.3.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (0.7.0)\n", - "Requirement already satisfied: srsly<3.0.0,>=2.4.3 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (2.4.6)\n", - "Requirement already satisfied: langcodes<4.0.0,>=3.2.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (3.3.0)\n", - "Requirement already satisfied: requests<3.0.0,>=2.13.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (2.31.0)\n", - "Requirement already satisfied: catalogue<2.1.0,>=2.0.6 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (2.0.8)\n", - "Requirement already satisfied: setuptools in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (57.4.0)\n", - "Requirement already satisfied: pydantic!=1.8,!=1.8.1,<1.11.0,>=1.7.4 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (1.10.8)\n", - "Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (1.0.9)\n", - "Requirement already satisfied: jinja2 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (3.1.2)\n", - "Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (2.0.7)\n", - "Requirement already satisfied: thinc<8.2.0,>=8.1.8 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (8.1.10)\n", - "Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (4.65.0)\n", - "Requirement already satisfied: wasabi<1.2.0,>=0.9.1 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (1.1.1)\n", - "Requirement already satisfied: typing-extensions>=4.2.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from pydantic!=1.8,!=1.8.1,<1.11.0,>=1.7.4->spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (4.6.1)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from requests<3.0.0,>=2.13.0->spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (2023.5.7)\n", - "Requirement already satisfied: charset-normalizer<4,>=2 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from requests<3.0.0,>=2.13.0->spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (3.1.0)\n", - "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from requests<3.0.0,>=2.13.0->spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (2.0.2)\n", - "Requirement already satisfied: idna<4,>=2.5 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from requests<3.0.0,>=2.13.0->spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (3.4)\n", - "Requirement already satisfied: blis<0.8.0,>=0.7.8 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from thinc<8.2.0,>=8.1.8->spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (0.7.9)\n", - "Requirement already satisfied: confection<1.0.0,>=0.0.1 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from thinc<8.2.0,>=8.1.8->spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (0.0.4)\n", - "Requirement already satisfied: click<9.0.0,>=7.1.1 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from typer<0.8.0,>=0.3.0->spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (8.1.3)\n", - "Requirement already satisfied: MarkupSafe>=2.0 in /home/shoney/dev/.venv/lib/python3.9/site-packages (from jinja2->spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (2.1.2)\n", - "\u001b[33mWARNING: You are using pip version 21.2.3; however, version 23.1.2 is available.\n", - "You should consider upgrading via the '/home/shoney/dev/.venv/bin/python -m pip install --upgrade pip' command.\u001b[0m\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m12.8/12.8 MB\u001b[0m \u001b[31m4.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", + "\u001b[?25hRequirement already satisfied: spacy<3.6.0,>=3.5.0 in /home/shoney/.local/lib/python3.10/site-packages (from en-core-web-sm==3.5.0) (3.5.3)\n", + "Requirement already satisfied: pathy>=0.10.0 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (0.10.1)\n", + "Requirement already satisfied: catalogue<2.1.0,>=2.0.6 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (2.0.8)\n", + "Requirement already satisfied: thinc<8.2.0,>=8.1.8 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (8.1.10)\n", + "Requirement already satisfied: wasabi<1.2.0,>=0.9.1 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (1.1.2)\n", + "Requirement already satisfied: langcodes<4.0.0,>=3.2.0 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (3.3.0)\n", + "Requirement already satisfied: packaging>=20.0 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (23.1)\n", + "Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (3.0.8)\n", + "Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (4.65.0)\n", + "Requirement already satisfied: jinja2 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (3.1.2)\n", + "Requirement already satisfied: pydantic!=1.8,!=1.8.1,<1.11.0,>=1.7.4 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (1.10.9)\n", + "Requirement already satisfied: numpy>=1.15.0 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (1.24.3)\n", + "Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (59.6.0)\n", + "Requirement already satisfied: spacy-loggers<2.0.0,>=1.0.0 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (1.0.4)\n", + "Requirement already satisfied: spacy-legacy<3.1.0,>=3.0.11 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (3.0.12)\n", + "Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (2.0.7)\n", + "Requirement already satisfied: smart-open<7.0.0,>=5.2.1 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (6.3.0)\n", + "Requirement already satisfied: requests<3.0.0,>=2.13.0 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (2.31.0)\n", + "Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (1.0.9)\n", + "Requirement already satisfied: srsly<3.0.0,>=2.4.3 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (2.4.6)\n", + "Requirement already satisfied: typer<0.8.0,>=0.3.0 in /home/shoney/.local/lib/python3.10/site-packages (from spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (0.7.0)\n", + "Requirement already satisfied: typing-extensions>=4.2.0 in /home/shoney/.local/lib/python3.10/site-packages (from pydantic!=1.8,!=1.8.1,<1.11.0,>=1.7.4->spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (4.6.3)\n", + "Requirement already satisfied: idna<4,>=2.5 in /home/shoney/.local/lib/python3.10/site-packages (from requests<3.0.0,>=2.13.0->spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (3.4)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /home/shoney/.local/lib/python3.10/site-packages (from requests<3.0.0,>=2.13.0->spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (2023.5.7)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /home/shoney/.local/lib/python3.10/site-packages (from requests<3.0.0,>=2.13.0->spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (3.1.0)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/shoney/.local/lib/python3.10/site-packages (from requests<3.0.0,>=2.13.0->spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (1.26.16)\n", + "Requirement already satisfied: blis<0.8.0,>=0.7.8 in /home/shoney/.local/lib/python3.10/site-packages (from thinc<8.2.0,>=8.1.8->spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (0.7.9)\n", + "Requirement already satisfied: confection<1.0.0,>=0.0.1 in /home/shoney/.local/lib/python3.10/site-packages (from thinc<8.2.0,>=8.1.8->spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (0.0.4)\n", + "Requirement already satisfied: click<9.0.0,>=7.1.1 in /home/shoney/.local/lib/python3.10/site-packages (from typer<0.8.0,>=0.3.0->spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (8.1.3)\n", + "Requirement already satisfied: MarkupSafe>=2.0 in /home/shoney/.local/lib/python3.10/site-packages (from jinja2->spacy<3.6.0,>=3.5.0->en-core-web-sm==3.5.0) (2.1.3)\n", + "Installing collected packages: en-core-web-sm\n", + "Successfully installed en-core-web-sm-3.5.0\n", "\u001b[38;5;2m✔ Download and installation successful\u001b[0m\n", "You can now load the package via spacy.load('en_core_web_sm')\n" ] } ], "source": [ - "!python -m spacy download en_core_web_sm" + "!python3 -m spacy download en_core_web_sm" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -118,11 +155,27 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "17268" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "text = (\"Motor oil, engine oil, or engine lubricant is any one of various substances used for the lubrication of internal combustion engines\")" + "text = (\"Motor oil, engine oil, or engine lubricant is any one of various substances used for the lubrication of internal combustion engines\")\n", + "doc = nlp(text)\n", + "svg = displacy.render(doc, style=\"dep\",jupyter=False)\n", + "\n", + "output_path = Path(\"../doc/images/dependency-parser.svg\") # you can keep there only \"dependency_plot.svg\" if you want to save it in the same folder where you run the script \n", + "output_path.open(\"w\", encoding=\"utf-8\").write(svg)" ] }, { @@ -733,7 +786,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.7" + "version": "3.10.6" } }, "nbformat": 4,