Learn R Programming

udpipe (version 0.8.3)

cbind_morphological: Add morphological features to an annotated dataset

Description

The result of udpipe_annotate which is put into a data.frame returns a field called feats containing morphological features as defined at http://universaldependencies.org/u/feat/index.html. If there are several of these features, these are concatenated with the | symbol. This function extracts each of these morphological features separately and adds these as extra columns to the data.frame

Usage

cbind_morphological(x, term = "feats")

Arguments

x

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

term

the name of the field in x which contains the morphological features. Defaults to 'feats'.

Value

x in the same order with extra columns added (at least the column has_morph is added indicating if any morphological features are present and as well extra columns for each possible morphological feature in the data)

Examples

Run this code
# 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 <- cbind_morphological(x, term = "feats")
# }
# NOT RUN {
f <- system.file(package = "udpipe", "dummydata", "traindata.conllu")
x <- udpipe_read_conllu(f)
x <- cbind_morphological(x, term = "feats")
# }

Run the code above in your browser using DataLab