languagetool: LanguageTool API function

View source: R/langtool_function.R

lato_quick_setupR Documentation

LanguageTool API function

Description

Provides a wrapper for the LanguageTool CLI tool for spelling, grammar and language checking. lato_quick_setup provides an easy option to automatically download LanguageTool.

Usage

lato_quick_setup(path = "~", overwrite = FALSE, timeout = 300)

languagetool(
  x = c(),
  input_file = NA_character_,
  input_directory = NA_character_,
  recursive = FALSE,
  executable = lato_get_default_executable(),
  encoding = "utf-8",
  linebreak_paragraph = FALSE,
  language = "en-GB",
  list_languages = FALSE,
  auto_detect_language = FALSE,
  mothertongue = NA_character_,
  disabled_rules = c(),
  enabled_rules = c(),
  enabled_only = FALSE,
  disabled_categories = c(),
  enabled_categories = c(),
  tagger_only = FALSE,
  list_unknown = FALSE,
  bitext = FALSE,
  profile = FALSE,
  verbose = FALSE,
  version = FALSE,
  apply = FALSE,
  rule_file = NA_character_,
  remote_rules_file = NA_character_,
  false_friends_file = NA_character_,
  bitext_rules_file = NA_character_,
  language_model_directory = NA_character_,
  fast_text_model_file = NA_character_,
  fast_text_binary_file = NA_character_,
  line_by_line = FALSE,
  enable_temp_off = FALSE,
  clean_overlapping = FALSE,
  level = NA_character_,
  quiet = FALSE
)

lato_list_languages(executable = lato_get_default_executable())

lato_get_version(executable = lato_get_default_executable())

lato_test_setup(executable = lato_get_default_executable())

lato_get_default_executable()

Arguments

path

Path. Directory where LanguageTool should be installed.

overwrite

Logical. Should the user not be asked whether she would like to overwrite an already available LanguageTool installation? (Default: FALSE)

timeout

Integer. Maximum download time in seconds. See ?utils::download.file

x

Character vector. Text to analyse

input_file

Path. File to analyse (instead of x)

input_directory

Path. Directory with files to analyse (instead of x). Maybe recursive = TRUE is necessary

recursive

Logical. Work recursively on directory, not on a single file

executable

Character. Path to the languagetool executable on your system

encoding

Character. Character set of the input text, e.g. utf-8 or latin1

linebreak_paragraph

Logical. Assume that a single line break marks the end of a paragraph

language

Character. The language code of the text, e.g. en for English, en-GB for British English

list_languages

Logical. Print all available languages and exit

auto_detect_language

Logical. Auto-detect the language of the input text - note this will not detect variants like 'English (US)', so you will not get spell checking for languages with variants

mothertongue

Character. The language code of your first language, used to activate false-friend checking

disabled_rules

Character vector. List of rule ids to be disabled

enabled_rules

Character vector. List of rule ids to be enabled

enabled_only

Logical. Disable all rules except those enabled explicitly

disabled_categories

Character vector. List of category ids to be disabled

enabled_categories

Character vector. List of category ids to be enabled

tagger_only

Logical. Don't check, but only print text analysis (sentences, part-of-speech tags)

list_unknown

Logical. Also print a summary of words from the input that LanguageTool doesn't know

bitext

Logical. Check bilingual texts with a tab-separated input file, see http://languagetool.wikidot.com/checking-translations-bilingual-texts

profile

Logical. Print performance measurements

verbose

Logical. Print text analysis (sentences, part-of-speech tags)

version

Logical. Print LanguageTool version number

apply

Logical. Automatically apply suggestions if available, printing result. NOTE: only use with very robust rules, as this will otherwise introduce new errors

rule_file

Path. Use an additional grammar file; if the filename contains a known language code, it is used in addition of standard rules

remote_rules_file

Path. Configure rules depending on external services via a JSON file (optional)

false_friends_file

Path. Use external false friend file to be used along with the built-in rules

bitext_rules_file

Path. Use external bitext XML rule file (useful only in bitext mode)

language_model_directory

Path. A directory with e.g. 'en' sub directory (i.e. a language code) that contains '1grams'...'3grams' sub directories with Lucene indexes with ngram occurrence counts; activates the confusion rule if supported; see https://dev.languagetool.org/finding-errors-using-n-gram-data

fast_text_model_file

Path. fasttext language detection model (optional), see https://fasttext.cc/docs/en/language-identification.html

fast_text_binary_file

Path. fasttext executable (optional), see https://fasttext.cc/docs/en/support.html

line_by_line

Logical. Work on file line by line (for development, e.g. inside an IDE)

enable_temp_off

Logical. Enable all temp_off rules (for testing and development)

clean_overlapping

Logical. Clean overlapping matches (show only the highest priority match)

level

Character. Enable the given level (currently only 'PICKY')

quiet

Logical. Should the console output of languagetool be displayed or hidden?

Value

A tibble (data.frame) with the output of languagetool parsed from json. Some options yield special outputs

Examples


# install LanguageTool if it is not already available
if (!LanguageToolR::lato_test_setup()) {
  LanguageToolR::lato_quick_setup(overwrite = TRUE)
}

# apply LanguageTool checks to some test text
languagetool(test_text)



nevrome/LanguageToolR documentation built on Oct. 12, 2024, 1:36 a.m.