A Common Lisp library for converting between Beta Code & polytonic Greek

Stanislav Kondratyev feafa5d3e2 New implementation 3 anos atrás
bcgreek feafa5d3e2 New implementation 3 anos atrás
cli feafa5d3e2 New implementation 3 anos atrás
zsh f4885b620a zsh completion 6 anos atrás
.gitignore f28607a084 .gitignore added 7 anos atrás
README.md feafa5d3e2 New implementation 3 anos atrás
bcgreek.asd feafa5d3e2 New implementation 3 anos atrás

README.md

cl-bcgreek

cl-bcgreek is a Common Lisp library for converting between Beta Code & polytonic Greek. It should work on Unicode-aware implementations where character codes coincide with Unicode code points.

The library defines the system bcgreek & bcgreek/cli. The system bcgreek defines the package BCGREEK exporting the function BCGREEK. The system bcgreek/cli defines the package BCGREEK/CLI exporting the function MAIN.

Function BCGREEK:BCGREEK-DECODE

Syntax:

bcgreek-decode string &key  (string &key (start 0) end (auto-final-sigma t) (j-sigma t) (case :ignore)) => resulting-string

Arguments & Values:

string ―a string.

start, end ―bounding index designators of string.

auto-final-sigma, j-sigma ―generalized booleans.

case one of :IGNORE, :UPPER, :LOWER

Description:

The function converts string from the Beta Code encoding into precombined polytonic Greek.

If auto-final-sigma is true (the default), ‘s’ is automatically converted into the medial or final sigma depending on its position in the word, otherwise it is always converted into the medial sigma.

If j-sigma is true (the default), ‘j’ is converted into the final sigma.

If case is :IGNORE, the conversion is case-insensitive. If it is :UPPER (resp. :LOWER), only uppercase (resp. lowercase) letters are converted.

The conversion is performed according to the following rules:

a -> alpha               t -> tau
b -> beta                u -> upsilon
g -> gamma               f -> phi
d -> delta               x -> chi
e -> epsilon             y -> psi                      
z -> zeta                w -> omega
h -> eta                 v -> digamma
q -> theta               ) -> smooth breathing
i -> iota                ( -> rough breathing
k -> kappa               / -> acute accent
l -> lambda              \\ -> grave accent           
m -> mu                  = -> circumflex accent
n -> nu                  | -> iota subscript/adscript
c -> xi                  : -> middle dot                
o -> omicron             ' -> apostrophe U+2019
p -> pi                  - -> hyphen U+2010
r -> rho                 _ -> em-dash U+2014
s -> sigma               * -> capital letter
j -> final sigma         
s1 -> medial sigma               
s2 -> final sigma               
s3 -> lunate sigma               

Unprocessed characters remain unaffected.

Examples:

(bcgreek-decode "mh=nin a)/eide qea\\ *phlhi+a/dew *)axilh=os")
    => "μῆνιν ἄειδε θεὰ Πηληϊάδεω Ἀχιλῆος"
(bcgreek-decode "*pro/s 123" nil) => "Πρόσ 123"

Side Effects:

None.

Affected By:

None.

Exceptional Situations:

Should be prepared to signal an error of type type-error if string is not a string or if start is not a fixnum or if end is not either fixnum or nil. Should be prepared to signal an error of type simple-error in the case of invalid bounding index designators.

Notes:

None.

Function BCGREEK/CLI:MAIN

The function provides a command line interface to BCGREEK:BCGREEK. Its argument is a list of command line options.

The following options are supported:

--final-sigma -s                boolean  Do not automatically convert S into final sigma
--file -f                       string   Input file; if this option is missing, standard input is
                                       used
--string -x                     string   Process string
--output -o                     string   Output file; if this option is missing, standard output
                                       is used
--help -h                       boolean  Display this help and exit