cbind_morphological {udpipe} | R Documentation |
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
https://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", which)
Arguments
x |
a data.frame or data.table as returned by |
term |
the name of the field in |
which |
a character vector with names of morphological features to uniquely parse out. These features are one of the 24 lexical and grammatical properties of words defined at https://universaldependencies.org/u/feat/index.html. Possible values are:
See the examples. |
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
## 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")
## End(Not run)
f <- system.file(package = "udpipe", "dummydata", "traindata.conllu")
x <- udpipe_read_conllu(f)
x <- cbind_morphological(x, term = "feats")
f <- system.file(package = "udpipe", "dummydata", "traindata.conllu")
x <- udpipe_read_conllu(f)
x <- cbind_morphological(x, term = "feats",
which = c("Mood", "Gender", "VerbForm", "Polarity", "Polite"))
# extract all features from the feats column even if not present in the data
f <- system.file(package = "udpipe", "dummydata", "traindata.conllu")
x <- udpipe_read_conllu(f)
x <- cbind_morphological(x, term = "feats",
which = c("lexical", "inflectional_noun", "inflectional_verb"))