diff --git a/CategoriesGramaticalesCombinatoire.ods b/CategoriesGramaticalesCombinatoire.ods index 1a1f10a..ea20c17 100644 Binary files a/CategoriesGramaticalesCombinatoire.ods and b/CategoriesGramaticalesCombinatoire.ods differ diff --git a/test.ipynb b/test.ipynb index d16d677..977cd97 100644 --- a/test.ipynb +++ b/test.ipynb @@ -8,7 +8,7 @@ "source": [ "from nltk.ccg import chart, lexicon\n", "from nltk.ccg.lexicon import CCGLexicon, Token, augParseCategory\n", - "from nltk.ccg.chart import CCGChart,CCGLeafEdge,BinaryCombinatorRule,CCGEdge\n", + "from nltk.ccg.chart import CCGChart,CCGLeafEdge,BinaryCombinatorRule,CCGEdge,compute_semantics\n", "from nltk.tree import Tree\n", "import pandas as pd\n", "import numpy as np" @@ -66,7 +66,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -79,6 +79,7 @@ " if s in valz:\n", " return valz[s]\n", " else:\n", + " print(\"Unknown rule\",s)\n", " return 1.0 # Base rules weight" ] }, @@ -93,13 +94,12 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 47, "metadata": {}, "outputs": [], "source": [ "# Implements the CYK algorithm, code partly taken from nltk\n", "def weightedParse(tokens, lex, rules):\n", - " \"\"\"made to take weighed tokens and lexicons\"\"\"\n", " chart = CCGChart(list(tokens))\n", " \n", " # Initialize leaf edges.\n", @@ -113,8 +113,6 @@ " for span in range(2, chart.num_leaves() + 1):\n", " for start in range(0, chart.num_leaves() - span + 1):\n", " \n", - " print(\"==>\",span,start)\n", - " \n", " bestedge = None\n", " nedg = 0\n", " # edges[s] is the best edge generating the category s\n", @@ -138,7 +136,7 @@ " edge = CCGEdge(\n", " span=(left.start(), right.end()),\n", " categ=res,\n", - " rule=BinaryCombinatorRule(rule),\n", + " rule=rule,\n", " )\n", " edge.weight = rweight(rule) * left.weight * right.weight\n", " edge.triple = (rule,left,right)\n", @@ -155,35 +153,34 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 48, "metadata": {}, "outputs": [], "source": [ - "def wpToTree(edge):\n", + "def wp_to_tree(edge, wChart):\n", " if isinstance(edge,CCGLeafEdge):\n", - " return Tree((edge.token(),\"Leaf\"),[Tree(edge.token(),[edge.leaf()])])\n", + " word = Tree(edge.token(), [wChart._tokens[edge.start()]])\n", + " leaf = Tree((edge.token(), \"Leaf\"), [word])\n", + " return leaf\n", " else:\n", - " return Tree(\n", - " (chart.Token(None,edge.categ()),edge.triple[0].__str__()),\n", - " [wpToTree(t) for t in (edge.triple[1:])])" + " children = [wp_to_tree(t, wChart) for t in (edge.triple[1:])]\n", + " lhs = Token(wChart._tokens[edge.start() : edge.end()],\n", + " edge.lhs(),\n", + " compute_semantics(children, edge))\n", + " return Tree((lhs,edge.triple[0].__str__()), children)" ] }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 49, "metadata": {}, "outputs": [], "source": [ "def bestTree(tokens, lex, rules):\n", - " # We build the weighgted parse tree using cky\n", - " wChart = weightedParse(tokens, lex, rules)\n", - " # We get the biggest edge\n", - " e = list(wChart.select(start=0,end=len(tokens)))[0]\n", - " print(\"Edge count:\",len(list(wChart.select(start=0,end=len(tokens)))))\n", - " # We get the tree that brought us to this edge\n", - " t = wChart._trees(e, True, dict(), Tree)[0]\n", - " # (wpToTree(e),e.weight)\n", - " return (t,e.weight)" + " wChart = weightedParse(tokens, lex, rules) # We build the weighgted parse tree using cky\n", + " edge = list(wChart.select(start=0,end=len(tokens)))[0] # We get the biggest edge\n", + " t = wp_to_tree(edge, wChart) # We get the tree that brought us to this edge\n", + " return (t,edge.weight)" ] }, { @@ -195,7 +192,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 50, "metadata": {}, "outputs": [], "source": [ @@ -203,7 +200,7 @@ "from nltk.sem.logic import Expression\n", "from nltk.ccg.api import PrimitiveCategory\n", "\n", - "def to_pseudo_entries(table, consider_semantics = True):\n", + "def to_pseudo_entries(table, consider_semantics = False):\n", " \"\"\"returns a list of lists in the format ['word', 'category', 'weight', None]\n", " if consider_semantics == false else ['word', 'category', weight, 'semantic']\n", " that is left to be converted into tokens by to_wlex_entries\"\"\"\n", @@ -247,7 +244,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 51, "metadata": {}, "outputs": [], "source": [ @@ -261,7 +258,7 @@ "#print(table.keys())\n", "\n", "# On le convertit en Lexique pondéré\n", - "pe = to_pseudo_entries(table, consider_semantics = False)\n", + "pe = to_pseudo_entries(table, consider_semantics = True)\n", "#print(pe)\n", "wEntries = to_wlex_entries(pseudo_entries= pe, primitives= primitives, families= families)\n", "#print([list(map(lambda x: f\"{k} : \"+ str(x) + str(x._semantics), L)) for k, L in wEntries.items()])\n", @@ -296,1150 +293,377 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 52, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", + "1 found derivation for sentence: le chat dort\n", + " le chat dort\n", + " (N/pN) {\\P.exists x.P(x)} pN {chat} (S\\N) {\\n.dormir(n)}\n", + "-------------------------------------->\n", + " N {exists x.chat(x)}\n", + "------------------------------------------------------------<\n", + " S {dormir(exists x.chat(x))}\n", + "Best derivation tree has weight 0.5599999999999999\n", + " le chat dort\n", + " (N/pN) {\\P.exists x.P(x)} pN {chat} (S\\N) {\\n.dormir(n)}\n", + "-------------------------------------->\n", + " N {exists x.chat(x)}\n", + "------------------------------------------------------------<\n", + " S {dormir(exists x.chat(x))}\n", + "##########################################\n", + "1 found derivation for sentence: il dort\n", + " il dort\n", + " N {il} (S\\N) {\\n.dormir(n)}\n", "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", + " S {dormir(il)}\n", + "Best derivation tree has weight 0.7\n", + " il dort\n", + " N {il} (S\\N) {\\n.dormir(n)}\n", "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", + " S {dormir(il)}\n", + "##########################################\n", + "1 found derivation for sentence: le chat dort paisiblement\n", + " le chat dort paisiblement\n", + " (N/pN) {\\P.exists x.P(x)} pN {chat} (S\\N) {\\n.dormir(n)} ((S\\N)\\(S\\N)) {\\V n.paisiblement(V(n))}\n", + "-------------------------------------->\n", + " N {exists x.chat(x)}\n", + " ---------------------------------------------------------------<\n", + " (S\\N) {\\n.paisiblement(dormir(n))}\n", + "-----------------------------------------------------------------------------------------------------<\n", + " S {paisiblement(dormir(exists x.chat(x)))}\n", + "Best derivation tree has weight 0.39199999999999996\n", + " le chat dort paisiblement\n", + " (N/pN) {\\P.exists x.P(x)} pN {chat} (S\\N) {\\n.dormir(n)} ((S\\N)\\(S\\N)) {\\V n.paisiblement(V(n))}\n", + "-------------------------------------->\n", + " N {exists x.chat(x)}\n", + " ---------------------------------------------------------------<\n", + " (S\\N) {\\n.paisiblement(dormir(n))}\n", + "-----------------------------------------------------------------------------------------------------<\n", + " S {paisiblement(dormir(exists x.chat(x)))}\n", + "##########################################\n", + "1 found derivation for sentence: le chat noir dort\n", + " le chat noir dort\n", + " (N/pN) {\\P.exists x.P(x)} pN {chat} (pN\\pN) {\\n.noir(n)} (S\\N) {\\n.dormir(n)}\n", + " ---------------------------------<\n", + " pN {noir(chat)}\n", + "------------------------------------------------------------>\n", + " N {exists x.noir(chat,x)}\n", + "----------------------------------------------------------------------------------<\n", + " S {dormir(exists x.noir(chat,x))}\n", + "Best derivation tree has weight 0.39199999999999996\n", + " le chat noir dort\n", + " (N/pN) {\\P.exists x.P(x)} pN {chat} (pN\\pN) {\\n.noir(n)} (S\\N) {\\n.dormir(n)}\n", + " ---------------------------------<\n", + " pN {noir(chat)}\n", + "------------------------------------------------------------>\n", + " N {exists x.noir(chat,x)}\n", + "----------------------------------------------------------------------------------<\n", + " S {dormir(exists x.noir(chat,x))}\n", "##########################################\n", "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", + " le méchant chat dort\n", + " (N/pN) {\\P.exists x.P(x)} (pN/pN) {\\n.méchant(n)} pN {chat} (S\\N) {\\n.dormir(n)}\n", + " ------------------------------------>\n", + " pN {méchant(chat)}\n", + "--------------------------------------------------------------->\n", + " N {exists x.méchant(chat,x)}\n", + "-------------------------------------------------------------------------------------<\n", + " S {dormir(exists x.méchant(chat,x))}\n", + " le méchant chat dort\n", + " (N/pN) {\\P.exists x.P(x)} (pN/pN) {\\n.méchant(n)} pN {chat} (S\\N) {\\n.dormir(n)}\n", + "---------------------------------------------------->B\n", + " (N/pN) {\\n.exists x.méchant(n,x)}\n", + "--------------------------------------------------------------->\n", + " N {exists x.méchant(chat,x)}\n", + "-------------------------------------------------------------------------------------<\n", + " S {dormir(exists x.méchant(chat,x))}\n", + "Unknown rule >B\n", + "Unknown rule >B\n", + "Best derivation tree has weight 0.44800000000000006\n", + " le méchant chat dort\n", + " (N/pN) {\\P.exists x.P(x)} (pN/pN) {\\n.méchant(n)} pN {chat} (S\\N) {\\n.dormir(n)}\n", + " ------------------------------------>\n", + " pN {méchant(chat)}\n", + "--------------------------------------------------------------->\n", + " N {exists x.méchant(chat,x)}\n", + "-------------------------------------------------------------------------------------<\n", + " S {dormir(exists x.méchant(chat,x))}\n", "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", + "4 found derivation for sentence: le très méchant chat dort\n", + " le très méchant chat dort\n", + " (N/pN) {\\P.exists x.P(x)} ((pN/pN)/(pN/pN)) {\\P n.très(P(n))} (pN/pN) {\\n.méchant(n)} pN {chat} (S\\N) {\\n.dormir(n)}\n", + " -------------------------------------------------------------->\n", + " (pN/pN) {\\n.très(méchant(n))}\n", + " ------------------------------------------------------------------------->\n", + " pN {très(méchant(chat))}\n", + "---------------------------------------------------------------------------------------------------->\n", + " N {exists x.très(méchant(chat),x)}\n", + "--------------------------------------------------------------------------------------------------------------------------<\n", + " S {dormir(exists x.très(méchant(chat),x))}\n", + " le très méchant chat dort\n", + " (N/pN) {\\P.exists x.P(x)} ((pN/pN)/(pN/pN)) {\\P n.très(P(n))} (pN\\pN) {\\n.méchant(n)} pN {chat} (S\\N) {\\n.dormir(n)}\n", + " -------------------------------------------------------------->\n", + " (pN/pN) {\\n.très(méchant(n))}\n", + " ------------------------------------------------------------------------->\n", + " pN {très(méchant(chat))}\n", + "---------------------------------------------------------------------------------------------------->\n", + " N {exists x.très(méchant(chat),x)}\n", + "--------------------------------------------------------------------------------------------------------------------------<\n", + " S {dormir(exists x.très(méchant(chat),x))}\n", + " le très méchant chat dort\n", + " (N/pN) {\\P.exists x.P(x)} ((pN/pN)/(pN/pN)) {\\P n.très(P(n))} (pN/pN) {\\n.méchant(n)} pN {chat} (S\\N) {\\n.dormir(n)}\n", + " -------------------------------------------------------------->\n", + " (pN/pN) {\\n.très(méchant(n))}\n", + "----------------------------------------------------------------------------------------->B\n", + " (N/pN) {\\n.exists x.très(méchant(n),x)}\n", + "---------------------------------------------------------------------------------------------------->\n", + " N {exists x.très(méchant(chat),x)}\n", + "--------------------------------------------------------------------------------------------------------------------------<\n", + " S {dormir(exists x.très(méchant(chat),x))}\n", + " le très méchant chat dort\n", + " (N/pN) {\\P.exists x.P(x)} ((pN/pN)/(pN/pN)) {\\P n.très(P(n))} (pN\\pN) {\\n.méchant(n)} pN {chat} (S\\N) {\\n.dormir(n)}\n", + " -------------------------------------------------------------->\n", + " (pN/pN) {\\n.très(méchant(n))}\n", + "----------------------------------------------------------------------------------------->B\n", + " (N/pN) {\\n.exists x.très(méchant(n),x)}\n", + "---------------------------------------------------------------------------------------------------->\n", + " N {exists x.très(méchant(chat),x)}\n", + "--------------------------------------------------------------------------------------------------------------------------<\n", + " S {dormir(exists x.très(méchant(chat),x))}\n", + "Unknown rule >B\n", + "Best derivation tree has weight 0.35840000000000005\n", + " le très méchant chat dort\n", + " (N/pN) {\\P.exists x.P(x)} ((pN/pN)/(pN/pN)) {\\P n.très(P(n))} (pN/pN) {\\n.méchant(n)} pN {chat} (S\\N) {\\n.dormir(n)}\n", + " -------------------------------------------------------------->\n", + " (pN/pN) {\\n.très(méchant(n))}\n", + " ------------------------------------------------------------------------->\n", + " pN {très(méchant(chat))}\n", + "---------------------------------------------------------------------------------------------------->\n", + " N {exists x.très(méchant(chat),x)}\n", + "--------------------------------------------------------------------------------------------------------------------------<\n", + " S {dormir(exists x.très(méchant(chat),x))}\n", "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "##########################################\n", - "2 found derivation for sentence: le méchant chat dort\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - "----------------->B\n", - " (N/pN)\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", - "==> 2 0\n", - "==> 2 1\n", - "==> 2 2\n", - "==> 3 0\n", - "==> 3 1\n", - "==> 4 0\n", - "Edge count: 1\n", - "Best derivation tree has weight 0.24957917865181148\n", - " le méchant chat dort\n", - " (N/pN) (pN/pN) pN (S\\N)\n", - " --------------->\n", - " pN\n", - "----------------------->\n", - " N\n", - "------------------------------<\n", - " S\n", + "9 found derivation for sentence: le chat de la sœur de mon voisin dort\n", + " le chat de la sœur de mon voisin dort\n", + " (N/pN) {\\P.exists x.P(x)} pN {chat} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {soeur} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {voisin} (S\\N) {\\n.dormir(n)}\n", + "-------------------------------------->\n", + " N {exists x.chat(x)}\n", + "----------------------------------------------------------------<\n", + " (N/N) {\\m.de(exists x.chat(x),m)}\n", + " --------------------------------------->\n", + " N {exists x.soeur(x)}\n", + " -----------------------------------------------------------------<\n", + " (N/N) {\\m.de(exists x.soeur(x),m)}\n", + " ---------------------------------------->\n", + " N {exists x.voisin(x)}\n", + " --------------------------------------------------------------------------------------------------------->\n", + " N {de(exists x.soeur(x),exists x.voisin(x))}\n", + "------------------------------------------------------------------------------------------------------------------------------------------------------------------------->\n", + " N {de(exists x.chat(x),de(exists x.soeur(x),exists x.voisin(x)))}\n", + "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<\n", + " S {dormir(de(exists x.chat(x),de(exists x.soeur(x),exists x.voisin(x))))}\n", + " le chat de la sœur de mon voisin dort\n", + " (N/pN) {\\P.exists x.P(x)} pN {chat} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {soeur} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {voisin} (S\\N) {\\n.dormir(n)}\n", + "-------------------------------------->\n", + " N {exists x.chat(x)}\n", + "----------------------------------------------------------------<\n", + " (N/N) {\\m.de(exists x.chat(x),m)}\n", + " --------------------------------------->\n", + " N {exists x.soeur(x)}\n", + " -----------------------------------------------------------------<\n", + " (N/N) {\\m.de(exists x.soeur(x),m)}\n", + " -------------------------------------------------------------------------------------------->B\n", + " (N/pN) {\\P.de(exists x.soeur(x),exists x.P(x))}\n", + " --------------------------------------------------------------------------------------------------------->\n", + " N {de(exists x.soeur(x),exists x.voisin(x))}\n", + "------------------------------------------------------------------------------------------------------------------------------------------------------------------------->\n", + " N {de(exists x.chat(x),de(exists x.soeur(x),exists x.voisin(x)))}\n", + "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<\n", + " S {dormir(de(exists x.chat(x),de(exists x.soeur(x),exists x.voisin(x))))}\n", + " le chat de la sœur de mon voisin dort\n", + " (N/pN) {\\P.exists x.P(x)} pN {chat} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {soeur} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {voisin} (S\\N) {\\n.dormir(n)}\n", + "-------------------------------------->\n", + " N {exists x.chat(x)}\n", + "----------------------------------------------------------------<\n", + " (N/N) {\\m.de(exists x.chat(x),m)}\n", + " --------------------------------------->\n", + " N {exists x.soeur(x)}\n", + " -----------------------------------------------------------------<\n", + " (N/N) {\\m.de(exists x.soeur(x),m)}\n", + "--------------------------------------------------------------------------------------------------------------------------------->B\n", + " (N/N) {\\m.de(exists x.chat(x),de(exists x.soeur(x),m))}\n", + " ---------------------------------------->\n", + " N {exists x.voisin(x)}\n", + "------------------------------------------------------------------------------------------------------------------------------------------------------------------------->\n", + " N {de(exists x.chat(x),de(exists x.soeur(x),exists x.voisin(x)))}\n", + "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<\n", + " S {dormir(de(exists x.chat(x),de(exists x.soeur(x),exists x.voisin(x))))}\n", + " le chat de la sœur de mon voisin dort\n", + " (N/pN) {\\P.exists x.P(x)} pN {chat} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {soeur} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {voisin} (S\\N) {\\n.dormir(n)}\n", + "-------------------------------------->\n", + " N {exists x.chat(x)}\n", + "----------------------------------------------------------------<\n", + " (N/N) {\\m.de(exists x.chat(x),m)}\n", + " --------------------------------------->\n", + " N {exists x.soeur(x)}\n", + "------------------------------------------------------------------------------------------------------->\n", + " N {de(exists x.chat(x),exists x.soeur(x))}\n", + "---------------------------------------------------------------------------------------------------------------------------------<\n", + " (N/N) {\\m.de(de(exists x.chat(x),exists x.soeur(x)),m)}\n", + " ---------------------------------------->\n", + " N {exists x.voisin(x)}\n", + "------------------------------------------------------------------------------------------------------------------------------------------------------------------------->\n", + " N {de(de(exists x.chat(x),exists x.soeur(x)),exists x.voisin(x))}\n", + "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<\n", + " S {dormir(de(de(exists x.chat(x),exists x.soeur(x)),exists x.voisin(x)))}\n", + " le chat de la sœur de mon voisin dort\n", + " (N/pN) {\\P.exists x.P(x)} pN {chat} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {soeur} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {voisin} (S\\N) {\\n.dormir(n)}\n", + "-------------------------------------->\n", + " N {exists x.chat(x)}\n", + "----------------------------------------------------------------<\n", + " (N/N) {\\m.de(exists x.chat(x),m)}\n", + "------------------------------------------------------------------------------------------->B\n", + " (N/pN) {\\P.de(exists x.chat(x),exists x.P(x))}\n", + "------------------------------------------------------------------------------------------------------->\n", + " N {de(exists x.chat(x),exists x.soeur(x))}\n", + "---------------------------------------------------------------------------------------------------------------------------------<\n", + " (N/N) {\\m.de(de(exists x.chat(x),exists x.soeur(x)),m)}\n", + " ---------------------------------------->\n", + " N {exists x.voisin(x)}\n", + "------------------------------------------------------------------------------------------------------------------------------------------------------------------------->\n", + " N {de(de(exists x.chat(x),exists x.soeur(x)),exists x.voisin(x))}\n", + "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<\n", + " S {dormir(de(de(exists x.chat(x),exists x.soeur(x)),exists x.voisin(x)))}\n", + " le chat de la sœur de mon voisin dort\n", + " (N/pN) {\\P.exists x.P(x)} pN {chat} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {soeur} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {voisin} (S\\N) {\\n.dormir(n)}\n", + "-------------------------------------->\n", + " N {exists x.chat(x)}\n", + "----------------------------------------------------------------<\n", + " (N/N) {\\m.de(exists x.chat(x),m)}\n", + " --------------------------------------->\n", + " N {exists x.soeur(x)}\n", + " -----------------------------------------------------------------<\n", + " (N/N) {\\m.de(exists x.soeur(x),m)}\n", + " -------------------------------------------------------------------------------------------->B\n", + " (N/pN) {\\P.de(exists x.soeur(x),exists x.P(x))}\n", + "------------------------------------------------------------------------------------------------------------------------------------------------------------>B\n", + " (N/pN) {\\P.de(exists x.chat(x),de(exists x.soeur(x),exists x.P(x)))}\n", + "------------------------------------------------------------------------------------------------------------------------------------------------------------------------->\n", + " N {de(exists x.chat(x),de(exists x.soeur(x),exists x.voisin(x)))}\n", + "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<\n", + " S {dormir(de(exists x.chat(x),de(exists x.soeur(x),exists x.voisin(x))))}\n", + " le chat de la sœur de mon voisin dort\n", + " (N/pN) {\\P.exists x.P(x)} pN {chat} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {soeur} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {voisin} (S\\N) {\\n.dormir(n)}\n", + "-------------------------------------->\n", + " N {exists x.chat(x)}\n", + "----------------------------------------------------------------<\n", + " (N/N) {\\m.de(exists x.chat(x),m)}\n", + " --------------------------------------->\n", + " N {exists x.soeur(x)}\n", + " -----------------------------------------------------------------<\n", + " (N/N) {\\m.de(exists x.soeur(x),m)}\n", + "--------------------------------------------------------------------------------------------------------------------------------->B\n", + " (N/N) {\\m.de(exists x.chat(x),de(exists x.soeur(x),m))}\n", + "------------------------------------------------------------------------------------------------------------------------------------------------------------>B\n", + " (N/pN) {\\P.de(exists x.chat(x),de(exists x.soeur(x),exists x.P(x)))}\n", + "------------------------------------------------------------------------------------------------------------------------------------------------------------------------->\n", + " N {de(exists x.chat(x),de(exists x.soeur(x),exists x.voisin(x)))}\n", + "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<\n", + " S {dormir(de(exists x.chat(x),de(exists x.soeur(x),exists x.voisin(x))))}\n", + " le chat de la sœur de mon voisin dort\n", + " (N/pN) {\\P.exists x.P(x)} pN {chat} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {soeur} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {voisin} (S\\N) {\\n.dormir(n)}\n", + "-------------------------------------->\n", + " N {exists x.chat(x)}\n", + "----------------------------------------------------------------<\n", + " (N/N) {\\m.de(exists x.chat(x),m)}\n", + " --------------------------------------->\n", + " N {exists x.soeur(x)}\n", + "------------------------------------------------------------------------------------------------------->\n", + " N {de(exists x.chat(x),exists x.soeur(x))}\n", + "---------------------------------------------------------------------------------------------------------------------------------<\n", + " (N/N) {\\m.de(de(exists x.chat(x),exists x.soeur(x)),m)}\n", + "------------------------------------------------------------------------------------------------------------------------------------------------------------>B\n", + " (N/pN) {\\P.de(de(exists x.chat(x),exists x.soeur(x)),exists x.P(x))}\n", + "------------------------------------------------------------------------------------------------------------------------------------------------------------------------->\n", + " N {de(de(exists x.chat(x),exists x.soeur(x)),exists x.voisin(x))}\n", + "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<\n", + " S {dormir(de(de(exists x.chat(x),exists x.soeur(x)),exists x.voisin(x)))}\n", + " le chat de la sœur de mon voisin dort\n", + " (N/pN) {\\P.exists x.P(x)} pN {chat} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {soeur} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {voisin} (S\\N) {\\n.dormir(n)}\n", + "-------------------------------------->\n", + " N {exists x.chat(x)}\n", + "----------------------------------------------------------------<\n", + " (N/N) {\\m.de(exists x.chat(x),m)}\n", + "------------------------------------------------------------------------------------------->B\n", + " (N/pN) {\\P.de(exists x.chat(x),exists x.P(x))}\n", + "------------------------------------------------------------------------------------------------------->\n", + " N {de(exists x.chat(x),exists x.soeur(x))}\n", + "---------------------------------------------------------------------------------------------------------------------------------<\n", + " (N/N) {\\m.de(de(exists x.chat(x),exists x.soeur(x)),m)}\n", + "------------------------------------------------------------------------------------------------------------------------------------------------------------>B\n", + " (N/pN) {\\P.de(de(exists x.chat(x),exists x.soeur(x)),exists x.P(x))}\n", + "------------------------------------------------------------------------------------------------------------------------------------------------------------------------->\n", + " N {de(de(exists x.chat(x),exists x.soeur(x)),exists x.voisin(x))}\n", + "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<\n", + " S {dormir(de(de(exists x.chat(x),exists x.soeur(x)),exists x.voisin(x)))}\n", + "Unknown rule >B\n", + "Unknown rule >B\n", + "Unknown rule >B\n", + "Unknown rule >B\n", + "Unknown rule >B\n", + "Best derivation tree has weight 0.11239423999999998\n", + " le chat de la sœur de mon voisin dort\n", + " (N/pN) {\\P.exists x.P(x)} pN {chat} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {soeur} ((N/N)\\N) {\\n m.de(n,m)} (N/pN) {\\P.exists x.P(x)} pN {voisin} (S\\N) {\\n.dormir(n)}\n", + "-------------------------------------->\n", + " N {exists x.chat(x)}\n", + "----------------------------------------------------------------<\n", + " (N/N) {\\m.de(exists x.chat(x),m)}\n", + " --------------------------------------->\n", + " N {exists x.soeur(x)}\n", + " -----------------------------------------------------------------<\n", + " (N/N) {\\m.de(exists x.soeur(x),m)}\n", + " ---------------------------------------->\n", + " N {exists x.voisin(x)}\n", + " --------------------------------------------------------------------------------------------------------->\n", + " N {de(exists x.soeur(x),exists x.voisin(x))}\n", + "------------------------------------------------------------------------------------------------------------------------------------------------------------------------->\n", + " N {de(exists x.chat(x),de(exists x.soeur(x),exists x.voisin(x)))}\n", + "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<\n", + " S {dormir(de(exists x.chat(x),de(exists x.soeur(x),exists x.voisin(x))))}\n", "##########################################\n" ] + }, + { + "ename": "AssertionError", + "evalue": "`{}(\\m.à(donne(exists x.voisin(x)),m))` must be a lambda expression", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[52], line 10\u001b[0m\n\u001b[1;32m 7\u001b[0m phrase \u001b[38;5;241m=\u001b[39m phrase\u001b[38;5;241m.\u001b[39mlower()\u001b[38;5;241m.\u001b[39mstrip()\n\u001b[1;32m 9\u001b[0m \u001b[38;5;66;03m# On compte les arbres de dérivation trouvés\u001b[39;00m\n\u001b[0;32m---> 10\u001b[0m i \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlen\u001b[39m(\u001b[38;5;28mlist\u001b[39m(parser\u001b[38;5;241m.\u001b[39mparse(phrase\u001b[38;5;241m.\u001b[39msplit())))\n\u001b[1;32m 11\u001b[0m \u001b[38;5;28mprint\u001b[39m(i, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mfound derivation for sentence:\u001b[39m\u001b[38;5;124m\"\u001b[39m,phrase)\n\u001b[1;32m 12\u001b[0m g \u001b[38;5;241m=\u001b[39m parser\u001b[38;5;241m.\u001b[39mparse(phrase\u001b[38;5;241m.\u001b[39msplit())\n", + "File \u001b[0;32m~/Documents/Arbeiten/Linguistique/.env/lib/python3.11/site-packages/nltk/parse/chart.py:677\u001b[0m, in \u001b[0;36mChart.parses\u001b[0;34m(self, root, tree_class)\u001b[0m\n\u001b[1;32m 672\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 673\u001b[0m \u001b[38;5;124;03mReturn an iterator of the complete tree structures that span\u001b[39;00m\n\u001b[1;32m 674\u001b[0m \u001b[38;5;124;03mthe entire chart, and whose root node is ``root``.\u001b[39;00m\n\u001b[1;32m 675\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 676\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m edge \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mselect(start\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m0\u001b[39m, end\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_num_leaves, lhs\u001b[38;5;241m=\u001b[39mroot):\n\u001b[0;32m--> 677\u001b[0m \u001b[38;5;28;01myield from\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtrees\u001b[49m\u001b[43m(\u001b[49m\u001b[43medge\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtree_class\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtree_class\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcomplete\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/Documents/Arbeiten/Linguistique/.env/lib/python3.11/site-packages/nltk/parse/chart.py:694\u001b[0m, in \u001b[0;36mChart.trees\u001b[0;34m(self, edge, tree_class, complete)\u001b[0m\n\u001b[1;32m 679\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mtrees\u001b[39m(\u001b[38;5;28mself\u001b[39m, edge, tree_class\u001b[38;5;241m=\u001b[39mTree, complete\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m):\n\u001b[1;32m 680\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 681\u001b[0m \u001b[38;5;124;03m Return an iterator of the tree structures that are associated\u001b[39;00m\n\u001b[1;32m 682\u001b[0m \u001b[38;5;124;03m with ``edge``.\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 692\u001b[0m \u001b[38;5;124;03m sharing, then create a deep copy of each tree.\u001b[39;00m\n\u001b[1;32m 693\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 694\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28miter\u001b[39m(\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_trees\u001b[49m\u001b[43m(\u001b[49m\u001b[43medge\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcomplete\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmemo\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m{\u001b[49m\u001b[43m}\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtree_class\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtree_class\u001b[49m\u001b[43m)\u001b[49m)\n", + "File \u001b[0;32m~/Documents/Arbeiten/Linguistique/.env/lib/python3.11/site-packages/nltk/ccg/chart.py:332\u001b[0m, in \u001b[0;36mCCGChart._trees\u001b[0;34m(self, edge, complete, memo, tree_class)\u001b[0m\n\u001b[1;32m 329\u001b[0m trees \u001b[38;5;241m=\u001b[39m []\n\u001b[1;32m 331\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m cpl \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mchild_pointer_lists(edge):\n\u001b[0;32m--> 332\u001b[0m child_choices \u001b[38;5;241m=\u001b[39m \u001b[43m[\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_trees\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcp\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcomplete\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmemo\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtree_class\u001b[49m\u001b[43m)\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mcp\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mcpl\u001b[49m\u001b[43m]\u001b[49m\n\u001b[1;32m 333\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m children \u001b[38;5;129;01min\u001b[39;00m itertools\u001b[38;5;241m.\u001b[39mproduct(\u001b[38;5;241m*\u001b[39mchild_choices):\n\u001b[1;32m 334\u001b[0m lhs \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 335\u001b[0m Token(\n\u001b[1;32m 336\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_tokens[edge\u001b[38;5;241m.\u001b[39mstart() : edge\u001b[38;5;241m.\u001b[39mend()],\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 340\u001b[0m \u001b[38;5;28mstr\u001b[39m(edge\u001b[38;5;241m.\u001b[39mrule()),\n\u001b[1;32m 341\u001b[0m )\n", + "File \u001b[0;32m~/Documents/Arbeiten/Linguistique/.env/lib/python3.11/site-packages/nltk/ccg/chart.py:332\u001b[0m, in \u001b[0;36m\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 329\u001b[0m trees \u001b[38;5;241m=\u001b[39m []\n\u001b[1;32m 331\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m cpl \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mchild_pointer_lists(edge):\n\u001b[0;32m--> 332\u001b[0m child_choices \u001b[38;5;241m=\u001b[39m [\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_trees\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcp\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcomplete\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmemo\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtree_class\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;28;01mfor\u001b[39;00m cp \u001b[38;5;129;01min\u001b[39;00m cpl]\n\u001b[1;32m 333\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m children \u001b[38;5;129;01min\u001b[39;00m itertools\u001b[38;5;241m.\u001b[39mproduct(\u001b[38;5;241m*\u001b[39mchild_choices):\n\u001b[1;32m 334\u001b[0m lhs \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 335\u001b[0m Token(\n\u001b[1;32m 336\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_tokens[edge\u001b[38;5;241m.\u001b[39mstart() : edge\u001b[38;5;241m.\u001b[39mend()],\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 340\u001b[0m \u001b[38;5;28mstr\u001b[39m(edge\u001b[38;5;241m.\u001b[39mrule()),\n\u001b[1;32m 341\u001b[0m )\n", + "File \u001b[0;32m~/Documents/Arbeiten/Linguistique/.env/lib/python3.11/site-packages/nltk/ccg/chart.py:338\u001b[0m, in \u001b[0;36mCCGChart._trees\u001b[0;34m(self, edge, complete, memo, tree_class)\u001b[0m\n\u001b[1;32m 332\u001b[0m child_choices \u001b[38;5;241m=\u001b[39m [\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_trees(cp, complete, memo, tree_class) \u001b[38;5;28;01mfor\u001b[39;00m cp \u001b[38;5;129;01min\u001b[39;00m cpl]\n\u001b[1;32m 333\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m children \u001b[38;5;129;01min\u001b[39;00m itertools\u001b[38;5;241m.\u001b[39mproduct(\u001b[38;5;241m*\u001b[39mchild_choices):\n\u001b[1;32m 334\u001b[0m lhs \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 335\u001b[0m Token(\n\u001b[1;32m 336\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_tokens[edge\u001b[38;5;241m.\u001b[39mstart() : edge\u001b[38;5;241m.\u001b[39mend()],\n\u001b[1;32m 337\u001b[0m edge\u001b[38;5;241m.\u001b[39mlhs(),\n\u001b[0;32m--> 338\u001b[0m \u001b[43mcompute_semantics\u001b[49m\u001b[43m(\u001b[49m\u001b[43mchildren\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43medge\u001b[49m\u001b[43m)\u001b[49m,\n\u001b[1;32m 339\u001b[0m ),\n\u001b[1;32m 340\u001b[0m \u001b[38;5;28mstr\u001b[39m(edge\u001b[38;5;241m.\u001b[39mrule()),\n\u001b[1;32m 341\u001b[0m )\n\u001b[1;32m 342\u001b[0m trees\u001b[38;5;241m.\u001b[39mappend(tree_class(lhs, children))\n\u001b[1;32m 344\u001b[0m memo[edge] \u001b[38;5;241m=\u001b[39m trees\n", + "File \u001b[0;32m~/Documents/Arbeiten/Linguistique/.env/lib/python3.11/site-packages/nltk/ccg/chart.py:363\u001b[0m, in \u001b[0;36mcompute_semantics\u001b[0;34m(children, edge)\u001b[0m\n\u001b[1;32m 361\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m compute_function_semantics(function, argument)\n\u001b[1;32m 362\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(combinator, UndirectedComposition):\n\u001b[0;32m--> 363\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mcompute_composition_semantics\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfunction\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43margument\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 364\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(combinator, UndirectedSubstitution):\n\u001b[1;32m 365\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m compute_substitution_semantics(function, argument)\n", + "File \u001b[0;32m~/Documents/Arbeiten/Linguistique/.env/lib/python3.11/site-packages/nltk/ccg/logic.py:39\u001b[0m, in \u001b[0;36mcompute_composition_semantics\u001b[0;34m(function, argument)\u001b[0m\n\u001b[1;32m 38\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mcompute_composition_semantics\u001b[39m(function, argument):\n\u001b[0;32m---> 39\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(argument, LambdaExpression), (\n\u001b[1;32m 40\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m`\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m+\u001b[39m \u001b[38;5;28mstr\u001b[39m(argument) \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m` must be a lambda expression\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 41\u001b[0m )\n\u001b[1;32m 42\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m LambdaExpression(\n\u001b[1;32m 43\u001b[0m argument\u001b[38;5;241m.\u001b[39mvariable, ApplicationExpression(function, argument\u001b[38;5;241m.\u001b[39mterm)\u001b[38;5;241m.\u001b[39msimplify()\n\u001b[1;32m 44\u001b[0m )\n", + "\u001b[0;31mAssertionError\u001b[0m: `{}(\\m.à(donne(exists x.voisin(x)),m))` must be a lambda expression" + ] } ], "source": [ "# On lit les phrases dans le fichier\n", "with open('phrases.txt') as f:\n", " lines = f.readlines()\n", - "\n", - " # On ajoute des phrases de test\n", - " lines.append(\"le chat et la souris dorment\")\n", " \n", " for phrase in lines:\n", " # On met tout en minuscule\n", " phrase = phrase.lower().strip()\n", - " phrase = \"le méchant chat dort\"\n", " \n", " # On compte les arbres de dérivation trouvés\n", " i = len(list(parser.parse(phrase.split())))\n", @@ -1459,12 +683,68 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 33, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "? => (S\\S) {\\S.exists x.S(x)}\n", + "attrape => ((S\\N)/N) {\\n m.attrappe(m,n)}\n", + "avec => (((S\\N)\\(S\\N))/N) {\\n V m.V(avec(m,n))}\n", + "chat => pN {chat}\n", + "de => ((N/N)\\N) {\\n m.de(n,m)}\n", + "dents => pN {dents}\n", + "donne => (S\\N) {\\n.donne(n)} | ((S\\N)/N) {\\n m.donne(m,n)} | ((S\\N)\\N) {\\n m.donne(n,m)}\n", + "donner => N {donner} | (N/N) {\\n.donner(n)}\n", + "donné => Pp {\\n.donné(n)}\n", + "dorment => (S\\N) {\\n.dormir(n)}\n", + "dort => (S\\N) {\\n.dormir(n)}\n", + "elle => N {elle}\n", + "est => ((S\\N)/_var10) {\\P x.P(x)} | ((S\\N)/(N/N)) {{}} | ((S\\N)/(N\\N)) {{}}\n", + "et => (((S\\N)/(S\\N))\\(S\\N)) {\\P Q x.(P(x) & Q(x))} | ((N/N)\\N) {\\n m.et(n,m)} | ((S/S)\\S) {\\P Q.(P & Q)}\n", + "fromage => pN {fromage}\n", + "il => N {il}\n", + "la => ((S\\N)/((S\\N)/N)) {\\P n.exists m.P(n,m)} | (N/pN) {\\P.exists x.P(x)}\n", + "le => ((S\\N)/((S\\N)/N)) {\\P n.exists m.P(n,m)} | (N/pN) {\\P.exists x.P(x)}\n", + "lui => ((S\\N)/(S\\N)) {\\V n m.à(V(n),m)}\n", + "mange => (S\\N) {\\n.mange(n)} | ((S\\N)/N) {\\n m.mange(m,n)} | ((S\\N)\\N) {\\n m.mange(n,m)}\n", + "mangé => Pp {\\n.mangé(n)}\n", + "mangée => Pp {\\n.mangé(n)}\n", + "mon => (N/pN) {\\P.exists x.P(x)}\n", + "méchant => (pN/pN) {\\n.méchant(n)} | (pN\\pN) {\\n.méchant(n)}\n", + "noir => (pN\\pN) {\\n.noir(n)} | (pN/pN) {\\n.noir(n)}\n", + "paisiblement => ((S\\N)\\(S\\N)) {\\V n.paisiblement(V(n))}\n", + "par => (((S\\N)\\(S\\N))/N) {\\n V.V(n)}\n", + "pourchasse => ((S\\N)/N) {\\n m.pourchasse(m,n)}\n", + "que => ((N\\N)/S) {{}} | (N/S) {\\x.x}\n", + "quel => (((((S\\N)\\(S\\N))/N)\\(S/S))/N) {{}} | ((S/(S\\N))/N) {\\n V x.V(x,n)}\n", + "quelle => (((((S\\N)\\(S\\N))/N)\\(S/S))/N) {{}} | ((S/(S\\N))/N) {\\n V x.V(x,n)}\n", + "qui => ((N\\N)/(S\\N)) {\\V n.V(n)} | (S/(S\\N)) {\\V x.V(x)}\n", + "quoi => (((S/S)\\(((S\\N)\\(S\\N))/N))/N) {{}}\n", + "rat => pN {rat}\n", + "ses => (N/pN) {\\P.exists x.P(x)}\n", + "souhaite => ((S\\N)/N) {\\N m.souhaite(m,N(m))}\n", + "souris => pN {souris}\n", + "sœur => pN {soeur}\n", + "très => ((pN/pN)/(pN/pN)) {\\P n.très(P(n))}\n", + "un => (N/pN) {\\P.exists x.P(x)}\n", + "voisin => pN {voisin}\n", + "à => (((S\\N)\\(S\\N))/N) {\\n V m.V(à(m,n))}\n" + ] + } + ], "source": [ "print(lex)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": {