Skip to content

Instantly share code, notes, and snippets.

@avidale
Last active May 25, 2023 21:25
Show Gist options
  • Save avidale/a8f8e12b5ebef7bf0dbc2694ada0fa57 to your computer and use it in GitHub Desktop.
Save avidale/a8f8e12b5ebef7bf0dbc2694ada0fa57 to your computer and use it in GitHub Desktop.
convert conjuction to separate phrases
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "convert conjuction to separate phrases",
"provenance": [],
"collapsed_sections": [],
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/avidale/a8f8e12b5ebef7bf0dbc2694ada0fa57/convert-conjuction-to-separate-phrases.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"id": "tnfnoUNWZaE0",
"colab_type": "code",
"colab": {}
},
"source": [
"!python -m spacy download en_core_web_lg"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "9uW52IAPZVSM",
"colab_type": "code",
"colab": {}
},
"source": [
" #!python -m spacy download en_core_web_lg\n",
" import spacy\n",
" nlp = spacy.load('en_core_web_lg')"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "UWPl5-1QZo4s",
"colab_type": "code",
"colab": {}
},
"source": [
"text1 = 'I like cats and dogs.'\n",
"text2 = 'The steering system shall ensure easy and safe handling of the vehicle up to its maximum design speed or in case of a trailer up to its technically permitted maximum speed.'"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "g1OiO8VCqylp",
"colab_type": "code",
"outputId": "834098a0-340b-48ca-bcab-821b0cef3f6f",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 333
}
},
"source": [
"from spacy import displacy\n",
"displacy.render(nlp(text1), style=\"dep\", jupyter=True)"
],
"execution_count": 0,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/html": [
"<span class=\"tex2jax_ignore\"><svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xml:lang=\"en\" id=\"055dafa713ba4f3eae9ae6ca3426778e-0\" class=\"displacy\" width=\"925\" height=\"312.0\" direction=\"ltr\" style=\"max-width: none; height: 312.0px; color: #000000; background: #ffffff; font-family: Arial; direction: ltr\">\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"222.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"50\">I</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"50\">PRON</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"222.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"225\">like</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"225\">VERB</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"222.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"400\">cats</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"400\">NOUN</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"222.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"575\">and</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"575\">CCONJ</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"222.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"750\">dogs.</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"750\">NOUN</tspan>\n",
"</text>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-055dafa713ba4f3eae9ae6ca3426778e-0-0\" stroke-width=\"2px\" d=\"M70,177.0 C70,89.5 220.0,89.5 220.0,177.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-055dafa713ba4f3eae9ae6ca3426778e-0-0\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">nsubj</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M70,179.0 L62,167.0 78,167.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-055dafa713ba4f3eae9ae6ca3426778e-0-1\" stroke-width=\"2px\" d=\"M245,177.0 C245,89.5 395.0,89.5 395.0,177.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-055dafa713ba4f3eae9ae6ca3426778e-0-1\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">dobj</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M395.0,179.0 L403.0,167.0 387.0,167.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-055dafa713ba4f3eae9ae6ca3426778e-0-2\" stroke-width=\"2px\" d=\"M420,177.0 C420,89.5 570.0,89.5 570.0,177.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-055dafa713ba4f3eae9ae6ca3426778e-0-2\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">cc</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M570.0,179.0 L578.0,167.0 562.0,167.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-055dafa713ba4f3eae9ae6ca3426778e-0-3\" stroke-width=\"2px\" d=\"M420,177.0 C420,2.0 750.0,2.0 750.0,177.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-055dafa713ba4f3eae9ae6ca3426778e-0-3\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">conj</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M750.0,179.0 L758.0,167.0 742.0,167.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"</svg></span>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "lzDmQCLycAhF",
"colab_type": "code",
"outputId": "8a996127-62d6-4405-c4e9-1eeb426d472e",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
}
},
"source": [
"spacy.explain('cc'), spacy.explain('conj')"
],
"execution_count": 0,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"('coordinating conjunction', 'conjunct')"
]
},
"metadata": {
"tags": []
},
"execution_count": 130
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "QW9WmmYLavED",
"colab_type": "code",
"outputId": "aea62bfd-4857-4e53-bc8f-e01fc0bffcfa",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 423
}
},
"source": [
"from spacy import displacy\n",
"displacy.render(nlp(text2), style=\"dep\", jupyter=True, options={'compact':True, 'distance': 70})\n"
],
"execution_count": 0,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/html": [
"<span class=\"tex2jax_ignore\"><svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xml:lang=\"en\" id=\"40514d1a6f624407b8ccaa26817ec8d5-0\" class=\"displacy\" width=\"2220\" height=\"382.0\" direction=\"ltr\" style=\"max-width: none; height: 382.0px; color: #000000; background: #ffffff; font-family: Arial; direction: ltr\">\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"50\">The</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"50\">DET</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"120\">steering</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"120\">NOUN</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"190\">system</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"190\">NOUN</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"260\">shall</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"260\">VERB</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"330\">ensure</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"330\">VERB</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"400\">easy</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"400\">ADJ</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"470\">and</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"470\">CCONJ</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"540\">safe</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"540\">ADJ</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"610\">handling</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"610\">NOUN</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"680\">of</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"680\">ADP</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"750\">the</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"750\">DET</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"820\">vehicle</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"820\">NOUN</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"890\">up</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"890\">ADP</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"960\">to</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"960\">ADP</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1030\">its</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1030\">DET</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1100\">maximum</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1100\">ADJ</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1170\">design</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1170\">NOUN</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1240\">speed</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1240\">NOUN</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1310\">or</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1310\">CCONJ</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1380\">in</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1380\">ADP</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1450\">case</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1450\">NOUN</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1520\">of</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1520\">ADP</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1590\">a</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1590\">DET</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1660\">trailer</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1660\">NOUN</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1730\">up</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1730\">ADP</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1800\">to</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1800\">ADP</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1870\">its</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1870\">DET</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1940\">technically</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1940\">ADV</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"2010\">permitted</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"2010\">VERB</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"2080\">maximum</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"2080\">ADJ</tspan>\n",
"</text>\n",
"\n",
"<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"292.0\">\n",
" <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"2150\">speed.</tspan>\n",
" <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"2150\">NOUN</tspan>\n",
"</text>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-0\" stroke-width=\"2px\" d=\"M62,247.0 62,223.66666666666666 175.0,223.66666666666666 175.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-0\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">det</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M62,249.0 L58,241.0 66,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-1\" stroke-width=\"2px\" d=\"M132,247.0 132,235.33333333333334 172.0,235.33333333333334 172.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-1\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">compound</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M132,249.0 L128,241.0 136,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-2\" stroke-width=\"2px\" d=\"M202,247.0 202,223.66666666666666 315.0,223.66666666666666 315.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-2\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">nsubj</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M202,249.0 L198,241.0 206,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-3\" stroke-width=\"2px\" d=\"M272,247.0 272,235.33333333333334 312.0,235.33333333333334 312.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-3\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">aux</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M272,249.0 L268,241.0 276,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-4\" stroke-width=\"2px\" d=\"M412,247.0 412,212.0 598.0,212.0 598.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-4\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">amod</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M412,249.0 L408,241.0 416,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-5\" stroke-width=\"2px\" d=\"M412,247.0 412,235.33333333333334 452.0,235.33333333333334 452.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-5\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">cc</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M452.0,249.0 L456.0,241.0 448.0,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-6\" stroke-width=\"2px\" d=\"M412,247.0 412,223.66666666666666 525.0,223.66666666666666 525.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-6\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">conj</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M525.0,249.0 L529.0,241.0 521.0,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-7\" stroke-width=\"2px\" d=\"M342,247.0 342,200.33333333333334 601.0,200.33333333333334 601.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-7\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">dobj</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M601.0,249.0 L605.0,241.0 597.0,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-8\" stroke-width=\"2px\" d=\"M622,247.0 622,235.33333333333334 662.0,235.33333333333334 662.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-8\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">prep</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M662.0,249.0 L666.0,241.0 658.0,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-9\" stroke-width=\"2px\" d=\"M762,247.0 762,235.33333333333334 802.0,235.33333333333334 802.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-9\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">det</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M762,249.0 L758,241.0 766,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-10\" stroke-width=\"2px\" d=\"M692,247.0 692,223.66666666666666 805.0,223.66666666666666 805.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-10\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">pobj</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M805.0,249.0 L809.0,241.0 801.0,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-11\" stroke-width=\"2px\" d=\"M342,247.0 342,165.33333333333331 890.0,165.33333333333331 890.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-11\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">prep</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M890.0,249.0 L894.0,241.0 886.0,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-12\" stroke-width=\"2px\" d=\"M902,247.0 902,235.33333333333334 942.0,235.33333333333334 942.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-12\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">prep</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M942.0,249.0 L946.0,241.0 938.0,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-13\" stroke-width=\"2px\" d=\"M1042,247.0 1042,212.0 1228.0,212.0 1228.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-13\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">poss</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M1042,249.0 L1038,241.0 1046,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-14\" stroke-width=\"2px\" d=\"M1112,247.0 1112,223.66666666666666 1225.0,223.66666666666666 1225.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-14\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">amod</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M1112,249.0 L1108,241.0 1116,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-15\" stroke-width=\"2px\" d=\"M1182,247.0 1182,235.33333333333334 1222.0,235.33333333333334 1222.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-15\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">compound</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M1182,249.0 L1178,241.0 1186,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-16\" stroke-width=\"2px\" d=\"M972,247.0 972,200.33333333333334 1231.0,200.33333333333334 1231.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-16\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">pobj</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M1231.0,249.0 L1235.0,241.0 1227.0,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-17\" stroke-width=\"2px\" d=\"M972,247.0 972,188.66666666666666 1304.0,188.66666666666666 1304.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-17\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">cc</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M1304.0,249.0 L1308.0,241.0 1300.0,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-18\" stroke-width=\"2px\" d=\"M972,247.0 972,177.0 1377.0,177.0 1377.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-18\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">conj</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M1377.0,249.0 L1381.0,241.0 1373.0,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-19\" stroke-width=\"2px\" d=\"M1392,247.0 1392,235.33333333333334 1432.0,235.33333333333334 1432.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-19\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">pobj</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M1432.0,249.0 L1436.0,241.0 1428.0,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-20\" stroke-width=\"2px\" d=\"M1462,247.0 1462,235.33333333333334 1502.0,235.33333333333334 1502.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-20\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">prep</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M1502.0,249.0 L1506.0,241.0 1498.0,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-21\" stroke-width=\"2px\" d=\"M1602,247.0 1602,235.33333333333334 1642.0,235.33333333333334 1642.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-21\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">det</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M1602,249.0 L1598,241.0 1606,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-22\" stroke-width=\"2px\" d=\"M1532,247.0 1532,223.66666666666666 1645.0,223.66666666666666 1645.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-22\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">pobj</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M1645.0,249.0 L1649.0,241.0 1641.0,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-23\" stroke-width=\"2px\" d=\"M1672,247.0 1672,235.33333333333334 1712.0,235.33333333333334 1712.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-23\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">prt</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M1712.0,249.0 L1716.0,241.0 1708.0,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-24\" stroke-width=\"2px\" d=\"M1742,247.0 1742,235.33333333333334 1782.0,235.33333333333334 1782.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-24\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">prep</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M1782.0,249.0 L1786.0,241.0 1778.0,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-25\" stroke-width=\"2px\" d=\"M1882,247.0 1882,200.33333333333334 2141.0,200.33333333333334 2141.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-25\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">poss</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M1882,249.0 L1878,241.0 1886,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-26\" stroke-width=\"2px\" d=\"M1952,247.0 1952,235.33333333333334 1992.0,235.33333333333334 1992.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-26\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">advmod</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M1952,249.0 L1948,241.0 1956,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-27\" stroke-width=\"2px\" d=\"M2022,247.0 2022,223.66666666666666 2135.0,223.66666666666666 2135.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-27\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">amod</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M2022,249.0 L2018,241.0 2026,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-28\" stroke-width=\"2px\" d=\"M2092,247.0 2092,235.33333333333334 2132.0,235.33333333333334 2132.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-28\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">amod</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M2092,249.0 L2088,241.0 2096,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"\n",
"<g class=\"displacy-arrow\">\n",
" <path class=\"displacy-arc\" id=\"arrow-40514d1a6f624407b8ccaa26817ec8d5-0-29\" stroke-width=\"2px\" d=\"M1812,247.0 1812,188.66666666666666 2144.0,188.66666666666666 2144.0,247.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
" <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
" <textPath xlink:href=\"#arrow-40514d1a6f624407b8ccaa26817ec8d5-0-29\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">pobj</textPath>\n",
" </text>\n",
" <path class=\"displacy-arrowhead\" d=\"M2144.0,249.0 L2148.0,241.0 2140.0,241.0\" fill=\"currentColor\"/>\n",
"</g>\n",
"</svg></span>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "j_DnlT3pdrrE",
"colab_type": "code",
"colab": {}
},
"source": [
" import itertools\n",
"\n",
" def generate_trees(root):\n",
" \"\"\"\n",
" Yield all conjuncted variants of subtrees that can be generated from the given node.\n",
" A subtree here is just a set of nodes.\n",
" \"\"\"\n",
" prev_result = [root]\n",
" if not root.children:\n",
" yield prev_result\n",
" return\n",
" \n",
" children_deps = {c.dep_ for c in root.children}\n",
" if 'conj' in children_deps:\n",
" # generate two options: subtree without cc+conj, or with conj child replacing the root\n",
" # the first option:\n",
" good_children = [c for c in root.children if c.dep_ not in {'cc', 'conj'}]\n",
" for subtree in combine_children(prev_result, good_children):\n",
" yield subtree \n",
" # the second option\n",
" for child in root.children:\n",
" if child.dep_ == 'conj':\n",
" for subtree in generate_trees(child):\n",
" yield subtree\n",
" else:\n",
" # otherwise, just combine all the children subtrees\n",
" for subtree in combine_children([root], root.children):\n",
" yield subtree\n",
"\n",
" def combine_children(prev_result, children):\n",
" \"\"\" Combine the parent subtree with all variants of the children subtrees \"\"\"\n",
" child_lists = []\n",
" for child in children:\n",
" cl = list(generate_trees(child))\n",
" child_lists.append(cl)\n",
" for prod in itertools.product(*child_lists): # all possible combinations\n",
" yield prev_result + [tok for parts in prod for tok in parts]"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "3A9DoNa8elJ1",
"colab_type": "code",
"outputId": "18e842dc-327f-4597-85b9-e0a7335e4df3",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 51
}
},
"source": [
" text = 'I like cats and dogs.'\n",
" doc = nlp(text)\n",
" sentence = list(doc.sents)[0]\n",
" for tree in generate_trees(sentence.root):\n",
" print(' '.join([token.text for token in sorted(tree, key=lambda x: x.i)]))\n",
" # I like cats .\n",
" # I like dogs ."
],
"execution_count": 0,
"outputs": [
{
"output_type": "stream",
"text": [
"I like cats .\n",
"I like dogs .\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "2jlXMKKImbGd",
"colab_type": "code",
"outputId": "86a07aab-b279-43b9-bb99-e5a15d3cc99a",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 85
}
},
"source": [
" text = 'The steering system shall ensure easy and safe handling of the vehicle up to its maximum design speed or in case of a trailer up to its technically permitted maximum speed.'\n",
" doc = nlp(text)\n",
" sentence = list(doc.sents)[0]\n",
" for tree in generate_trees(sentence.root):\n",
" print(' '.join([token.text for token in sorted(tree, key=lambda x: x.i)]))\n",
" # The steering system shall ensure easy handling of the vehicle up to its maximum design speed .\n",
" # The steering system shall ensure easy handling of the vehicle up in case of a trailer up to its technically permitted maximum speed .\n",
" # The steering system shall ensure safe handling of the vehicle up to its maximum design speed .\n",
" # The steering system shall ensure safe handling of the vehicle up in case of a trailer up to its technically permitted maximum speed ."
],
"execution_count": 0,
"outputs": [
{
"output_type": "stream",
"text": [
"The steering system shall ensure easy handling of the vehicle up to its maximum design speed .\n",
"The steering system shall ensure easy handling of the vehicle up in case of a trailer up to its technically permitted maximum speed .\n",
"The steering system shall ensure safe handling of the vehicle up to its maximum design speed .\n",
"The steering system shall ensure safe handling of the vehicle up in case of a trailer up to its technically permitted maximum speed .\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "-JkOBnDdksDt",
"colab_type": "code",
"colab": {}
},
"source": [
""
],
"execution_count": 0,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment