{ "cells": [ { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "import spacy\n", "from spacy import displacy" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "nlp = spacy.load(\"../training/trf/model-best\")" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "text = \"\"\"\n", "We went to my neighbor's house and we looked inside the barn to hide. We also waited in the kitchen. We found a cellar and later left on a motorbike.\n", "\"\"\"" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "doc = nlp(text)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " We went to my \n", "\n", " neighbor\n", " \n", "\n", "\n", "\n", " \n", "\n", " \n", " BUILDING\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", " 's\n", " \n", "\n", "\n", "\n", " \n", "\n", "\n", "\n", " house\n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", " \n", "\n", " \n", " BUILDING\n", " \n", "\n", "\n", "\n", "\n", "and we looked inside the \n", "\n", " barn\n", " \n", "\n", "\n", "\n", " \n", "\n", " \n", " BUILDING\n", " \n", "\n", "\n", "\n", "\n", "to hide . We also waited in the \n", "\n", " kitchen\n", " \n", "\n", "\n", "\n", " \n", "\n", " \n", " INT_SPACE\n", " \n", "\n", "\n", "\n", "\n", ". We found a \n", "\n", " cellar\n", " \n", "\n", "\n", "\n", " \n", "\n", " \n", " INT_SPACE\n", " \n", "\n", "\n", "\n", "\n", "and later left on a \n", "\n", " motorbike\n", " \n", "\n", "\n", "\n", " \n", "\n", " \n", " SPATIAL_OBJ\n", " \n", "\n", "\n", "\n", "\n", ". \n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "displacy.render(doc, style=\"span\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "holocaust", "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.13" } }, "nbformat": 4, "nbformat_minor": 2 }