{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from pattern.search import STRICT, search\n", "from pattern.en import parsetree" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "https://github.com/clips/pattern/wiki/pattern-search\n", "( inspired by [videogrep](https://github.com/antiboredom/videogrep/blob/master/videogrep/searcher.py) search )" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "text = open(\"RESURGENCE.txt\").read()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'RESURGENCE | Isabelle Stengers \\n\\n“We are the grandchildren of the witches you were not able to burn”'" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "text[:100]" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "tree = parsetree(text)" ] }, { "cell_type": "code", "execution_count": 80, "metadata": { "scrolled": true }, "outputs": [], "source": [ "n = 0\n", "actions = []\n", "\n", "for s in tree:\n", " f = open(f\"page{n}.html\",\"w\")\n", " print(\"\"\"\"\"\",\"here is your fate:\",file = f)\n", " print(s, file = f)\n", " print(actions[1],file = f)\n", " f.close()\n", " n = n + 1\n", " " ] }, { "cell_type": "code", "execution_count": 81, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Sentence(\"I/PRP/B-NP/O will/MD/B-VP/O honour/NN/B-NP/O the/DT/I-NP/O vision/NN/I-NP/O which/WDT/O/O ,/,/O/O since/IN/B-PP/B-PNP the/DT/B-NP/I-PNP Reagan/NNP/I-NP/I-PNP era/NN/I-NP/I-PNP ,/,/O/O has/VBZ/B-VP/O sustained/VBN/I-VP/O reclaiming/VBG/I-VP/O witches/NNS/B-NP/O such/JJ/B-ADJP/O as/IN/B-PP/B-PNP Starhawk/NNP/B-NP/I-PNP ,/,/O/O who/WP/O/O associate/VBP/B-VP/O their/PRP$/B-NP/O activism/NN/I-NP/O with/IN/B-PP/B-PNP the/DT/B-NP/I-PNP memory/NN/I-NP/I-PNP of/IN/B-PP/B-PNP a/DT/B-NP/I-PNP past/NN/I-NP/I-PNP earth-based/JJ/B-NP/I-PNP religion/NN/I-NP/I-PNP of/IN/B-PP/B-PNP the/DT/B-NP/I-PNP goddess/NN/I-NP/I-PNP -/:/O/O who/WP/O/O now/RB/B-ADVP/O ‘/''/O/O returns/NNS/B-NP/O ././O/O\")" ] }, "execution_count": 81, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tree[7]" ] }, { "cell_type": "code", "execution_count": 82, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "[Match(words=[Word('able/JJ')]),\n", " Match(words=[Word('recent/JJ')]),\n", " Match(words=[Word('defiant/JJ')]),\n", " Match(words=[Word('past/JJ')]),\n", " Match(words=[Word('dead/JJ')]),\n", " Match(words=[Word('many/JJ')]),\n", " Match(words=[Word('imaginary/JJ')]),\n", " Match(words=[Word('collective/JJ')]),\n", " Match(words=[Word('different/JJ')]),\n", " Match(words=[Word('burning/JJ')]),\n", " Match(words=[Word('rural/JJ')]),\n", " Match(words=[Word('old/JJ')]),\n", " Match(words=[Word('violent/JJ')]),\n", " Match(words=[Word('unquestionable/JJ')]),\n", " Match(words=[Word('modern/JJ')]),\n", " Match(words=[Word('defiant/JJ')]),\n", " Match(words=[Word('past/JJ')]),\n", " Match(words=[Word('such/JJ')]),\n", " Match(words=[Word('earth-based/JJ')]),\n", " Match(words=[Word('ongoing/JJ')]),\n", " Match(words=[Word('academic/JJ')]),\n", " Match(words=[Word('critical/JJ')]),\n", " Match(words=[Word('academic/JJ')]),\n", " Match(words=[Word('futile/JJ')]),\n", " Match(words=[Word('few/JJ')]),\n", " Match(words=[Word('regressive/JJ')]),\n", " Match(words=[Word('busy/JJ')]),\n", " Match(words=[Word('relentless/JJ')]),\n", " Match(words=[Word('neoliberal/JJ')]),\n", " Match(words=[Word('past/JJ')]),\n", " Match(words=[Word('eradicative/JJ')]),\n", " Match(words=[Word('futile/JJ')]),\n", " Match(words=[Word('Creative/JJ')]),\n", " Match(words=[Word('interconnecting/JJ')]),\n", " Match(words=[Word('such/JJ')]),\n", " Match(words=[Word('academic/JJ')]),\n", " Match(words=[Word('own/JJ')]),\n", " Match(words=[Word('specific/JJ')]),\n", " Match(words=[Word('deleterious/JJ')]),\n", " Match(words=[Word('agricultural/JJ')]),\n", " Match(words=[Word('successful/JJ')]),\n", " Match(words=[Word('natural/JJ')]),\n", " Match(words=[Word('industrial/JJ')]),\n", " Match(words=[Word('such/JJ')]),\n", " Match(words=[Word('stable/JJ')]),\n", " Match(words=[Word('natural/JJ')]),\n", " Match(words=[Word('ordered/JJ')]),\n", " Match(words=[Word('scientific/JJ')]),\n", " Match(words=[Word('academic/JJ')]),\n", " Match(words=[Word('past/JJ')]),\n", " Match(words=[Word('critical/JJ')]),\n", " Match(words=[Word('feminist/JJ')]),\n", " Match(words=[Word('sexist/JJ')]),\n", " Match(words=[Word('rational/JJ')]),\n", " Match(words=[Word('contemporary/JJ')]),\n", " Match(words=[Word('eradicative/JJ')]),\n", " Match(words=[Word('possible/JJ')]),\n", " Match(words=[Word('oppressive/JJ')]),\n", " Match(words=[Word('religious/JJ')]),\n", " Match(words=[Word('possible/JJ')]),\n", " Match(words=[Word('past/JJ')]),\n", " Match(words=[Word('new/JJ')]),\n", " Match(words=[Word('academic/JJ')]),\n", " Match(words=[Word('only/JJ')]),\n", " Match(words=[Word('true/JJ')]),\n", " Match(words=[Word('objective/JJ')]),\n", " Match(words=[Word('past/JJ')]),\n", " Match(words=[Word('rid/JJ')]),\n", " Match(words=[Word('academic/JJ')]),\n", " Match(words=[Word('eradicative/JJ')]),\n", " Match(words=[Word('human/JJ')]),\n", " Match(words=[Word('give/JJ')]),\n", " Match(words=[Word('subjective/JJ')]),\n", " Match(words=[Word('objective/JJ')]),\n", " Match(words=[Word('relevant/JJ')]),\n", " Match(words=[Word('mobilized/JJ')]),\n", " Match(words=[Word('complex/JJ')]),\n", " Match(words=[Word('unattended/JJ')]),\n", " Match(words=[Word('easy/JJ')]),\n", " Match(words=[Word('strict/JJ')]),\n", " Match(words=[Word('experimental/JJ')]),\n", " Match(words=[Word('exceptional/JJ')]),\n", " Match(words=[Word('fragile/JJ')]),\n", " Match(words=[Word('experimental/JJ')]),\n", " Match(words=[Word('active/JJ')]),\n", " Match(words=[Word('unusual/JJ')]),\n", " Match(words=[Word('other/JJ')]),\n", " Match(words=[Word('possible/JJ')]),\n", " Match(words=[Word('Experimental/JJ')]),\n", " Match(words=[Word('fragile/JJ')]),\n", " Match(words=[Word('experimental/JJ')]),\n", " Match(words=[Word('experimental/JJ')]),\n", " Match(words=[Word('become/JJ')]),\n", " Match(words=[Word('messy/JJ')]),\n", " Match(words=[Word('real/JJ')]),\n", " Match(words=[Word('devastating/JJ')]),\n", " Match(words=[Word('unilateral/JJ')]),\n", " Match(words=[Word('mere/JJ')]),\n", " Match(words=[Word('other/JJ')]),\n", " Match(words=[Word('muted/JJ')]),\n", " Match(words=[Word('good/JJ')]),\n", " Match(words=[Word('relevant/JJ')]),\n", " Match(words=[Word('bad/JJ')]),\n", " Match(words=[Word('abusive/JJ')]),\n", " Match(words=[Word('critical/JJ')]),\n", " Match(words=[Word('such/JJ')]),\n", " Match(words=[Word('ludicrous/JJ')]),\n", " Match(words=[Word('such/JJ')]),\n", " Match(words=[Word('theoretical/JJ')]),\n", " Match(words=[Word('scientific/JJ')]),\n", " Match(words=[Word('famous/JJ')]),\n", " Match(words=[Word('cooperative/JJ')]),\n", " Match(words=[Word('collaborative/JJ')]),\n", " Match(words=[Word('such/JJ')]),\n", " Match(words=[Word('creative/JJ')]),\n", " Match(words=[Word('common/JJ')]),\n", " Match(words=[Word('sad/JJ')]),\n", " Match(words=[Word('academic/JJ')]),\n", " Match(words=[Word('concerned/JJ')]),\n", " Match(words=[Word('common/JJ')]),\n", " Match(words=[Word('cooperative/JJ')]),\n", " Match(words=[Word('non-antagonist/JJ')]),\n", " Match(words=[Word('concerned/JJ')]),\n", " Match(words=[Word('laborious/JJ')]),\n", " Match(words=[Word('hesitant/JJ')]),\n", " Match(words=[Word('conflictual/JJ')]),\n", " Match(words=[Word('collective/JJ')]),\n", " Match(words=[Word('particular/JJ')]),\n", " Match(words=[Word('practical/JJ')]),\n", " Match(words=[Word('eradicative/JJ')]),\n", " Match(words=[Word('give/JJ')]),\n", " Match(words=[Word('collective/JJ')]),\n", " Match(words=[Word('many/JJ')]),\n", " Match(words=[Word('academic/JJ')]),\n", " Match(words=[Word('PowerPoint/JJ')]),\n", " Match(words=[Word('authoritative/JJ')]),\n", " Match(words=[Word('confrontational/JJ')]),\n", " Match(words=[Word('ancient/JJ')]),\n", " Match(words=[Word('academic/JJ')]),\n", " Match(words=[Word('traditional/JJ')]),\n", " Match(words=[Word('many/JJ')]),\n", " Match(words=[Word('activist/JJ')]),\n", " Match(words=[Word('contemporary/JJ')]),\n", " Match(words=[Word('common/JJ')]),\n", " Match(words=[Word('design/JJ')]),\n", " Match(words=[Word('resurgent/JJ')]),\n", " Match(words=[Word('deliberative/JJ')]),\n", " Match(words=[Word('appropriate/JJ')]),\n", " Match(words=[Word('own/JJ')]),\n", " Match(words=[Word('such/JJ')]),\n", " Match(words=[Word('shared/JJ')]),\n", " Match(words=[Word('free/JJ')]),\n", " Match(words=[Word('participatory/JJ')]),\n", " Match(words=[Word('own/JJ')]),\n", " Match(words=[Word('other/JJ')]),\n", " Match(words=[Word('s/JJ')]),\n", " Match(words=[Word('transformative/JJ')]),\n", " Match(words=[Word('slow/JJ')]),\n", " Match(words=[Word('mutual/JJ')]),\n", " Match(words=[Word('mutual/JJ')]),\n", " Match(words=[Word('own/JJ')]),\n", " Match(words=[Word('b]Polyphonic/JJ')]),\n", " Match(words=[Word('relevant/JJ')]),\n", " Match(words=[Word('authoritative/JJ')]),\n", " Match(words=[Word('biotechnological/JJ')]),\n", " Match(words=[Word('self-contained/JJ')]),\n", " Match(words=[Word('isolable/JJ')]),\n", " Match(words=[Word('dubious/JJ')]),\n", " Match(words=[Word('individual/JJ')]),\n", " Match(words=[Word('multiple/JJ')]),\n", " Match(words=[Word('specific/JJ')]),\n", " Match(words=[Word('interdependent/JJ')]),\n", " Match(words=[Word('sensitive/JJ')]),\n", " Match(words=[Word('belong/JJ')]),\n", " Match(words=[Word('evolutionary/JJ')]),\n", " Match(words=[Word('developmental/JJ')]),\n", " Match(words=[Word('evolutionary/JJ')]),\n", " Match(words=[Word('open/JJ')]),\n", " Match(words=[Word('cooperative/JJ')]),\n", " Match(words=[Word('polyphonic/JJ')]),\n", " Match(words=[Word('preserved.[4/JJ')]),\n", " Match(words=[Word('other/JJ')]),\n", " Match(words=[Word('cooperative/JJ')]),\n", " Match(words=[Word('worlding/JJ')]),\n", " Match(words=[Word('interesting/JJ')]),\n", " Match(words=[Word('such/JJ')]),\n", " Match(words=[Word('royal/JJ')]),\n", " Match(words=[Word('complex/JJ')]),\n", " Match(words=[Word('systemic/JJ')]),\n", " Match(words=[Word('rightful/JJ')]),\n", " Match(words=[Word('heretical/JJ')]),\n", " Match(words=[Word('apt/JJ')]),\n", " Match(words=[Word('cooperative/JJ')]),\n", " Match(words=[Word('positive/JJ')]),\n", " Match(words=[Word('business-as-usual/JJ')]),\n", " Match(words=[Word('academic/JJ')]),\n", " Match(words=[Word('capitalist/JJ')]),\n", " Match(words=[Word('socio-technical/JJ')]),\n", " Match(words=[Word('organizational/JJ')]),\n", " Match(words=[Word('business-as-usual/JJ')]),\n", " Match(words=[Word('horrific/JJ')]),\n", " Match(words=[Word('trusting/JJ')]),\n", " Match(words=[Word('capitalist/JJ')]),\n", " Match(words=[Word('wild/JJ')]),\n", " Match(words=[Word('natural/JJ')]),\n", " Match(words=[Word('blind/JJ')]),\n", " Match(words=[Word('rational/JJ')]),\n", " Match(words=[Word('sustainable/JJ')]),\n", " Match(words=[Word('prejudicial/JJ')]),\n", " Match(words=[Word('expendable/JJ')]),\n", " Match(words=[Word('willful/JJ')]),\n", " Match(words=[Word('trusting/JJ')]),\n", " Match(words=[Word('sufficient/JJ')]),\n", " Match(words=[Word('overbearing/JJ')]),\n", " Match(words=[Word('factual/JJ')]),\n", " Match(words=[Word('abstract/JJ')]),\n", " Match(words=[Word('situational/JJ')]),\n", " Match(words=[Word('oppose/JJ')]),\n", " Match(words=[Word('first/JJ')]),\n", " Match(words=[Word('interesting/JJ')]),\n", " Match(words=[Word('intriguing/JJ')]),\n", " Match(words=[Word('enlightening/JJ')]),\n", " Match(words=[Word('new/JJ')]),\n", " Match(words=[Word('possible/JJ')]),\n", " Match(words=[Word('new/JJ')]),\n", " Match(words=[Word('contemporary/JJ')]),\n", " Match(words=[Word('other/JJ')]),\n", " Match(words=[Word('trusting/JJ')]),\n", " Match(words=[Word('own/JJ')]),\n", " Match(words=[Word('reproducible/JJ')]),\n", " Match(words=[Word('such/JJ')]),\n", " Match(words=[Word('past/JJ')]),\n", " Match(words=[Word('challenge/JJ')]),\n", " Match(words=[Word('environmental/JJ')]),\n", " Match(words=[Word('social/JJ')]),\n", " Match(words=[Word('multiracial/JJ')]),\n", " Match(words=[Word('oppressed/JJ')]),\n", " Match(words=[Word('ancient/JJ')]),\n", " Match(words=[Word('ongoing/JJ')]),\n", " Match(words=[Word('future/JJ')]),\n", " Match(words=[Word('genuine/JJ')]),\n", " Match(words=[Word('Daring/JJ')]),\n", " Match(words=[Word('do/JJ')]),\n", " Match(words=[Word('uncertified/JJ')]),\n", " Match(words=[Word('improbable/JJ')]),\n", " Match(words=[Word('speculative/JJ')]),\n", " Match(words=[Word('future/JJ')]),\n", " Match(words=[Word('ludicrous/JJ')]),\n", " Match(words=[Word('free/JJ')]),\n", " Match(words=[Word('alternative/JJ')]),\n", " Match(words=[Word('condescending/JJ')]),\n", " Match(words=[Word('equivalent/JJ')]),\n", " Match(words=[Word('privileged/JJ')]),\n", " Match(words=[Word('involved/JJ')]),\n", " Match(words=[Word('interdependent/JJ')]),\n", " Match(words=[Word('always-situated/JJ')]),\n", " Match(words=[Word('generative/JJ')]),\n", " Match(words=[Word('liable/JJ')]),\n", " Match(words=[Word('new/JJ')]),\n", " Match(words=[Word('new/JJ')]),\n", " Match(words=[Word('scientific/JJ')]),\n", " Match(words=[Word('critical/JJ')]),\n", " Match(words=[Word('critical/JJ')]),\n", " Match(words=[Word('such/JJ')]),\n", " Match(words=[Word('liable/JJ')]),\n", " Match(words=[Word('new/JJ')]),\n", " Match(words=[Word('such/JJ')]),\n", " Match(words=[Word('scientific/JJ')]),\n", " Match(words=[Word('great/JJ')]),\n", " Match(words=[Word('worthy/JJ')]),\n", " Match(words=[Word('unworthy/JJ')]),\n", " Match(words=[Word('great/JJ')]),\n", " Match(words=[Word('certified/JJ')]),\n", " Match(words=[Word('i]Caliban/JJ')]),\n", " Match(words=[Word('Primitive/JJ')]),\n", " Match(words=[Word('Enemys/JJ')]),\n", " Match(words=[Word('i]Social/JJ')]),\n", " Match(words=[Word('Quarterly/JJ')]),\n", " Match(words=[Word('Dark/JJ')]),\n", " Match(words=[Word('Short/JJ')])]" ] }, "execution_count": 82, "metadata": {}, "output_type": "execute_result" } ], "source": [ "search(\"JJ\", tree)" ] }, { "cell_type": "code", "execution_count": 83, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[Match(words=[Word('take/VB'), Word('this/DT'), Word('motto/NN')]),\n", " Match(words=[Word('disqualify/VB'), Word('the/DT'), Word('resurgence/NN')]),\n", " Match(words=[Word('be/VB'), Word('the/DT'), Word('way/NN')]),\n", " Match(words=[Word('inherit/VB'), Word('the/DT'), Word('struggle/NN')]),\n", " Match(words=[Word('resist/VB'), Word('the/DT'), Word('idea/NN')]),\n", " Match(words=[Word('have/VB'), Word('the/DT'), Word('courage/NN')]),\n", " Match(words=[Word('accept/VB'), Word('this/DT'), Word('loss/NN')]),\n", " Match(words=[Word('be/VB'), Word('a/DT'), Word('question/NN')]),\n", " Match(words=[Word('have/VB'), Word('no/DT'), Word('power/NN')]),\n", " Match(words=[Word('signal/VB'), Word('an/DT'), Word('advance/NN')]),\n", " Match(words=[Word('generate/VB'), Word('the/DT'), Word('capacity/NN')]),\n", " Match(words=[Word('suspect/VB'), Word('some/DT'), Word('kind/NN')]),\n", " Match(words=[Word('suppress/VB'), Word('any/DT'), Word('temptation/NN')]),\n", " Match(words=[Word('doubt/VB'), Word('the/DT'), Word('kind/NN')]),\n", " Match(words=[Word('make/VB'), Word('a/DT'), Word('living/NN')]),\n", " Match(words=[Word('become/VB'), Word('an/DT'), Word('ally/NN')]),\n", " Match(words=[Word('weather/VB'), Word('the/DT'), Word('storm/NN')]),\n", " Match(words=[Word('recover/VB'), Word('the/DT'), Word('capacity/NN')])]" ] }, "execution_count": 83, "metadata": {}, "output_type": "execute_result" } ], "source": [ "search('VB DT NN', tree)" ] }, { "cell_type": "code", "execution_count": 84, "metadata": {}, "outputs": [], "source": [ "f = open(\"vbdtnn.html\",\"w\")\n", "n = 0\n", "print(\"\"\"\"\"\",file = f)\n", "print(\"choose your action:\",file = f)\n", "\n", "for m in search (\"VB DT NN\", tree): \n", " print(f\"{m.string}\",file = f)\n", " n = n + 1\n", "f.close()" ] }, { "cell_type": "code", "execution_count": 85, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'recover the capacity'" ] }, "execution_count": 85, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m.string" ] }, { "cell_type": "code", "execution_count": 86, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "their memory\n", "their power and practices\n", "their old rites\n", "their labour-power\n", "their activism\n", "their chant\n", "their return\n", "our future\n", "their fate\n", "its own destruction\n", "its specific responsibility\n", "their way\n", "his back\n", "his destiny\n", "their deconstruction\n", "its destruction\n", "their duty\n", "their method\n", "their fields\n", "their objectivity\n", "their position\n", "its own way\n", "our own reasons demands\n", "our reasons\n", "their own reasons\n", "their interest prevail\n", "his colleagues\n", "their participation\n", "its power\n", "its rightful object\n", "our business-as-usual academic routines\n", "our future\n", "our business-as-usual life\n", "our reasons\n", "its [\n", "our future\n", "their part\n", "their own\n", "their maintenance\n", "our additions\n", "My Enemys Enemy\n", "i]The Quarterly Review\n" ] } ], "source": [ "for m in search (\"PRP$ *\", tree):\n", " print (f\"{m.string}\")\n", " " ] }, { "cell_type": "code", "execution_count": 87, "metadata": {}, "outputs": [], "source": [ "from pattern.en import wordnet" ] }, { "cell_type": "code", "execution_count": 88, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "[Match(words=[Word('RESURGENCE/NN')]),\n", " Match(words=[Word('motto/NN')]),\n", " Match(words=[Word('cry/NN')]),\n", " Match(words=[Word('resurgence/NN')]),\n", " Match(words=[Word('memory/NN')]),\n", " Match(words=[Word('retrospective/NN')]),\n", " Match(words=[Word('power/NN')]),\n", " Match(words=[Word('matter/NN')]),\n", " Match(words=[Word('construction/NN')]),\n", " Match(words=[Word('understanding/NN')]),\n", " Match(words=[Word('destruction/NN')]),\n", " Match(words=[Word('appropriation/NN')]),\n", " Match(words=[Word('commons/NN')]),\n", " Match(words=[Word('rule/NN')]),\n", " Match(words=[Word('law/NN')]),\n", " Match(words=[Word('owner/NN')]),\n", " Match(words=[Word('invention/NN')]),\n", " Match(words=[Word('labour-power/NN')]),\n", " Match(words=[Word('market/NN')]),\n", " Match(words=[Word('commodity/NN')]),\n", " Match(words=[Word('Listening/NN')]),\n", " Match(words=[Word('cry/NN')]),\n", " Match(words=[Word('honour/NN')]),\n", " Match(words=[Word('vision/NN')]),\n", " Match(words=[Word('era/NN')]),\n", " Match(words=[Word('activism/NN')]),\n", " Match(words=[Word('memory/NN')]),\n", " Match(words=[Word('past/NN')]),\n", " Match(words=[Word('religion/NN')]),\n", " Match(words=[Word('goddess/NN')]),\n", " Match(words=[Word('judgement/NN')]),\n", " Match(words=[Word('resurgence/NN')]),\n", " Match(words=[Word('chant/NN')]),\n", " Match(words=[Word('goddess/NN')]),\n", " Match(words=[Word('return/NN')]),\n", " Match(words=[Word('return/NN')]),\n", " Match(words=[Word('goddess/NN')]),\n", " Match(words=[Word('regression/NN')]),\n", " Match(words=[Word('future/NN')]),\n", " Match(words=[Word('question/NN')]),\n", " Match(words=[Word('resurgence/NN')]),\n", " Match(words=[Word('future/NN')]),\n", " Match(words=[Word('order/NN')]),\n", " Match(words=[Word('something/NN')]),\n", " Match(words=[Word('way/NN')]),\n", " Match(words=[Word('way/NN')]),\n", " Match(words=[Word('fate/NN')]),\n", " Match(words=[Word('fate/NN')]),\n", " Match(words=[Word('price/NN')]),\n", " Match(words=[Word('progress/NN')]),\n", " Match(words=[Word('cascading/NN')]),\n", " Match(words=[Word('destruction/NN')]),\n", " Match(words=[Word('world/NN')]),\n", " Match(words=[Word('destruction/NN')]),\n", " Match(words=[Word('one/NN')]),\n", " Match(words=[Word('responsibility/NN')]),\n", " Match(words=[Word('formation/NN')]),\n", " Match(words=[Word('way/NN')]),\n", " Match(words=[Word('future/NN')]),\n", " Match(words=[Word('Resurgence/NN')]),\n", " Match(words=[Word('reappearance/NN')]),\n", " Match(words=[Word('something/NN')]),\n", " Match(words=[Word('pest/NN')]),\n", " Match(words=[Word('epidemic/NN')]),\n", " Match(words=[Word('vector/NN')]),\n", " Match(words=[Word('operation/NN')]),\n", " Match(words=[Word('eradication/NN')]),\n", " Match(words=[Word('landscape/NN')]),\n", " Match(words=[Word('catastrophe/NN')]),\n", " Match(words=[Word('exploitation/NN')]),\n", " Match(words=[Word('Today/NN')]),\n", " Match(words=[Word('reworlding/NN')]),\n", " Match(words=[Word('ecology/NN')]),\n", " Match(words=[Word('restoration/NN')]),\n", " Match(words=[Word('equilibrium/NN')]),\n", " Match(words=[Word('Ecology/NN')]),\n", " Match(words=[Word('association/NN')]),\n", " Match(words=[Word('reality/NN')]),\n", " Match(words=[Word('generalization/NN')]),\n", " Match(words=[Word('contrast/NN')]),\n", " Match(words=[Word('idea/NN')]),\n", " Match(words=[Word('regression/NN')]),\n", " Match(words=[Word('Man/NN')]),\n", " Match(words=[Word('Man/NN')]),\n", " Match(words=[Word('back/NN')]),\n", " Match(words=[Word('destiny/NN')]),\n", " Match(words=[Word('emancipation/NN')]),\n", " Match(words=[Word('order/NN')]),\n", " Match(words=[Word('nature/NN')]),\n", " Match(words=[Word('deconstruction/NN')]),\n", " Match(words=[Word('imperialist/NN')]),\n", " Match(words=[Word('colonialist/NN')]),\n", " Match(words=[Word('character/NN')]),\n", " Match(words=[Word('Man/NN')]),\n", " Match(words=[Word('motto/NN')]),\n", " Match(words=[Word('reference/NN')]),\n", " Match(words=[Word('progress/NN')]),\n", " Match(words=[Word('possibility/NN')]),\n", " Match(words=[Word('resurgence/NN')]),\n", " Match(words=[Word('materialist/NN')]),\n", " Match(words=[Word('secularist/NN')]),\n", " Match(words=[Word('position/NN')]),\n", " Match(words=[Word('resurgence/NN')]),\n", " Match(words=[Word('word/NN')]),\n", " Match(words=[Word('future/NN')]),\n", " Match(words=[Word('way/NN')]),\n", " Match(words=[Word('challenge/NN')]),\n", " Match(words=[Word('materialism/NN')]),\n", " Match(words=[Word('secularism/NN')]),\n", " Match(words=[Word('today/NN')]),\n", " Match(words=[Word('struggle/NN')]),\n", " Match(words=[Word('character/NN')]),\n", " Match(words=[Word('materialism/NN')]),\n", " Match(words=[Word('secularism/NN')]),\n", " Match(words=[Word('destruction/NN')]),\n", " Match(words=[Word('transition/NN')]),\n", " Match(words=[Word('capitalism/NN')]),\n", " Match(words=[Word('world.[1/NN')]),\n", " Match(words=[Word('idea/NN')]),\n", " Match(words=[Word('courage/NN')]),\n", " Match(words=[Word('loss/NN')]),\n", " Match(words=[Word('question/NN')]),\n", " Match(words=[Word('root/NN')]),\n", " Match(words=[Word('environment/NN')]),\n", " Match(words=[Word('way/NN')]),\n", " Match(words=[Word('destruction/NN')]),\n", " Match(words=[Word('fait/NN')]),\n", " Match(words=[Word('accompli/NN')]),\n", " Match(words=[Word('environment/NN')]),\n", " Match(words=[Word('fait/NN')]),\n", " Match(words=[Word('accompli/NN')]),\n", " Match(words=[Word('destruction/NN')]),\n", " Match(words=[Word('point/NN')]),\n", " Match(words=[Word('agreement/NN')]),\n", " Match(words=[Word('antagonist/NN')]),\n", " Match(words=[Word('fact/NN')]),\n", " Match(words=[Word('magic/NN')]),\n", " Match(words=[Word('practice/NN')]),\n", " Match(words=[Word('magic/NN')]),\n", " Match(words=[Word('cultural-subjective/NN')]),\n", " Match(words=[Word('construction/NN')]),\n", " Match(words=[Word('Objectivity/NN')]),\n", " Match(words=[Word('Subjectivity/NN')]),\n", " Match(words=[Word('banners[b/NN')]),\n", " Match(words=[Word('world/NN')]),\n", " Match(words=[Word('routine/NN')]),\n", " Match(words=[Word('methodology/NN')]),\n", " Match(words=[Word('duty/NN')]),\n", " Match(words=[Word('order/NN')]),\n", " Match(words=[Word('information/NN')]),\n", " Match(words=[Word('meaning/NN')]),\n", " Match(words=[Word('value/NN')]),\n", " Match(words=[Word('way/NN')]),\n", " Match(words=[Word('quest/NN')]),\n", " Match(words=[Word('approach/NN')]),\n", " Match(words=[Word('objectivity/NN')]),\n", " Match(words=[Word('subjectivity/NN')]),\n", " Match(words=[Word('way/NN')]),\n", " Match(words=[Word('method/NN')]),\n", " Match(words=[Word('knowledge/NN')]),\n", " Match(words=[Word('objectivity/NN')]),\n", " Match(words=[Word('banner/NN')]),\n", " Match(words=[Word('power/NN')]),\n", " Match(words=[Word('sense/NN')]),\n", " Match(words=[Word('achievement/NN')]),\n", " Match(words=[Word('objective/NN')]),\n", " Match(words=[Word('fact/NN')]),\n", " Match(words=[Word('questioning/NN')]),\n", " Match(words=[Word('objectivity/NN')]),\n", " Match(words=[Word('creation/NN')]),\n", " Match(words=[Word('situation/NN')]),\n", " Match(words=[Word('thing/NN')]),\n", " Match(words=[Word('power/NN')]),\n", " Match(words=[Word('interpretation/NN')]),\n", " Match(words=[Word('one/NN')]),\n", " Match(words=[Word('objectivity/NN')]),\n", " Match(words=[Word('name/NN')]),\n", " Match(words=[Word('event/NN')]),\n", " Match(words=[Word('outcome/NN')]),\n", " Match(words=[Word('method/NN')]),\n", " Match(words=[Word('lab/NN')]),\n", " Match(words=[Word('techno-social/NN')]),\n", " Match(words=[Word('milieu/NN')]),\n", " Match(words=[Word('world/NN')]),\n", " Match(words=[Word('claim/NN')]),\n", " Match(words=[Word('objectivity/NN')]),\n", " Match(words=[Word('lab/NN')]),\n", " Match(words=[Word('claim/NN')]),\n", " Match(words=[Word('operator/NN')]),\n", " Match(words=[Word('kind/NN')]),\n", " Match(words=[Word('objectivity/NN')]),\n", " Match(words=[Word('sheer/NN')]),\n", " Match(words=[Word('extraction/NN')]),\n", " Match(words=[Word('imposition/NN')]),\n", " Match(words=[Word('method/NN')]),\n", " Match(words=[Word('banner/NN')]),\n", " Match(words=[Word('conquest/NN')]),\n", " Match(words=[Word('hand/NN')]),\n", " Match(words=[Word('ground/NN')]),\n", " Match(words=[Word('subjectivity/NN')]),\n", " Match(words=[Word('objectivity/NN')]),\n", " Match(words=[Word('difference/NN')]),\n", " Match(words=[Word('sciences.[2/NN')]),\n", " Match(words=[Word('banner/NN')]),\n", " Match(words=[Word('subjectivity/NN')]),\n", " Match(words=[Word('turns/NN')]),\n", " Match(words=[Word('turn/NN')]),\n", " Match(words=[Word('t/NN')]),\n", " Match(words=[Word('help/NN')]),\n", " Match(words=[Word('advance/NN')]),\n", " Match(words=[Word('destruction/NN')]),\n", " Match(words=[Word('sense/NN')]),\n", " Match(words=[Word('contrast/NN')]),\n", " Match(words=[Word('resurgence/NN')]),\n", " Match(words=[Word('demoralization/NN')]),\n", " Match(words=[Word('perspective/NN')]),\n", " Match(words=[Word('advance/NN')]),\n", " Match(words=[Word('Demoralization/NN')]),\n", " Match(words=[Word('recognition/NN')]),\n", " Match(words=[Word('limit/NN')]),\n", " Match(words=[Word('possibility/NN')]),\n", " Match(words=[Word('possibility/NN')]),\n", " Match(words=[Word('feeling/NN')]),\n", " Match(words=[Word('legitimacy/NN')]),\n", " Match(words=[Word('objectivity/NN')]),\n", " Match(words=[Word('subjectivity/NN')]),\n", " Match(words=[Word('signal/NN')]),\n", " Match(words=[Word('process/NN')]),\n", " Match(words=[Word('resurgence/NN')]),\n", " Match(words=[Word('position/NN')]),\n", " Match(words=[Word('subjectivity/NN')]),\n", " Match(words=[Word('objectivity/NN')]),\n", " Match(words=[Word('dismemberment/NN')]),\n", " Match(words=[Word('sense[b/NN')]),\n", " Match(words=[Word('matter/NN')]),\n", " Match(words=[Word('way/NN')]),\n", " Match(words=[Word('mobilization/NN')]),\n", " Match(words=[Word('advance/NN')]),\n", " Match(words=[Word('knowledge/NN')]),\n", " Match(words=[Word('resurgence/NN')]),\n", " Match(words=[Word('situation/NN')]),\n", " Match(words=[Word('power/NN')]),\n", " Match(words=[Word('think/NN')]),\n", " Match(words=[Word('learning/NN')]),\n", " Match(words=[Word('process/NN')]),\n", " Match(words=[Word('situation/NN')]),\n", " Match(words=[Word('requirement/NN')]),\n", " Match(words=[Word('power/NN')]),\n", " Match(words=[Word('objective&slash;subjective/NN')]),\n", " Match(words=[Word('disjunction/NN')]),\n", " Match(words=[Word('way/NN')]),\n", " Match(words=[Word('process/NN')]),\n", " Match(words=[Word('ritual/NN')]),\n", " Match(words=[Word('bullet-point/NN')]),\n", " Match(words=[Word('instance/NN')]),\n", " Match(words=[Word('way/NN')]),\n", " Match(words=[Word('game/NN')]),\n", " Match(words=[Word('truth/NN')]),\n", " Match(words=[Word('power/NN')]),\n", " Match(words=[Word('position/NN')]),\n", " Match(words=[Word('addition/NN')]),\n", " Match(words=[Word('inspiration/NN')]),\n", " Match(words=[Word('instance/NN')]),\n", " Match(words=[Word('way/NN')]),\n", " Match(words=[Word('sweat/NN')]),\n", " Match(words=[Word('lodge/NN')]),\n", " Match(words=[Word('Today/NN')]),\n", " Match(words=[Word('share/NN')]),\n", " Match(words=[Word('reinvention/NN')]),\n", " Match(words=[Word('art/NN')]),\n", " Match(words=[Word('deliberation/NN')]),\n", " Match(words=[Word('issue/NN')]),\n", " Match(words=[Word('deliberation/NN')]),\n", " Match(words=[Word('power/NN')]),\n", " Match(words=[Word('sense/NN')]),\n", " Match(words=[Word('care/NN')]),\n", " Match(words=[Word('truth/NN')]),\n", " Match(words=[Word('power/NN')]),\n", " Match(words=[Word('agreement/NN')]),\n", " Match(words=[Word('process/NN')]),\n", " Match(words=[Word('party/NN')]),\n", " Match(words=[Word('experiment/NN')]),\n", " Match(words=[Word('capacity/NN')]),\n", " Match(words=[Word('feel/NN')]),\n", " Match(words=[Word('goddess/NN')]),\n", " Match(words=[Word('room/NN')]),\n", " Match(words=[Word('power/NN')]),\n", " Match(words=[Word('generativity/NN')]),\n", " Match(words=[Word('chant/NN')]),\n", " Match(words=[Word('everything/NN')]),\n", " Match(words=[Word('everything/NN')]),\n", " Match(words=[Word('honour/NN')]),\n", " Match(words=[Word('change/NN')]),\n", " Match(words=[Word('everything/NN')]),\n", " Match(words=[Word('way/NN')]),\n", " Match(words=[Word('conversion/NN')]),\n", " Match(words=[Word('i]She[i/NN')]),\n", " Match(words=[Word('course/NN')]),\n", " Match(words=[Word('trust/NN')]),\n", " Match(words=[Word('possibility/NN')]),\n", " Match(words=[Word('generativity/NN')]),\n", " Match(words=[Word('kind/NN')]),\n", " Match(words=[Word('role-playing/NN')]),\n", " Match(words=[Word('role/NN')]),\n", " Match(words=[Word('something/NN')]),\n", " Match(words=[Word('position/NN')]),\n", " Match(words=[Word('temptation/NN')]),\n", " Match(words=[Word('kind/NN')]),\n", " Match(words=[Word('authority/NN')]),\n", " Match(words=[Word('hesitation/NN')]),\n", " Match(words=[Word('betrayal/NN')]),\n", " Match(words=[Word('art/NN')]),\n", " Match(words=[Word('emergence/NN')]),\n", " Match(words=[Word('intensification/NN')]),\n", " Match(words=[Word('sensitivity/NN')]),\n", " Match(words=[Word('sensitivity/NN')]),\n", " Match(words=[Word('change/NN')]),\n", " Match(words=[Word('relationship/NN')]),\n", " Match(words=[Word('song[b/NN')]),\n", " Match(words=[Word('resurgence/NN')]),\n", " Match(words=[Word('situation/NN')]),\n", " Match(words=[Word('work/NN')]),\n", " Match(words=[Word('laboratory/NN')]),\n", " Match(words=[Word('redefinition/NN')]),\n", " Match(words=[Word('biology/NN')]),\n", " Match(words=[Word('abstraction/NN')]),\n", " Match(words=[Word('interest/NN')]),\n", " Match(words=[Word('prevail/NN')]),\n", " Match(words=[Word('living/NN')]),\n", " Match(words=[Word('none/NN')]),\n", " Match(words=[Word('biology.[3/NN')]),\n", " Match(words=[Word('song/NN')]),\n", " Match(words=[Word('singer/NN')]),\n", " Match(words=[Word('specialist/NN')]),\n", " Match(words=[Word('microbiology/NN')]),\n", " Match(words=[Word('character/NN')]),\n", " Match(words=[Word('composition/NN')]),\n", " Match(words=[Word('pattern/NN')]),\n", " Match(words=[Word('song/NN')]),\n", " Match(words=[Word('lab/NN')]),\n", " Match(words=[Word('field/NN')]),\n", " Match(words=[Word('life/NN')]),\n", " Match(words=[Word('participation/NN')]),\n", " Match(words=[Word('revolution/NN')]),\n", " Match(words=[Word('biology/NN')]),\n", " Match(words=[Word('heresy/NN')]),\n", " Match(words=[Word('challenge/NN')]),\n", " Match(words=[Word('creed/NN')]),\n", " Match(words=[Word('advance/NN')]),\n", " Match(words=[Word('science/NN')]),\n", " Match(words=[Word('biology/NN')]),\n", " Match(words=[Word('power/NN')]),\n", " Match(words=[Word('research/NN')]),\n", " Match(words=[Word('direction/NN')]),\n", " Match(words=[Word('song/NN')]),\n", " Match(words=[Word('assemblage/NN')]),\n", " Match(words=[Word('interdependence/NN')]),\n", " Match(words=[Word('extraction/NN')]),\n", " Match(words=[Word('isolation/NN')]),\n", " Match(words=[Word('road/NN')]),\n", " Match(words=[Word('progress/NN')]),\n", " Match(words=[Word('theory/NN')]),\n", " Match(words=[Word('i]a/NN')]),\n", " Match(words=[Word('priori[i/NN')]),\n", " Match(words=[Word('object/NN')]),\n", " Match(words=[Word('way/NN')]),\n", " Match(words=[Word('situation/NN')]),\n", " Match(words=[Word('biology/NN')]),\n", " Match(words=[Word('ally/NN')]),\n", " Match(words=[Word('resurgence/NN')]),\n", " Match(words=[Word('time/NN')]),\n", " Match(words=[Word('demobilization/NN')]),\n", " Match(words=[Word('s/NN')]),\n", " Match(words=[Word('proposition/NN')]),\n", " Match(words=[Word('future/NN')]),\n", " Match(words=[Word('life/NN')]),\n", " Match(words=[Word('place/NN')]),\n", " Match(words=[Word('resurgence/NN')]),\n", " Match(words=[Word('cultivation/NN')]),\n", " Match(words=[Word('art/NN')]),\n", " Match(words=[Word('attention/NN')]),\n", " Match(words=[Word('art/NN')]),\n", " Match(words=[Word('vigilance/NN')]),\n", " Match(words=[Word('relevance/NN')]),\n", " Match(words=[Word('risk/NN')]),\n", " Match(words=[Word('disaster/NN')]),\n", " Match(words=[Word('demand/NN')]),\n", " Match(words=[Word('precariousness/NN')]),\n", " Match(words=[Word('stable/NN')]),\n", " Match(words=[Word('Tsing/NN')]),\n", " Match(words=[Word('Matsutake/NN')]),\n", " Match(words=[Word('mushroom/NN')]),\n", " Match(words=[Word('extraction/NN')]),\n", " Match(words=[Word('exploitation/NN')]),\n", " Match(words=[Word('matter[I/NN')]),\n", " Match(words=[Word('Devastation/NN')]),\n", " Match(words=[Word('unravelling/NN')]),\n", " Match(words=[Word('life/NN')]),\n", " Match(words=[Word('deliberate/NN')]),\n", " Match(words=[Word('idea/NN')]),\n", " Match(words=[Word('case/NN')]),\n", " Match(words=[Word('mushroom/NN')]),\n", " Match(words=[Word('i]symbionts[i/NN')]),\n", " Match(words=[Word('knowledge/NN')]),\n", " Match(words=[Word('objectivity/NN')]),\n", " Match(words=[Word('subjectivity/NN')]),\n", " Match(words=[Word('light/NN')]),\n", " Match(words=[Word('situation/NN')]),\n", " Match(words=[Word('situation/NN')]),\n", " Match(words=[Word('woven[b/NN')]),\n", " Match(words=[Word('future/NN')]),\n", " Match(words=[Word('possibility/NN')]),\n", " Match(words=[Word('resurgence/NN')]),\n", " Match(words=[Word('possibility/NN')]),\n", " Match(words=[Word('name/NN')]),\n", " Match(words=[Word('extraction/NN')]),\n", " Match(words=[Word('web/NN')]),\n", " Match(words=[Word('generativity.[6/NN')]),\n", " Match(words=[Word('cultivation/NN')]),\n", " Match(words=[Word('interdependence/NN')]),\n", " Match(words=[Word('precariousness/NN')]),\n", " Match(words=[Word('part/NN')]),\n", " Match(words=[Word('growth/NN')]),\n", " Match(words=[Word('selection/NN')]),\n", " Match(words=[Word('off-ground/NN')]),\n", " Match(words=[Word('resurgence/NN')]),\n", " Match(words=[Word('return/NN')]),\n", " Match(words=[Word('climate/NN')]),\n", " Match(words=[Word('justice/NN')]),\n", " Match(words=[Word('i]Alliance/NN')]),\n", " Match(words=[Word('alliances[i/NN')]),\n", " Match(words=[Word('gender/NN')]),\n", " Match(words=[Word('colour/NN')]),\n", " Match(words=[Word('resistance/NN')]),\n", " Match(words=[Word('storm/NN')]),\n", " Match(words=[Word('need/NN')]),\n", " Match(words=[Word('honour/NN')]),\n", " Match(words=[Word('struggle/NN')]),\n", " Match(words=[Word('for.[7/NN')]),\n", " Match(words=[Word('commons/NN')]),\n", " Match(words=[Word('world/NN')]),\n", " Match(words=[Word('name/NN')]),\n", " Match(words=[Word('property/NN')]),\n", " Match(words=[Word('commons/NN')]),\n", " Match(words=[Word('need/NN')]),\n", " Match(words=[Word('capacity/NN')]),\n", " Match(words=[Word('concern/NN')]),\n", " Match(words=[Word('care/NN')]),\n", " Match(words=[Word('maintenance/NN')]),\n", " Match(words=[Word('commons.[8/NN')]),\n", " Match(words=[Word('Resurgence/NN')]),\n", " Match(words=[Word('word/NN')]),\n", " Match(words=[Word('option/NN')]),\n", " Match(words=[Word('future/NN')]),\n", " Match(words=[Word('trust/NN')]),\n", " Match(words=[Word('today/NN')]),\n", " Match(words=[Word('s/NN')]),\n", " Match(words=[Word('possibility/NN')]),\n", " Match(words=[Word('worth/NN')]),\n", " Match(words=[Word('option/NN')]),\n", " Match(words=[Word('today/NN')]),\n", " Match(words=[Word('standing/NN')]),\n", " Match(words=[Word('place/NN')]),\n", " Match(words=[Word('skepticism/NN')]),\n", " Match(words=[Word('resurgence/NN')]),\n", " Match(words=[Word('option/NN')]),\n", " Match(words=[Word('ground/NN')]),\n", " Match(words=[Word('soil/NN')]),\n", " Match(words=[Word('commons/NN')]),\n", " Match(words=[Word('abstraction/NN')]),\n", " Match(words=[Word('process/NN')]),\n", " Match(words=[Word('matter/NN')]),\n", " Match(words=[Word('song/NN')]),\n", " Match(words=[Word('song/NN')]),\n", " Match(words=[Word('attention/NN')]),\n", " Match(words=[Word('concern/NN')]),\n", " Match(words=[Word('attention/NN')]),\n", " Match(words=[Word('song/NN')]),\n", " Match(words=[Word('question/NN')]),\n", " Match(words=[Word('pluriverse/NN')]),\n", " Match(words=[Word('rise/NN')]),\n", " Match(words=[Word('fall/NN')]),\n", " Match(words=[Word('value/NN')]),\n", " Match(words=[Word('question/NN')]),\n", " Match(words=[Word('answer/NN')]),\n", " Match(words=[Word('difference/NN')]),\n", " Match(words=[Word('world/NN')]),\n", " Match(words=[Word('manner/NN')]),\n", " Match(words=[Word('difference/NN')]),\n", " Match(words=[Word('Enemy/NN')]),\n", " Match(words=[Word('doi:10.2307&slash;466844/NN')]),\n", " Match(words=[Word('I./NN')]),\n", " Match(words=[Word('doi:10.1086&slash;668166/NN')]),\n", " Match(words=[Word('Song/NN')]),\n", " Match(words=[Word('i]Biology/NN')]),\n", " Match(words=[Word('End/NN')]),\n", " Match(words=[Word('Sex/NN')]),\n", " Match(words=[Word('Introduction/NN')]),\n", " Match(words=[Word('i]Pragmatism/NN')]),\n", " Match(words=[Word('Name/NN')])]" ] }, "execution_count": 88, "metadata": {}, "output_type": "execute_result" } ], "source": [ "search('NN', tree)\n" ] }, { "cell_type": "code", "execution_count": 89, "metadata": {}, "outputs": [], "source": [ "sense = wordnet.synsets(\"language\")[0]" ] }, { "cell_type": "code", "execution_count": 90, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Synset('communication.n.02')" ] }, "execution_count": 90, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sense.hypernym" ] }, { "cell_type": "code", "execution_count": 78, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "matching owner\n", "matching Man\n", "matching Man\n", "matching imperialist\n", "matching colonialist\n", "matching Man\n", "matching materialist\n", "matching secularist\n", "matching antagonist\n", "matching singer\n", "matching specialist\n" ] } ], "source": [ "output = []\n", "search_word=\"person\"\n", "for search_word in search_word.split('|'):\n", " synset = wordnet.synsets(search_word)[0]\n", " pos = synset.pos\n", " possible_words = search(pos, tree)\n", " for match in possible_words:\n", " # print (f\"match {match}\")\n", " word = match[0].string\n", " synsets = wordnet.synsets(word)\n", " if len(synsets) > 0:\n", " hypernyms = synsets[0].hypernyms(recursive=True)\n", " if any(search_word == h.senses[0] for h in hypernyms):\n", " print(f\"matching {word}\")\n", " output.append(word)" ] }, { "cell_type": "code", "execution_count": 79, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['owner',\n", " 'Man',\n", " 'Man',\n", " 'imperialist',\n", " 'colonialist',\n", " 'Man',\n", " 'materialist',\n", " 'secularist',\n", " 'antagonist',\n", " 'singer',\n", " 'specialist']" ] }, "execution_count": 79, "metadata": {}, "output_type": "execute_result" } ], "source": [ "output" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.7.3" } }, "nbformat": 4, "nbformat_minor": 4 }