Learn R Programming

arete (version 0.1)

check_lang: Check if text is language-appropriate

Description

Many, if not all, large language models are biased to English terms and sentence constructions. This function performs a quick check with cld2 over every element of a string of characters and returns whether it is mostly (75

Usage

check_lang(strings, detailed = FALSE)

Value

logical. If TRUE the language of the string is mostly English. If detailed is TRUE a list is instead returned for the full document.

Arguments

strings

character. Vector of strings containing document sentences.

detailed

bool. If TRUE, the full cld2 report is returned as well.

Examples

Run this code
# English 
check_lang("Species Macrothele calpeiana is found in Alentejo.")

# Portuguese
check_lang("A espécie Macrothele calpeiana é encontrada no Alentejo.")

Run the code above in your browser using DataLab