Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
11 views

Unit 2_Lecture 1

This document covers Unit II of a Natural Language Processing course, focusing on syntax and dependency parsing. It explains the concepts of syntax trees, types of parsing (top-down and bottom-up), and the differences between deep and shallow parsing. Additionally, it introduces dependency grammar and provides examples and practice problems related to parsing.

Uploaded by

Niveditha S
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Unit 2_Lecture 1

This document covers Unit II of a Natural Language Processing course, focusing on syntax and dependency parsing. It explains the concepts of syntax trees, types of parsing (top-down and bottom-up), and the differences between deep and shallow parsing. Additionally, it introduces dependency grammar and provides examples and practice problems related to parsing.

Uploaded by

Niveditha S
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

21CSE356T– Natural

Language Processing

Unit II
Instructor:
Mrs. S. Niveditha,
Lecture : 10 Assistant Professor(Sr. G)
Unit :2 SRM Institute of Science and Technology,
Session :1 nivedits@srmist.edu.in
Topics for Today

 Syntax Parsing

 Dependency Parsing
Syntax Parsing

 A Syntax tree or a parse tree is a tree representation of different syntactic


categories of a sentence. It helps us to understand the syntactical structure of a
sentence.

 Parsing is the task of uncovering the syntactic structure of language and is often
viewed as an important prerequisite for building systems capable of understanding
language

 Syntactic structure is necessary as a first step towards semantic interpretation, for


detecting phrasal chunks for indexing in an IR system .
Goal of syntactic analysis (parsing):

 Detect if a sentence is correct

 Provide a syntactic structure of a sentence


Types of Parsing

 Derivation divides parsing into the followings two types −

 Top-down Parsing

The parser starts constructing the parse tree from the start symbol and
then tries to transform the start symbol to the input. The most common
form of top-down parsing uses recursive procedure to process the input.
The main disadvantage of recursive descent parsing is backtracking.

 Bottom-up Parsing

The parser starts with the input symbol and tries to construct the parser
tree up to the start symbol.
Deep Vs Shallow Parsing

Deep Parsing Shallow Parsing

In deep parsing, the search strategy will give a It is the task of parsing a limited part of the
complete syntactic structure to a sentence. syntactic information from the given task.

It is suitable for complex NLP applications. It can be used for less complex NLP
applications.

Dialogue systems and summarization are the Information extraction and text mining are the
examples of NLP applications where deep examples of NLP applications where deep
parsing is used. parsing is used.

It is also called full parsing. It is also called chunking.


Types of Derivation

 Left-most Derivation
 In the left-most derivation, the sentential form of an input is scanned and replaced
from the left to the right. The sentential form in this case is called the left-
sentential form.

 Right-most Derivation
 In the left-most derivation, the sentential form of an input is scanned and replaced
from right to left. The sentential form in this case is called the right-sentential form.
Sample Grammar
Sample Grammar
Example
Example
Ambiguity
Dependency Parsing

 Dependency grammar (DG) is opposite to the syntactic grammar because it


lacks phrasal nodes.
Dependency grammar

 In Dependency Grammar, the linguistic units, i.e., words are


connected to each other by directed links.

 The verb becomes the center of the clause structure.

 Every other syntactic units are connected to the verb in terms of


directed link. These syntactic units are called dependencies.
Example
Syntax Tree Vs Dependency Tree

Syntax Tree Dependency Tree

Main Element: Constituents (or Main Element: dependency


Phrases, or bracketing's)

Constituents abstract linguistic Focus on relations between


units words
Results in nested trees Handles free word order nicely.
Lets Implement!!
Parse Tree generation
# Import required libraries
import nltk
#Extract all parts of speech from any text
#nltk.download('punkt') chunker = RegexpParser("""
#nltk.download('averaged_perceptron_ta NP: {<DT>?<JJ>*<NN>} #To extract Noun Phrases
gger') P: {<IN>} #To extract Prepositions
from nltk import pos_tag, word_tokenize, V: {<V.*>} #To extract Verbs
RegexpParser PP: {<p> <NP>} #To extract Prep. Phrases
VP: {<V> <NP|PP>*} #To extract Verb Phrases
# Example text """)

sample_text = "The quick brown fox


jumps over the lazy dog" # Print all parts of speech in above sentence
output = chunker.parse(tagged)
print("After Extracting\n", output)
# Find all parts of speech in above
output.draw()
sentence
Practice Problems

 1. S → NP VP
 2. NP → Det N
The dog chased the cat
 3. VP → V NP / V ADV The sun is shining
 4. Det → "The" | "A“ brightly.
 5. N → "dog" | "cat“ | “sun”
 6. V → "chased“
 7. Adv → “Shining”

You might also like