The method correct.hyph can be used to alter objects of class kRp.hyphen.
correct.hyph(obj, word = NULL, hyphen = NULL, cache = TRUE)# S4 method for kRp.hyphen
correct.hyph(obj, word = NULL, hyphen = NULL, cache = TRUE)
An object of the same class as obj.
An object of class kRp.hyphen.
A character string,
the (possibly incorrectly hyphenated) word entry to be replaced with hyphen.
A character string,
the new manually hyphenated version of word. Mustn't contain
anything other than characters of word plus the hyphenation mark "-".
Logical, if TRUE,
the given hyphenation will be added to the sessions' hyphenation cache.
Existing entries for the same word will be replaced.
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.
if (FALSE) {
hyphenated.txt <- correct.hyph(hyphenated.txt, "Hilfe", "Hil-fe")
}
Run the code above in your browser using DataLab