sylly (version 0.1-4)

correct.hyph: Correct kRp.hyphen objects

Description

The method correct.hyph can be used to alter objects of class kRp.hyphen-class.

Usage

correct.hyph(obj, word = NULL, hyphen = NULL, cache = TRUE)

# S4 method for kRp.hyphen correct.hyph(obj, word = NULL, hyphen = NULL, cache = TRUE)

Arguments

obj

An object of class kRp.hyphen-class.

word

A character string, the (possibly incorrectly hyphenated) word entry to be replaced with hyphen.

hyphen

A character string, the new manually hyphenated version of word. Mustn't contain anything other than characters of word plus the hyphenation mark "-".

cache

Logical, if TRUE, the given hyphenation will be added to the sessions' hyphenation cache. Existing entries for the same word will be replaced.

Value

An object of the same class as obj.

Details

Although hyphenation should turn out to be rather accurate, the algorithm does ususally produce some errors. If you want to correct for these flaws, this method can be of help, because it might prevent you from introducing new errors. That is, it will do some sanitiy checks before the object is actually manipulated and returned.

That is, correct.hyph checks whether word and hyphen are actually hyphenations of the same token before proceeding. If so, it will also recalculate the number of syllables and update the syll field.

If both word and hyphen are NULL, correct.hyph will try to simply recalculate the syllable count for each word, by counting the hyphenation marks (and adding 1 to the number). This can be usefull if you changed hyphenation some other way, e.g. in a spreadsheet GUI, but don't want to have to correct the syllable count yourself as well.

Examples

Run this code
# NOT RUN {
hyphenated.txt <- correct.hyph(hyphenated.txt, "Hilfe", "Hil-fe")
# }

Run the code above in your browser using DataCamp Workspace