Learn R Programming

SemNetCleaner (version 1.0.0)

multi.word.check: Multi Word Checker Wrapper

Description

A wrapper function to spell-check responses that have more than one word in them

Usage

multi.word.check(string, dictionary, tolerance)

Arguments

string

Character. A string of words with a length = 1

dictionary

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

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

Either a spell-correctd response or the original response

Examples

Run this code
# NOT RUN {
#returns "guinea pig"
multi.word.check("guinea big", SemNetDictionaries::load.dictionaries("animals"), tolerance = 1)

#returns original response
multi.word.check("cat dog bear fish bull",
SemNetDictionaries::load.dictionaries("animals"), tolerance = 1)

# }

Run the code above in your browser using DataLab