From 63aca3de2c1c3bcabc6a93884549b5a541b05b36 Mon Sep 17 00:00:00 2001 From: shoneyj Date: Thu, 8 Jun 2023 01:27:18 +0200 Subject: [PATCH] doc --- doc/References.bib | 10 +++++++ doc/chapters/chapter1.tex | 17 +++++++++-- doc/images/verbpart.svg | 58 ++++++++++++++++++++++++++++++++++++ doc/preliminary/acronyms.tex | 7 ++++- knowledgegraph/graph.ipynb | 0 knowledgegraph/spacy.ipynb | 33 +++++++++++--------- 6 files changed, 108 insertions(+), 17 deletions(-) create mode 100644 doc/images/verbpart.svg create mode 100644 knowledgegraph/graph.ipynb diff --git a/doc/References.bib b/doc/References.bib index 09d9930..07f2c10 100644 --- a/doc/References.bib +++ b/doc/References.bib @@ -126,4 +126,14 @@ 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.} +} + +@InProceedings{SciPyProceedings_11, + author = {Aric A. Hagberg and Daniel A. Schult and Pieter J. Swart}, + title = {Exploring Network Structure, Dynamics, and Function using NetworkX}, + booktitle = {Proceedings of the 7th Python in Science Conference}, + pages = {11 - 15}, + address = {Pasadena, CA USA}, + year = {2008}, + editor = {Ga\"el Varoquaux and Travis Vaught and Jarrod Millman}, } \ No newline at end of file diff --git a/doc/chapters/chapter1.tex b/doc/chapters/chapter1.tex index 34f3a60..2a22cc7 100644 --- a/doc/chapters/chapter1.tex +++ b/doc/chapters/chapter1.tex @@ -29,11 +29,24 @@ Wikipedia\footnote{https://www.wikipedia.org/} is primarily an encyclopedia with 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. +In figure \ref{fig:dp}, we see a complex sentence's dependency parsing. It has a \acf{nsubj} , connecting \acfp{pobj} with \acfp{adp} and no \acf{dobj}. + \begin{figure}[htp!] \centering \includesvg[scale=0.16]{dependency-parser.svg} - \caption{kuch kar bhai} - \label{fig:propn} + \caption{Navigating the parse tree and subtrees} + \label{fig:dp} \end{figure} +The \acs{nsubj} "oil", itself do not give a complete meaning. However, upon combining its dependency noun "Motor", which is "Motor oil" gives us an understanding of the topic. Traversing from \acs{nsubj} to \acfp{conj} provides us with three related compound nouns belonging to a similar group. +"Motor oil", "Engine Oil", "Engine Lubricant" + +Traversing further right of the dependency tree we can extract the \acsp{pobj}. An \acf{amod} "internal" is connecting compound noun "combustion engine". + +\begin{figure}[htp!] + \centering + \includesvg[scale=0.7]{verbpart.svg} + \caption{Negetive Part} + \label{fig:vp} +\end{figure} diff --git a/doc/images/verbpart.svg b/doc/images/verbpart.svg new file mode 100644 index 0000000..4a72a7c --- /dev/null +++ b/doc/images/verbpart.svg @@ -0,0 +1,58 @@ + + + Ford + PROPN + + + + does + AUX + + + + not + PART + + + + recomend + VERB + + + + Fx01 + PROPN + + + + + + nsubj + + + + + + + + aux + + + + + + + + neg + + + + + + + + dobj + + + + \ No newline at end of file diff --git a/doc/preliminary/acronyms.tex b/doc/preliminary/acronyms.tex index 0d2036c..17360fe 100644 --- a/doc/preliminary/acronyms.tex +++ b/doc/preliminary/acronyms.tex @@ -14,6 +14,11 @@ \acro{qg}[QG]{Question generation} \acro{ner}[NER]{Named Entity Recognition} - +\acro{adp}[ADP]{adposition} +\acro{pobj}[pobj]{prepositional object} +\acro{dobj}[dobj]{direct object} +\acro{nsubj}[nsubj]{nominal subject} +\acro{conj}[conj]{coordinating conjunction} +\acro{amod}[amod]{adjectival modifier} \end{acronym} diff --git a/knowledgegraph/graph.ipynb b/knowledgegraph/graph.ipynb new file mode 100644 index 0000000..e69de29 diff --git a/knowledgegraph/spacy.ipynb b/knowledgegraph/spacy.ipynb index 9cec659..f145f02 100644 --- a/knowledgegraph/spacy.ipynb +++ b/knowledgegraph/spacy.ipynb @@ -498,18 +498,25 @@ "cell_type": "code", "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "3855" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "text = (\"Ford does not recomend Fx01\")" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [], - "source": [ - "doc = nlp(text)" + "text = (\"Ford does not recomend Fx01\")\n", + "doc = nlp(text)\n", + "svg = displacy.render(doc, style=\"dep\",jupyter=False)\n", + "\n", + "output_path = Path(\"../doc/images/verbpart.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)" ] }, { @@ -587,9 +594,7 @@ "output_type": "display_data" } ], - "source": [ - "displacy.render(doc, style=\"dep\")" - ] + "source": [] }, { "cell_type": "code",