Learn R Programming

udpipe (version 0.8.11)

as_fasttext: Combine labels and text as used in fasttext

Description

Fasttext prepends a label or different labels to text using a special string (__label__). This function takes a character vector of text and prepends the labels alongside the special string.

Usage

as_fasttext(x, y, label = "__label__")

Value

a character vector of text where x and y are combined

Arguments

x

a character vector

y

a character vector of labels or a list of labels. y should be of the same length as x

label

the string to use to prepend to the label. Defaults to __label__

Examples

Run this code
as_fasttext(x = c("just a bit of txt", "example2", "more txt please", "more"), 
            y = c("pos", "neg", "neg", NA))
as_fasttext(x = c("just a bit of txt", "example2", "more txt please", "more"), 
            y = list(c("ok", "pos"), c("neg", "topic2"), "", NA))

Run the code above in your browser using DataLab