Python Forum
[nltk] Parsing with CFG
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[nltk] Parsing with CFG
#1
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).
Reply
#2
see: https://www.nltk.org/book/ch08.html
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error on trying to use NLTK Punkt PythonDE 1 2,010 Oct-22-2020, 07:17 PM
Last Post: PythonDE
  [nltk] Relations Extractor constantin01 3 3,471 Jun-28-2019, 10:41 AM
Last Post: constantin01
  [nltk] Naive Bayes Classifier constantin01 0 1,959 Jun-24-2019, 10:36 AM
Last Post: constantin01
  NLTK Download Attribute error laila1a 1 8,454 Jan-27-2019, 12:03 AM
Last Post: Larz60+
  [split] serious n00b.. NLTK in python 2.7 and 3.5 kevindenman 3 4,497 Feb-22-2018, 09:05 PM
Last Post: kevindenman

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020