{
  "source_file": "0930",
  "source_platform": "Dev.to",
  "author": "Javier Aguirre",
  "title_listed": "Dependency Parsing: How NLP Understands Sentence Structure",
  "keywords": "",
  "domain": "文本处理",
  "content_type": "技术教程",
  "is_paid_flag": "否",
  "url": "https://dev.to/javiagu13/dependency-parsing-how-nlp-understands-sentence-structure-4mmd",
  "publish_date": "2026-09-09",
  "corpus_stage": "",
  "notes": "",
  "id": "a7f28f9f5699",
  "collected_at": "2026-10-02T13:54:12",
  "title": "Dependency Parsing: How NLP Understands Sentence Structure - DEV Community",
  "body_markdown": "You now know what each word is. But do you know what each word\ndoes\n?\nIn the previous post, we covered Part of Speech Tagging: the process of labelling each word as a noun, verb, adjective, and so on. That tells you the category of every word in a sentence. But it doesn’t tell you how those words connect to each other.\nTake this sentence:\n“The dog bit the man.”\nPOS tagging tells you that “dog” is a noun and “bit” is a verb. But it doesn’t tell you that “dog” is the one doing the biting, or that “man” is the one receiving it. For a lot of NLP tasks, that distinction matters enormously.\nDependency parsing\nis how NLP systems figure out those relationships. It maps the grammatical connections between words, revealing who did what to whom and how every part of a sentence fits together.\nWhat is dependency parsing?\nBefore we get into how computers do this, it helps to understand the underlying idea.\nDependency grammar\nis a theory of language structure that describes sentences as networks of relationships between words. Instead of breaking a sentence into nested phrases (like traditional grammar diagrams), dependency grammar draws direct links between individual words.\nEvery word in a sentence (except one) depends on another word. The word it depends on is called its\nhead\n. The relationship between them is called a\ndependency relation\n, and these relations have names that describe the grammatical role: subject, object, modifier, determiner, and so on. The one word that depends on nothing is the root of the sentence, usually the main verb.\nIn\n“The dog bit the man,”\nthe structure looks like this:\n“bit”\nis the root (nothing governs it)\n“dog”\ndepends on\n“bit”\nas the subject (\nnsubj\n)\n“man”\ndepends on\n“bit”\nas the object (\nobj\n)\n“The”\n(first one) depends on\n“dog”\nas a determiner (\ndet\n)\n“the”\n(second one) depends on\n“man”\nas a determiner (\ndet\n)\nEvery word is accounted for. Every relationship is named. The sentence has been turned into a map.\nWhen you draw out all those relationships visually, you get what’s called a\ndependency tree\n. It’s called a tree because the structure branches outward from a single root, just like a real tree. The main verb sits at the top. Subjects, objects, and modifiers hang below it. Determiners and other function words hang below those. Every node is a word, every edge is a labelled relationship, and every word appears exactly once with no circular chains.\nHere’s what the dependency tree for\n“The quick brown fox jumped over the fence”\nlooks like conceptually:\nThe tree makes the structure of the sentence explicit and machine-readable. A system can now navigate it programmatically: find the subject of the main verb, find all modifiers of a given noun, find the object of any action.\nDependency grammar maps every word to its head with a named relationship label\nParse Trees: Two Flavours\nYou’ll often hear the term\nparse tree\nused when people talk about dependency parsing, and it’s worth understanding what it means and how it relates to what we’ve just described.\nA dependency parse tree (what we’ve been describing) connects individual words to each other with typed relationship labels. The structure is flat in the sense that it connects words directly, without grouping them into phrases.\nA\nconstituency parse tree\n(also called a phrase structure tree) takes a different approach. Instead of connecting words to words, it groups words into nested phrases. A noun phrase contains a determiner and a noun. A verb phrase contains a verb and its noun phrase. Those phrases nest inside a sentence node at the top. The two approaches reveal the same underlying sentence structure but from different angles.\nIn practice the choice between them comes down to the task:\nDependency trees\nare word-to-word. Better for tasks that need to know relationships between specific words: who did what to whom.\nConstituency trees\nare phrase-based. Better for tasks that need to understand the hierarchical structure of a sentence: how clauses nest inside each other.\nIn modern NLP, dependency parsing is more widely used in production systems. It’s faster to compute, easier to work with programmatically, and sufficient for most downstream tasks.\nConstituency parse tree vs dependency parse tree for the same sentence showing the structural difference\nBoth dependency parsing and constituency parsing are forms of\nsyntactic analysis\n: the broader process of examining the grammatical structure of a sentence. POS tagging is also a form of syntactic analysis. They’re all part of the same family of techniques, each revealing a different layer of grammatical structure. In NLP pipelines, syntactic analysis typically sits between basic text processing (tokenization, POS tagging) and higher-level understanding (semantic analysis, information extraction). It provides the structural backbone that makes deeper analysis possible.\nHow Dependency Parsing Works\nModern dependency parsers use neural networks, but the core task is always the same: for each word in a sentence, find its head and label the relationship.\nThere are two main algorithmic approaches.\nTransition-based parsing\nworks through the sentence from left to right, maintaining a stack of words currently being processed. At each step, a classifier decides between a small set of actions: shift the next word onto the stack, create a dependency between two words, or move on. Because decisions are made one step at a time, this approach runs in linear time and is fast enough for production use.\nGraph-based parsing\ntakes a different route. Instead of building the tree step by step, it scores all possible edges between all pairs of words and then finds the tree that maximises the total score. This is slower but tends to be more accurate, especially for longer sentences with complex structure. Most state-of-the-art parsers today combine neural networks with graph-based approaches, using Transformer-based representations to score edges with rich contextual information.\nWhy It Matters in Practice\nLike POS tagging, dependency parsing is rarely the end goal. It’s a layer in a pipeline that makes other things possible.\nInformation extraction\nuses dependency trees to find subject-verb-object triples at scale. Given a corpus of news articles, you can extract every event of the form “company acquired company” or “person said statement” by querying the parse tree structure. This is faster and more precise than hoping a language model happens to extract the right thing.\nQuestion answering\nsystems use dependency parsing to understand what a question is actually asking.\n“Who did the dog bite?”\nand\n“Who bit the dog?”\nhave identical words but opposite meanings. The dependency tree makes that difference explicit.\nMachine translation\nrelies on syntactic structure to produce grammatically correct output in the target language. Word order differs between languages, and dependency relations provide language-agnostic structure that translation systems can map across.\nClinical NLP\nuses dependency parsing to extract medication dosages, symptoms, and diagnoses from clinical notes. A rule like “find the noun that is the object of the verb ‘prescribed’” is far more reliable than keyword matching when clinical language is ambiguous and variable.\nCoreference resolution\n(figuring out that “he” in one sentence refers to “John” in a previous one) uses dependency structure to track entities across sentences. The grammatical role of a pronoun is a strong signal for what it refers to.\nThe honest take on modern NLP: large language models have reduced how much explicit dependency parsing is done in cutting-edge research. But in production systems where interpretability, speed, and precision matter, dependency parsing remains a practical and widely used tool. spaCy runs a dependency parser by default on every document you process. You might not use the output directly, but it’s there, and the components that do use it quietly improve everything downstream.\nThe structure of a sentence is not decoration. It is the scaffolding that holds meaning together.\nDependency Parsing in Python with spaCy\nspaCy makes dependency parsing straightforward. It runs automatically when you process text:\nimport\nspacy\nnlp\n=\nspacy\n.\nload\n(\n\"\nen_core_web_sm\n\"\n)\ndoc\n=\nnlp\n(\n\"\nThe dog bit the man.\n\"\n)\nfor\ntoken\nin\ndoc\n:\nprint\n(\nf\n\"\n{\ntoken\n.\ntext\n}\n--[\n{\ntoken\n.\ndep_\n}\n]-->\n{\ntoken\n.\nhead\n.\ntext\n}\n\"\n)\nEnter fullscreen mode\nExit fullscreen mode\nOutput:\nThe --[det]--> dog\ndog --[nsubj]--> bit\nbit --[ROOT]--> bit\nthe --[det]--> man\nman --[dobj]--> bit\n. --[punct]--> bit\nEnter fullscreen mode\nExit fullscreen mode\nEvery token shows its dependency label and the head it points to. The root points to itself. From this output, a downstream system can immediately answer: what is the subject of “bit”? Dog. What is the object? Man.\nYou can also visualise the tree directly in spaCy using its built-in displaCy renderer, which produces a clean arc diagram in the browser.\nA dependency tree visualised as an arc diagram showing labelled relationships between words\nIs Dependency Parsing Still Relevant?\nShort answer: yes, especially in production.\nLarge language models are impressive at understanding language holistically, but they’re opaque. You can’t inspect why they interpreted a sentence a certain way. Dependency parsing gives you an explicit, interpretable representation of sentence structure that you can query, validate, and debug.\nFor teams building NLP pipelines in healthcare, legal tech, or finance, where decisions need to be explainable and auditable, dependency parsing is not a relic of the past. It’s a practical engineering choice that trades some accuracy for a lot of transparency and control.\nEven in LLM-powered systems, dependency parsing often runs in the preprocessing layer: cleaning up the input, extracting structured signals, or filtering out irrelevant sentences before the expensive model ever sees them. It earns its place not by being the most powerful tool, but by being fast, reliable, and interpretable in a world where those qualities are often more valuable than raw performance.\nWhat Comes Next\nDependency parsing gives you the grammatical structure of a sentence. You now know what each word is (POS tags) and how each word connects to the others (dependency relations).\nThe next step is moving from structure to meaning. That’s where\nWord Sense Disambiguation\ncomes in: the process of figuring out which meaning a word carries when it could mean several different things. It’s where NLP starts crossing from grammar into genuine language understanding.\nLearn This at Fondra Labs\nThis post is part of our\nNLP Foundations\nseries, where we build up practical AI knowledge one concept at a time, from tokenization and POS tagging all the way to retrieval systems and production pipelines.\nAt\nFondra Labs\n, we teach AI from production reality, not hype. Every topic in this series is here because it genuinely matters when you sit down to build something real.\nIf this was useful, explore the rest of the blog. We cover machine learning, deep learning, NLP, and the practical skills that turn understanding into building.\nOriginally published at\nhttps://fondralabs.com\n.",
  "metadata": {
    "title": "Dependency Parsing: How NLP Understands Sentence Structure - DEV Community",
    "description": "You now know what each word is. But do you know what each word does?  In the previous post, we... Tagged with ai, machinelearning, nlp.",
    "keywords": "ai, machinelearning, nlp, software, coding, development, engineering, inclusive, community",
    "author": null,
    "og:type": "article",
    "og:url": "https://dev.to/javiagu13/dependency-parsing-how-nlp-understands-sentence-structure-4mmd",
    "og:title": "Dependency Parsing: How NLP Understands Sentence Structure",
    "og:description": "You now know what each word is. But do you know what each word does?  In the previous post, we...",
    "og:site_name": "DEV Community",
    "og:image": "https://media2.dev.to/dynamic/image/width=1200,height=627,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fefawl9kq72djjbsy1grf.png",
    "twitter:site": "@thepracticaldev",
    "twitter:creator": "@",
    "twitter:title": "Dependency Parsing: How NLP Understands Sentence Structure",
    "twitter:description": "You now know what each word is. But do you know what each word does?  In the previous post, we...",
    "twitter:card": "summary_large_image",
    "twitter:widgets:new-embed-design": "on",
    "twitter:image:src": "https://media2.dev.to/dynamic/image/width=1200,height=627,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fefawl9kq72djjbsy1grf.png"
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 200,
    "error": ""
  },
  "code_blocks": [
    {
      "file": "attachments/a7f28f9f5699/code/body-000.txt",
      "chars": 167,
      "language": "text"
    },
    {
      "file": "attachments/a7f28f9f5699/code/body-001.txt",
      "chars": 118,
      "language": "text"
    }
  ],
  "images": [
    {
      "status": "ok",
      "url": "https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F629pqwfw2jlvfiyfikig.png",
      "bytes": 102460,
      "reused": true,
      "local_path": "attachments/a7f28f9f5699/images/001.png",
      "src": "https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F629pqwfw2jlvfiyfikig.png",
      "alt": "",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbdfcro3ju0wmqs83kjua.png",
      "bytes": 80318,
      "reused": true,
      "local_path": "attachments/a7f28f9f5699/images/002.png",
      "src": "https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbdfcro3ju0wmqs83kjua.png",
      "alt": "Dependency grammar maps every word to its head with a named relationship label",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnlc4l4crf7wfb4duet9t.png",
      "bytes": 107002,
      "reused": true,
      "local_path": "attachments/a7f28f9f5699/images/003.png",
      "src": "https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnlc4l4crf7wfb4duet9t.png",
      "alt": "Constituency parse tree vs dependency parse tree for the same sentence showing the structural difference",
      "downloaded": true
    },
    {
      "status": "ok",
      "url": "https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7kko90zbtam3ch47eouo.png",
      "bytes": 58710,
      "reused": true,
      "local_path": "attachments/a7f28f9f5699/images/004.png",
      "src": "https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7kko90zbtam3ch47eouo.png",
      "alt": "A dependency tree visualised as an arc diagram showing labelled relationships between words",
      "downloaded": true
    }
  ],
  "audio": [],
  "videos": [],
  "links": [
    {
      "href": "https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F629pqwfw2jlvfiyfikig.png",
      "label": "",
      "type": "a"
    },
    {
      "href": "https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbdfcro3ju0wmqs83kjua.png",
      "label": "",
      "type": "a"
    },
    {
      "href": "https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnlc4l4crf7wfb4duet9t.png",
      "label": "",
      "type": "a"
    },
    {
      "href": "https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7kko90zbtam3ch47eouo.png",
      "label": "",
      "type": "a"
    },
    {
      "href": "https://fondralabs.com/nlp-foundations.html",
      "label": "NLP Foundations",
      "type": "a"
    },
    {
      "href": "https://fondralabs.com/",
      "label": "Fondra Labs",
      "type": "a"
    },
    {
      "href": "https://fondralabs.com/blog/nlp-foundations/dependency-parsing-how-nlp-understands-sentence-structure.html",
      "label": "https://fondralabs.com",
      "type": "a"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-14T10:48:54Z",
  "source_url": "https://dev.to/javiagu13/dependency-parsing-how-nlp-understands-sentence-structure-4mmd",
  "papers": [],
  "actual_video_files": [],
  "body_chars": 11209,
  "expected_body_images": 4,
  "discovery_status": "ok",
  "delivery_status": "ok",
  "missing_reason": "",
  "raw_html": "attachments/a7f28f9f5699/pages/source.html",
  "local_html": "attachments/a7f28f9f5699/pages/article.html",
  "body_base_path": "attachments/a7f28f9f5699/pages/",
  "body_markdown_path": "attachments/a7f28f9f5699/pages/article.md"
}