Predict Text Label Using Flair Classifier
Value
A list containing:
- label
Character string of predicted label
- score
Numeric confidence score from classifier
- token_number
Integer count of tokens in input text
Examples
if (FALSE) { # \dontrun{
# Example 1: Using text input
classifier <- flair_models()$TextClassifier$load('stance-classifier')
result1 <- predict_label(
text = "I strongly support this policy",
classifier = classifier
)
# Example 2: Using pre-created and tagged sentence
sent <- Sentence("I love Berlin and New York.")
tagger <- flair_models()$SequenceTagger$load('pos')
tagger$predict(sent)
print(sent) # Shows tokens with POS tags
result2 <- predict_label(
text = NULL,
classifier = classifier,
sentence = sent
)
} # }