Skip to content

Common Lisp library for Cyrillic->Latin and Latin->Cyrillic transliteration.

License

Notifications You must be signed in to change notification settings

aartaka/cl-translit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cl-translit – Common Lisp Cyrillic/Latin alphabet transliteration library

This is a small utility to transliterate Cyrillic text to Latin alphabet and transliterate it back to Cyrillics. The only encoding supported at the moment is cur2url, the code for which is basically rewritten line-by-line from Python (see translit).

Getting Started

Clone the repo to somewhere ASDF can discover it:

# This implies that ~/common-lisp/ is reachable for ASDF
git clone https://github.com/aartaka/cl-translit ~/common-lisp/cl-translit

Then do (asdf:load-system :cl-translit).

And you’re good to go! Get your first transliteration there:

(translit:cyr-to-url "Зевес тогді кружав сивуху і оселедцем заїдав;")
;; => "Zeves toghdi kruzhav syvukhu i oseledcem zajidav;"

Functions

cyr2url (aliases: cyr-to-url, cyr->url)

Arglist is

string &key (consonants *consonants*) (softeners *softeners*) (vowels *vowels*)
         (additional-translations nil)
         (apostrophe-char *apostrophe-char*) (stop-char *stop-char*)
         (dictionary (build-encode-dict consonants softeners vowels
                                        additional-translations apostrophe-char stop-char))  

Docstring:

Translate a Cyrillic text to Latin URL-compatible text.

CONSONANTS, SOFTENERS, VOWELS, and ADDITIONAL-TRANSLATIONS should be alists from Cyrillic characters to Latinic ones. Default values are `*consonants*`, `*softeners*`, `*vowels*`, and nil respectively. APOSTROPHE-CHAR and STOP-CHAR are characters/strings to insert in special cases. Defaults to `*apostrophe-char*’ and `*stop-char*’. See the respective documentation for when those are inserted.

url2cyr (aliases: url-to-cyr, url->cyr)

Arglist is

string &key (consonants *consonants*) (softeners *softeners*) (vowels *vowels*)
         (additional-translations nil)
         (apostrophe-char *apostrophe-char*) (stop-char *stop-char*)
         (dictionary (build-decode-dict consonants softeners vowels
                                        additional-translations apostrophe-char stop-char))  

Docstring:

Translate a Latin URL-compatible text to Cyrillic text.

Arguments are the same as for `cyr2url’, except that DICTIONARY should be a decoding dictionary (see `build-decode-dict’).

build-(decode|encode)-dict

Those simply build a dictionary (hash-table) out of the argument they are provided. As you seen earlier, those are used in en/decoding functions. See the respective docstrings for argument explanations.

About

Common Lisp library for Cyrillic->Latin and Latin->Cyrillic transliteration.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published