Python Forum
[nltk] Parsing with CFG - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: [nltk] Parsing with CFG (/thread-19590.html)



[nltk] Parsing with CFG - constantin01 - Jul-05-2019

Hi

I am reading "Natural Language Processing with Python" and the author gives example of use of CFG in nltk

 grammar2 = nltk.parse_cfg("""
 S -> NP VP
 NP -> Det Nom | PropN
 Nom -> Adj Nom | N
 VP -> V Adj | V NP | V S | V NP PP
 PP -> P NP
 PropN -> 'Buster' | 'Chatterer' | 'Joe'
 Det -> 'the' | 'a'
 N -> 'bear' | 'squirrel' | 'tree' | 'fish' | 'log'
 Adj -> 'angry' | 'frightened' | 'little' | 'tall'
 V -> 'chased' | 'saw' | 'said' | 'thought' | 'was' | 'put'
 P -> 'on'
 """)


But what if I want to parse arbitary sentence? How I can automize the process of description of given sentence? I was thinking that I can use tagged sentence, but nltk functions for parsing take only list of words (not list of tuples with word and tag).


RE: [nltk] Parsing with CFG - Larz60+ - Jul-05-2019

see: https://www.nltk.org/book/ch08.html