cbind_dependencies {udpipe}R Documentation

Add the dependency parsing information to an annotated dataset

Description

Annotated results of udpipe_annotate contain dependency parsing results which indicate how each word is linked to another word and the relation between these 2 words.
This information is available in the fields token_id, head_token_id and dep_rel which indicates how each token is linked to the parent. The type of relation (dep_rel) is defined at http://universaldependencies.org/u/dep/index.html. For example in the text 'The economy is weak but the outlook is bright', the term economy is linked to weak as the term economy is the nominal subject of weak.
This function adds the parent information to the annotated data.frame.

Usage

cbind_dependencies(x, type = c("parent", "child"))

Arguments

x

a data.frame or data.table as returned by as.data.frame(udpipe_annotate(...))

type

currently only possible value is 'parent', indicating to add the information of the head_token_id to the dataset

Details

Mark that the output which this function provides might possibly change in subsequent releases and is experimental.

Value

a data.frame/data.table in the same order of x where the token/lemma/upos/xpos information of the parent (head dependency) is added to the data.frame. See the examples.

Examples

## Not run: 
udmodel <- udpipe_download_model(language = "english-ewt")
udmodel <- udpipe_load_model(file = udmodel$file_model)
x <- udpipe_annotate(udmodel, 
                     x = "The economy is weak but the outlook is bright")
x <- as.data.frame(x)
x[, c("token_id", "token", "head_token_id", "dep_rel")]
x <- cbind_dependencies(x, type = "parent")
nominalsubject <- subset(x, dep_rel %in% c("nsubj"))
nominalsubject <- nominalsubject[, c("dep_rel", "token", "token_parent")]
nominalsubject

## End(Not run)

[Package udpipe version 0.8.3 Index]