add_tags: Add tags to documents

Description Usage Arguments Value Examples

View source: R/API.R

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

1
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

1
2
3
4
library(fastrtext)
tags <- list(c(1, 5), 0)
documents <- c("this is a text", "this is another document")
add_tags(documents = documents, tags = tags)

fastrtext documentation built on Oct. 30, 2019, 11:32 a.m.