set.hyph.support: Add support for new languages

Description Usage Arguments Details Hyphenation patterns Examples

View source: R/set.hyph.support.R

Description

You can use this function to add new languages to be used with sylly.

Usage

1

Arguments

value

A named list that upholds exactly the structure defined above.

Details

Language support in this package is designed to be extended easily. You could call it modular, although it's actually more "environemntal", but nevermind.

To add new language support, say for Xyzedish, you basically have to call this function once and provide respective hyphenation patterns. If you would like to re-use this language support, you should consider making it a package.

If it succeeds, it will fill an internal environment with the information you have defined. hyphen will then know which language patterns are available as data files (which you must provide also).

You provide the meta data as a named list. It usually has one single entry to tell the new language abbreviation, e.g., set.hyph.support(list("xyz"="xyz")). However, this will only work if a) the language support script is a part of the sylly package itself, and b) the hyphen pattern is located in its data subdirectory.

For your custom hyphenation patterns to be found automatically, provide it as the value in the named list, e.g., set.hyph.support(list("xyz"=hyph.xyz)). This will directly add the patterns to sylly's environment, so it will be found when hyphenation is requested for language "xyz".

If you would like to provide hyphenation as part of a third party language package, you must name the object hyph.<lang>, save it to your package's data subdirectory named hyph.<lang>.rda, and append package="<yourpackage>" to the named list; e.g., set.hyph.support(list("xyz"=c("xyz", package="koRpus.lang.xyz")). Only then sylly will look for the pattern object in your package, not its own data directory.

Hyphenation patterns

To be able to also do syllable count with the newly added language, you should add a hyphenation pattern file as well. Refer to the documentation of read.hyph.pat() to learn how to produce a pattern object from a downloaded hyphenation pattern file. Make sure you use the correct name scheme (e.g. "hyph.xyz.rda") and good compression.

Examples

1
2
3
4
5
6
## Not run: 
set.hyph.support(
  list("xyz"="xyz")
)

## End(Not run)

sylly documentation built on Sept. 20, 2020, 9:07 a.m.