Learn R Programming

RBERT (version 0.1.11)

convert_single_example: Convert a single InputExample into a single InputFeatures

Description

Converts a single InputExample into a single InputFeatures.

Usage

convert_single_example(
  ex_index,
  example,
  label_list,
  max_seq_length,
  tokenizer
)

Arguments

ex_index

Integer; the index of this example. This is used to determine whether or not to print out some log info (for debugging or runtime confirmation). It is assumed this starts with 1 (in R).

example

The InputExample to convert.

label_list

Character (or integer); allowed labels for these examples.

max_seq_length

Integer; the maximum number of tokens that will be considered together.

tokenizer

A tokenizer object to use (e.g. object of class FullTokenizer).

Value

An object of class InputFeatures.

Examples

Run this code
# NOT RUN {
tokenizer <- FullTokenizer("vocab.txt")
input_ex <- InputExample(
  guid = 1L,
  text_a = "Some text to classify.",
  text_b = "More wordy words.",
  label = "good"
)
feat <- convert_single_example(
  ex_index = 1L,
  example = input_ex,
  label_list = c("good", "bad"),
  max_seq_length = 15L,
  tokenizer = tokenizer
)
# }

Run the code above in your browser using DataLab