mirror of
https://github.com/gsi-upm/sitc
synced 2024-11-24 15:32:29 +00:00
Added rd grammar
This commit is contained in:
parent
1a38307a2e
commit
3c96a2b12c
@ -233,12 +233,14 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"We can use the StandfordParser that is integrated in NLTK, but it requires to configure the CLASSPATH, which can be a bit annoying. Instead, we are going to see some demos to understand how grammars work. In case you are interested, you can consult the [manual](http://www.nltk.org/api/nltk.parse.html) to run it.\n",
|
"We can use the StandfordParser that is integrated in NLTK, but it requires to configure the CLASSPATH, which can be a bit annoying. Instead, we are going to see some demos to understand how grammars work. In case you are interested, you can consult the [manual](http://www.nltk.org/api/nltk.parse.html) to run it.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"In the following example, you will run an interactive context-free parser, called [shift-reduce parser](http://www.nltk.org/book/ch08.html).\n",
|
"In the following example, you will run two interactive context-free parser (http://www.nltk.org/book/ch08.html): shift-reduce parser (botton-up) and recursive descent parser (top-down).\n",
|
||||||
"The panel on the left shows the grammar as a list of production rules. The panel on the right contains the stack and the remaining input.\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"First, we run the shift-reduce parser. The panel on the left shows the grammar as a list of production rules. The panel on the right contains the stack and the remaining input.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"You should:\n",
|
"You should:\n",
|
||||||
"* Run pressing 'step' until the sentence is fully analyzed. With each step, the parser either shifts one word onto the stack or reduces two subtrees of the stack into a new subtree.\n",
|
"* Run pressing 'step' until the sentence is fully analyzed. With each step, the parser either shifts one word onto the stack or reduces two subtrees of the stack into a new subtree.\n",
|
||||||
"* Try to act as the parser. Instead of pressing 'step', press 'shift' and 'reduce'. Follow the 'always shift before reduce' rule. It is likely you will reach a state where the parser cannot proceed. You can go back with 'Undo'."
|
"* Try to act as the parser. Instead of pressing 'step', press 'shift' and 'reduce'. Follow the 'always shift before reduce' rule. It is likely you will reach a state where the parser cannot proceed. You can go back with 'Undo'. You can try to change the order of the grammar rules or add new grammar rules."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -253,6 +255,25 @@
|
|||||||
"srparser_app.app()"
|
"srparser_app.app()"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"Now we run the recursive descent parser. Observe the different parsing strategies and consult the [book](http://www.nltk.org/api/nltk.parse.html)."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": true
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from nltk.app import rdparser_app\n",
|
||||||
|
"rdparser_app.app()"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
|
Loading…
Reference in New Issue
Block a user