Notebooks >> Scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

126 lines
7.0 KiB

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "4b1a1586-0823-4046-ab19-0fa99a0f241b",
"metadata": {
"scrolled": true,
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Defaulting to user installation because normal site-packages is not writeable\n",
"Collecting spacy\n",
" Downloading spacy-3.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.4 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m6.4/6.4 MB\u001b[0m \u001b[31m15.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
"\u001b[?25hCollecting thinc<8.2.0,>=8.1.0\n",
" Downloading thinc-8.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (822 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m822.5/822.5 KB\u001b[0m \u001b[31m10.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m\n",
"\u001b[?25hCollecting cymem<2.1.0,>=2.0.2\n",
" Using cached cymem-2.0.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (35 kB)\n",
"Requirement already satisfied: requests<3.0.0,>=2.13.0 in /usr/lib/python3/dist-packages (from spacy) (2.25.1)\n",
"Collecting wasabi<1.1.0,>=0.9.1\n",
" Downloading wasabi-0.10.1-py3-none-any.whl (26 kB)\n",
"Requirement already satisfied: packaging>=20.0 in /home/donaldrich/.local/lib/python3.10/site-packages (from spacy) (21.3)\n",
"Collecting spacy-legacy<3.1.0,>=3.0.9\n",
" Using cached spacy_legacy-3.0.9-py2.py3-none-any.whl (20 kB)\n",
"Requirement already satisfied: jinja2 in /usr/lib/python3/dist-packages (from spacy) (3.0.3)\n",
"Collecting langcodes<4.0.0,>=3.2.0\n",
" Using cached langcodes-3.3.0-py3-none-any.whl (181 kB)\n",
"Collecting pathy>=0.3.5\n",
" Downloading pathy-0.6.2-py3-none-any.whl (42 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m42.8/42.8 KB\u001b[0m \u001b[31m1.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hCollecting murmurhash<1.1.0,>=0.28.0\n",
" Using cached murmurhash-1.0.7-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21 kB)\n",
"Collecting tqdm<5.0.0,>=4.38.0\n",
" Downloading tqdm-4.64.0-py2.py3-none-any.whl (78 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m78.4/78.4 KB\u001b[0m \u001b[31m2.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hCollecting preshed<3.1.0,>=3.0.2\n",
" Using cached preshed-3.0.6-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (128 kB)\n",
"Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from spacy) (59.6.0)\n",
"Collecting spacy-loggers<2.0.0,>=1.0.0\n",
" Downloading spacy_loggers-1.0.3-py3-none-any.whl (9.3 kB)\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: typer<0.5.0,>=0.3.0 in /home/donaldrich/.local/lib/python3.10/site-packages (from spacy) (0.4.2)\n",
"Requirement already satisfied: numpy>=1.15.0 in /usr/lib/python3/dist-packages (from spacy) (1.21.5)\n",
"Collecting srsly<3.0.0,>=2.4.3\n",
" Downloading srsly-2.4.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (460 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m460.0/460.0 KB\u001b[0m \u001b[31m10.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m\n",
"\u001b[?25hRequirement already satisfied: pydantic!=1.8,!=1.8.1,<1.10.0,>=1.7.4 in /home/donaldrich/.local/lib/python3.10/site-packages (from spacy) (1.9.1)\n",
"Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/lib/python3/dist-packages (from packaging>=20.0->spacy) (2.4.7)\n",
"Collecting smart-open<6.0.0,>=5.2.1\n",
" Using cached smart_open-5.2.1-py3-none-any.whl (58 kB)\n",
"Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/donaldrich/.local/lib/python3.10/site-packages (from pydantic!=1.8,!=1.8.1,<1.10.0,>=1.7.4->spacy) (4.3.0)\n",
"Collecting blis<0.8.0,>=0.7.8\n",
" Downloading blis-0.7.8-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[31m19.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m0:01\u001b[0m\n",
"\u001b[?25hRequirement already satisfied: click<9.0.0,>=7.1.1 in /usr/lib/python3/dist-packages (from typer<0.5.0,>=0.3.0->spacy) (8.0.3)\n",
"Installing collected packages: wasabi, murmurhash, cymem, tqdm, spacy-loggers, spacy-legacy, smart-open, preshed, langcodes, catalogue, blis, srsly, pathy, thinc, spacy\n",
"Successfully installed blis-0.7.8 catalogue-2.0.8 cymem-2.0.6 langcodes-3.3.0 murmurhash-1.0.7 pathy-0.6.2 preshed-3.0.6 smart-open-5.2.1 spacy-3.4.1 spacy-legacy-3.0.9 spacy-loggers-1.0.3 srsly-2.4.4 thinc-8.1.0 tqdm-4.64.0 wasabi-0.10.1\n",
"zsh:1: command not found: python\n"
]
}
],
"source": [
"!pip install -U spacy\n",
"!python -m spacy download en_core_web_sm"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b0d80ae8-94a9-45b6-af8b-790dbb12e469",
"metadata": {},
"outputs": [],
"source": [
"import spacy\n",
"from spacy import displacy\n",
"\n",
"text = \"When Sebastian Thrun started working on self-driving cars at Google in 2007, few people outside of the company took him seriously.\"\n",
"\n",
"nlp = spacy.load(\"en_core_web_sm\")\n",
"doc = nlp(text)\n",
"displacy.serve(doc, style=\"ent\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b2b9b88c-343b-4839-b56a-48423773a03b",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.4 64-bit",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
},
"vscode": {
"interpreter": {
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}