11. Phrase Structure Parsing And Dependency Parsing
-
POS Tagging = Labeling the bricks (this is a red brick, this is a blue brick).
-
Phrase Parsing = Showing how the bricks are cemented together to build a wall (this stack of bricks is a "Subject", that stack is a "Predicate").
1. Phrase Structure Parsing (Constituency Parsing)
Definition: Phrase Structure Parsing identifies the nested phrase structure of a sentence by breaking it down into constituents (phrases like Noun Phrases, Verb Phrases, etc.). It typically relies on rules from Context-Free Grammar (CFG).
Common Phrase Types
| Phrase Type | Meaning | Example |
|---|---|---|
| NP | Noun Phrase | the lazy dog |
| VP | Verb Phrase | eats an apple |
| PP | Prepositional Phrase | in the garden |
| ADJP | Adjective Phrase | very tall |
| ADVP | Adverb Phrase | quite slowly |
Structural Example
Sentence: "The dog barked loudly."
Tree Representation:
(S
(NP (DT The) (NN dog))
(VP (VBD barked)
(ADVP (RB loudly)))
)
Breakdown:
-
NP (Noun Phrase): "The dog"
-
VP (Verb Phrase): "barked loudly"
-
ADVP (Adverb Phrase): "loudly" (nested inside the VP)
2. Dependency Parsing
Definition: Dependency Parsing determines how words are related to each other using head-dependent relations (e.g., subject, object, modifier). Unlike phrase structure parsing, it connects words directly using directed arcs (Head \toDependent).
Dependency Example
Sentence: "The dog barked loudly."
-
ROOT: barked (Main verb)
-
nsubj (Subject): dog \to depends on barked
-
det (Determiner): The \to depends on dog
-
advmod (Adverbial Modifier): loudly \to depends on barked
Visual Logic:
[ROOT]
|
barked
/ \
dog loudly
|
The
Dependency Relation Types
| Relation | Meaning |
|---|---|
| nsubj | Nominal subject |
| dobj | Direct object |
| amod | Adjective modifier |
| advmod | Adverbial modifier |
| det | Determiner |
| prep | Prepositional modifier |
| pobj | Object of a preposition |
| ROOT | Root verb of the sentence |
3. Comparison: Phrase Structure vs. Dependency Parsing
| Feature | Phrase Structure Parsing | Dependency Parsing |
|---|---|---|
| Structure Type | Constituency tree (Nested phrases) | Dependency tree (Word-to-word links) |
| Focus | Phrase grouping (NP, VP) | Head-dependent word relations |
| Root | Sentence (S) | Main verb (ROOT) |
| Used In | Grammar-based NLP | Modern NLP (syntax, translation, extraction) |
| Tools | NLTK, Berkeley Parser | spaCy, Stanza, UDPipe |
4. Applications of Parsing
| Application | Usage |
|---|---|
| Question Answering | Understanding Subject-Verb-Object relationships to pinpoint answers. |
| Machine Translation | Essential for sentence reordering between languages with different grammar rules. |
| Grammar Correction | Identifying incorrect structures or broken dependencies. |
| Information Extraction | Extracting specific relations like Subject-Action. |
| Semantic Role Labeling | Understanding the underlying meaning and roles within a sentence. |
Tags: #data-engineering #sql