Learn R Programming

SemNetCleaner (version 1.0.0)

word.check.wrapper: A Spell-checking wrapper

Description

A wrapper function to spell-check with menu options

Usage

word.check.wrapper(word, dictionary, context = NULL, tolerance = 1)

Arguments

word

Character. A word to get spell-checked

dictionary

A dictionary to look for word in (see examples). See SemNetDictionaries

context

Vector. Defaults to NULL. When a word is inside of a vector of words, then the vector can be input to provide context for whether this word is spelled correctly with other words. For example, "guinea" is spelled correctly but will not be in animals.dictionary. The vector can be input to determine if "guinea pig" or "guinea fowl" is meant by the participant. The word that is being checked will appear with "<<" and ">>" around it in the context of other words (e.g., bat dog fish <<guinea>> pig rat horse)

tolerance

Numeric. The distance tolerance set for automatic spell-correction purposes. This function uses the function stringdist to compute the Damerau-Levenshtein (DL) distance, which is used to determine potential best guesses.

Unique words (i.e., n = 1) that are within the (distance) tolerance are automatically output as best guess responses, which are then passed through word.check.wrapper. If there is more than one word that is within or below the distance tolerance, then these will be provided as potential options.

The recommended and default distance tolerace is tolerance = 1, which only spell corrects a word if there is only one word with a DL distance of 1.

Value

A menu will appear with several options. Here is what is returned with each option:

POTENTIAL RESPONSE

If a potential response is selected, then the input word is replaced with the potential response

ADD TO DICTIONARY

When selected, the input word will be added to the appendix dictionary (see append.dictionary). The input word will be returned

TYPE MY OWN

User will type their own response to replace the input word. If word is not in dictionary, then user will be prompted for whether they would like to add the word to their appendix dictionary (see append.dictionary). In all cases, the typed word will be returned

GOOGLE IT

"Googles" the response in question. A browser will open with the Google search terms: define "RESPONSE"

BAD RESPONSE

When selected, NA will be returned

BAD STRING

When selected, a vector of NA the length of the context vector will be returned

SKIP

When selected, input word will be returned

Examples

Run this code
# NOT RUN {
#word to check
word <- "goat"

# }
# NOT RUN {
#good response, should be SKIP or "goat"
word.check.wrapper(word, SemNetDictionaries::animals.dictionary)

#response needs to be checked
word.check.wrapper("gost", SemNetDictionaries::animals.dictionary)

#word in context
word.check.wrapper("guinea",SemNetDictionaries::animals.dictionary, c("bat fish guinea pig rat")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab