Dependency parsing in R with UDPipe
As a follow-up to my previous post (POS-tagging in R with UDPipe), I explore the udpipe package further, focusing this time on dependency parsing. Dependency parsing is a process of analyzing the grammatical structure of sentences, establishing relationships between words in the sentences, and labeling these relationships using grammatical dependencies. Before you proceed, it is a good idea to become acquainted with the philosophy behind universal dependencies (UD).
Dependency parsing
Having access to the grammatical structure of a sentence is useful for a variety of NLP tasks, such as:
- Information extraction: Dependency parsing can be used to identify the relationships between words in a sentence and extract specific pieces of information. For example, you might use dependency parsing to identify the subject and object of a sentence, or to extract the names of people or organizations mentioned in the text.
- Text generation: Dependency parsing can be used to generate natural language text by determining the grammatical structure of a sentence and inserting words in the appropriate positions.
- Machine translation: Dependency parsing can be used to analyze the structure of sentences in one language and generate equivalent sentences in another language, which can be useful for machine translation tasks.
- Text classification: Dependency parsing can be used to extract features from text that can be used to classify text into different categories, such as sentiment analysis or topic classification.
- Text summarization: Dependency parsing can be used to identify the most important words or phrases in a sentence or document, which can be useful for text summarization tasks.
The pipeline
We are going to re-use some of the code of POS-tagging in R with UDPipe, namely the parts designed to:
- dowload and load the UDPipe language models with the
udpipe_download_model()andudpipe_load_model()functions; - annotate a candidate sentence with
udpipe_annotate()function.
The new part of the code involves submitting a candidate sentence and visualizing the tokens, POS tag, and dependencies with the powerful and versatile textplot package.
(Down)load the language model
# load the necessary packages
library(udpipe)
library(textplot)
# download a language model (english-ewt) and save its path
m_eng_ewt <- udpipe_download_model(language = "english-ewt")
m_eng_ewt_path <- m_eng_ewt$file_model
# load the selected language model
m_eng_ewt_loaded <- udpipe_load_model(file = m_eng_ewt_path)
Annotate a sentence
It is now time to parse a candidate sentence, which is “The dead air shapes the dead darkness, further away than seeing shapes the dead earth” (Faulkner, As I Lay Dying). The sentence is annotated and the output is converted into a data frame.
sentence <- udpipe::udpipe_annotate(m_eng_ewt_loaded, x = "The dead air shapes the dead darkness, further away than seeing shapes the dead earth.")
%>%
as.data.frame()
You can inspect the annotated sentence with head(sentence). I do not do it here because the output is too wide.
Plot the dependencies
To plot the dependencies, we use the textplot_dependencyparser() function of the textplot package.
textplot_dependencyparser(sentence, size = 3)

english-ewt modelThe two arguments are: the annotated sentence (sentence) and the label size (size).
Interpreting the graph
Bear in mind that UD treebanks are annotated with grammatical dependencies between the words in a sentence. In UD, each word is assigned a dependency relation to one of the other words in the sentence. The word that the relation is pointing to is called the head of the relation, and the word that the relation is coming from is called the dependent.
To understand dependencies, you need to refer to an inventory of dependencies. I recommend this one, adapted from de Marneffe et al (2014). The nature of each dependency is spelled out in red. In the above sentence, we have:
detdetermineramodadjectival modifiernsubjnominal subjectobjobjectpunctpunctuationadvmodadverbial modifieradvcladverbial clause modifiercsubjclausal subjectmarkmarker
To assess how well the parser performed, it is also a good idea to know what goes on in the sentence. Here, the first occurrence of the verb shapes is the root of the first clause and the second occurrence of the same verb is the root of the second clause. The first clause says that dead air is shaping dead darkness and the second clause says that the nominalized verb seeing is shaping dead earth. In the first clause, The determines the noun air and dead is an adjective modifying air and darkness. Air is the subject of the verb shapes, and darkness is the object. In the second clause, the adverb further modifies the adverb away. Both adverbs modify the verb shape. Than is here tagged as a ‘marker’ (mark). The arc from than to shapes signals that it is a subordinating conjunction. Seeing is the subject of the verb shapes and earth is the object. Although picky grammarians may propose alternative taggings and parsings, we can say that english-ewt has done a reasonably good job.
Choosing the right language model
You must match the model to the text data that you work with. On top of english-ewt, there are three other models that are worth considering for English: english-gum, english-lines, and english-partut. They are trained on different datasets and may have slightly different performance characteristics. Here is a brief overview of each model:
english-ewtis trained on the English Web Treebank (EWT), which is a collection of sentences from the web;english-gumis trained on the GUM Corpus, which is a large, manually annotated corpus of English that includes a wide range of text types and genres;english-linesis trained on the LINES Corpus, which is a collection of sentences from the web;english-partutis trained on the ParTUT Corpus, which is originally a collection of Italian sentences. It has been adapted for use with English text by applying cross-lingual transfer learning techniques.
If you are working with a specific type of text (e.g., web text, news articles, etc.), you may want to choose a model that was trained on a similar dataset, e.g., english-ewt or english-lines. If you are working with a mix of text types, you may want to choose a more general-purpose model, e.g., english-gum.
Having said that, no parser is perfect. The graph below is based on english-gum, which is a priori the best model for a Faulkner sentence. Surprisingly, the parser has misinterpreted the grammatical status of the second occurrence of shapes, which it considers a noun instead of a verb. This error comes from the fact that, on the surface, shapes can be considered a noun or a verb.

english-gum modelThe same problem appears with english-lines…

english-lines model… and english-partut.

english-partut modelThere are therefore three solutions: (a) compare parsers on a series of test sentences and choose the one that performs best, (b) accept that your parser will generate a certain amount of wrong tags and dependencies, or (c) train your own model on your specific data, a feature also offered by the udpipe package.
References
De Marneffe, M. C., Dozat, T., Silveira, N., Haverinen, K., Ginter, F., Nivre, J., & Manning, C. D. (2014). Universal Stanford dependencies: A cross-linguistic typology. In Proceedings of the Ninth International Conference on Language Resources and Evaluation (LREC’14) (pp. 4585-4592).
Nivre, J, de Marneffe, M.C., Ginter, F., Hajič, J., Manning, C.D., Pyysalo, S., Schuster, S., Tyers, F., and Zeman, D. 2020. Universal Dependencies v2: An Evergrowing Multilingual Treebank Collection. In Proceedings of the Twelfth Language Resources and Evaluation Conference, pp. 4034–4043, Marseille, France. European Language Resources Association.
(Cover image generated with Nano Banana 2)
The text only may be used under licence Creative Commons Attribution Non Commercial 4.0 International. All other elements (illustrations, imported files) are “All rights reserved”, unless otherwise stated.
OpenEdition suggests that you cite this post as follows:
Guillaume Desagulier (December 20, 2022). Dependency parsing in R with UDPipe. Around the word. Retrieved May 20, 2026 from https://doi.org/10.58079/n4vc


orcid.org/0000-0003-4895-0788