fastrtext (version 0.3.3)

add_tags: Add tags to documents

Description

Add tags in the `fastText`` format. This format is require for the training step. As fastText doesn't support newlines inside documents (as newlines are delimiting documents) this function also ensures that there are absolutely no new lines. By default new lines are replaced by a single space.

Usage

add_tags(documents, tags, prefix = "__label__", new_lines = " ")

Arguments

documents

texts to learn

tags

labels provided as a list or a vector. There can be 1 or more per document.

prefix

character to add in front of tag (fastText format)

new_lines

Character that replaces new lines (\r\n), default is space.

Value

character ready to be written in a file

Examples

Run this code
# NOT RUN {
library(fastrtext)
tags <- list(c(1, 5), 0)
documents <- c("this is a text", "this is another document")
add_tags(documents = documents, tags = tags)

# }

Run the code above in your browser using DataCamp Workspace