Transliterate English text using the Greek alphabet: Difference between revisions
No edit summary |
m (more double letter substitutions) |
||
Line 102: | Line 102: | ||
"""I was looking at some rhododendrons in my back garden, |
"""I was looking at some rhododendrons in my back garden, |
||
dressed in my khaki shorts, when the telephone rang. |
dressed in my khaki shorts, when the telephone rang. |
||
As I answered it, I cheerfully glimpsed that the July sun |
As I answered it, I cheerfully glimpsed that the July sun |
||
caused a fragment of black pine wax to ooze on the velvet quilt |
caused a fragment of black pine wax to ooze on the velvet quilt |
||
Line 110: | Line 110: | ||
const replacements = [ |
const replacements = [ |
||
"ch" => "χ", "th" => "θ", "ps" => "ψ", "ph" => "f", r"s(\W)" => s"ς\1", |
"ch" => "χ", "th" => "θ", "ps" => "ψ", "ph" => "f", r"s(\W)" => s"ς\1", |
||
"Ch" => "Χ", "Th" => "Θ", "Ps" => "Ψ", "Ph" => "F", " |
"Ch" => "Χ", "Th" => "Θ", "Ps" => "Ψ", "Ph" => "F", "ee" => "h", |
||
"ck" => "k", "rh" => "r", "kh" => "χ", "oo" => "w", "a" => "α", "b" => "β", |
|||
"d" => "δ", "e" => "ε", "f" => "φ", "g" => "γ", "h" => "η", "i" => "ι", |
"d" => "δ", "e" => "ε", "f" => "φ", "g" => "γ", "h" => "η", "i" => "ι", |
||
"j" => "ι", "l" => "λ", "m" => "μ", "n" => "ν", "o" => "ο", "p" => "π", |
"j" => "ι", "l" => "λ", "m" => "μ", "n" => "ν", "o" => "ο", "p" => "π", |
||
"q" => "κ", "r" => "ρ", "s" => "σ", "t" => "τ", "u" => "υ", "w" => "ω", |
"q" => "κ", "r" => "ρ", "s" => "σ", "t" => "τ", "u" => "υ", "w" => "ω", |
||
"x" => "ξ", "z" => "ζ", "A" => "Α", "B" => "Β", "D" => "Δ", "E" => "Ε", |
"x" => "ξ", "z" => "ζ", "A" => "Α", "B" => "Β", "D" => "Δ", "E" => "Ε", |
||
"F" => "Φ", "G" => "Γ", "H" => "Η", "I" => "Ι", "J" => "I", "L" => "Λ", |
"F" => "Φ", "G" => "Γ", "H" => "Η", "I" => "Ι", "J" => "I", "L" => "Λ", |
||
"M" => "Μ", "N" => "Ν", "O" => "Ο", "P" => "Π", "Q" => "Κ", "R" => "Ρ", |
"M" => "Μ", "N" => "Ν", "O" => "Ο", "P" => "Π", "Q" => "Κ", "R" => "Ρ", |
||
"S" => "Σ", "T" => "Τ", "U" => "Υ", "W" => "Ω", "X" => "Ξ", "Z" => "Ζ"] |
"S" => "Σ", "T" => "Τ", "U" => "Υ", "W" => "Ω", "X" => "Ξ", "Z" => "Ζ"] |
||
for txt in texts |
for txt in texts |
||
println("$txt\n=>") |
println("$txt\n=>") |
||
Line 126: | Line 127: | ||
println("$txt\n", "="^65) |
println("$txt\n", "="^65) |
||
end |
end |
||
</lang>{{out}} |
</lang>{{out}} |
||
<pre> |
|||
The quick brown fox jumped over the lazy dog. |
|||
=> |
|||
Θε κυιk βροων φοξ ιυμπεδ οvερ θε λαζy δογ. |
|||
================================================================= |
|||
I was looking at some rhododendrons in my back garden, |
|||
dressed in my khaki shorts, when the telephone rang. |
|||
As I answered it, I cheerfully glimpsed that the July sun |
|||
caused a fragment of black pine wax to ooze on the velvet quilt |
|||
laying in my patio. |
|||
=> |
|||
Ι ωας λωkινγ ατ σομε ροδοδενδρονς ιν μy βαk γαρδεν, |
|||
δρεσσεδ ιν μy χαkι σηορτς, ωηεν θε τελεφονε ρανγ. |
|||
Ας Ι ανσωερεδ ιτ, Ι χηρφυλλy γλιμψεδ θατ θε Iυλy συν |
|||
cαυσεδ α φραγμεντ οφ βλαk πινε ωαξ το ωζε ον θε vελvετ κυιλτ |
|||
λαyινγ ιν μy πατιο. |
|||
================================================================= |
|||
sphinx of black quartz, judge my vow. |
|||
=> |
|||
σφινξ οφ βλαk κυαρτζ, ιυδγε μy vοω. |
|||
================================================================= |
|||
</pre> |
|||
=={{header|Wren}}== |
=={{header|Wren}}== |
Revision as of 05:13, 17 June 2022
- Rules
A rather silly little task intended as a bit of fun as well as a simple exercise in text substitution. So, if you're a Greek speaker or an expert in ancient Greek, please don't take it too seriously!
As there isn't a one-to-one correspondence between the English and Greek alphabets, we need some rules:
Greek letter | Corresponding English letter(s) |
---|---|
alpha | a |
beta | b or v |
gamma | g |
delta | d |
epsilon | e (but not ee) |
zeta | z |
eta | h or ee (but not ch, kh, ph, rh or th) |
theta | th |
iota | i or j |
kappa | c, k, q or ck (but not ch and kh) |
lambda | l |
mu | m |
nu | n |
xi | x |
omicron | o (but not oo) |
pi | p (but not ph or ps) |
rho | r or rh |
sigma | s (but not ps) |
tau | t (but not th) |
upsilon | u or y |
phi | f or ph |
chi | ch or kh |
psi | ps |
omega | w or oo |
In the case of lower-case sigma, use ς when s is the final letter of an English word or σ otherwise.
Ignore Greek diacritics (accents and breathings) but use the same capitalization, spacing and punctuation as in the English text.
- Example
English: The quick brown fox jumped over the lazy dog.
Greek: Θε κυικ βροων φοξ ιυμπεδ οβερ θε λαζυ δογ.
- Task
Transliterate the following English text into Greek using the above rules:
I was looking at some rhododendrons in my back garden, dressed in my khaki shorts, when the telephone rang. As I answered it, I cheerfully glimpsed that the July sun caused a fragment of black pine wax to ooze on the velvet quilt laying in my patio.
If your language does not support the printing of non-ascii characters, then you can instead transliterate the following lower-case pangram:
sphinx of black quartz, judge my vow.
Just represent the Greek letters by their names in angle brackets. For example:
the dog => <theta><epsilon> <delta><omicron><gamma>
- Reference
- Metrics
- Counting
- Word frequency
- Letter frequency
- Jewels and stones
- I before E except after C
- Bioinformatics/base count
- Count occurrences of a substring
- Count how many vowels and consonants occur in a string
- Remove/replace
- XXXX redacted
- Conjugate a Latin verb
- Remove vowels from a string
- String interpolation (included)
- Strip block comments
- Strip comments from a string
- Strip a set of characters from a string
- Strip whitespace from a string -- top and tail
- Strip control codes and extended characters from a string
- Anagrams/Derangements/shuffling
- Word wheel
- ABC problem
- Sattolo cycle
- Knuth shuffle
- Ordered words
- Superpermutation minimisation
- Textonyms (using a phone text pad)
- Anagrams
- Anagrams/Deranged anagrams
- Permutations/Derangements
- Find/Search/Determine
- ABC words
- Odd words
- Word ladder
- Semordnilap
- Word search
- Wordiff (game)
- String matching
- Tea cup rim text
- Alternade words
- Changeable words
- State name puzzle
- String comparison
- Unique characters
- Unique characters in each string
- Extract file extension
- Levenshtein distance
- Palindrome detection
- Common list elements
- Longest common suffix
- Longest common prefix
- Compare a list of strings
- Longest common substring
- Find common directory path
- Words from neighbour ones
- Change e letters to i in words
- Non-continuous subsequences
- Longest common subsequence
- Longest palindromic substrings
- Longest increasing subsequence
- Words containing "the" substring
- Sum of the digits of n is substring of n
- Determine if a string is numeric
- Determine if a string is collapsible
- Determine if a string is squeezable
- Determine if a string has all unique characters
- Determine if a string has all the same characters
- Longest substrings without repeating characters
- Find words which contains all the vowels
- Find words which contains most consonants
- Find words which contains more than 3 vowels
- Find words which first and last three letters are equals
- Find words which odd letters are consonants and even letters are vowels or vice_versa
- Formatting
- Substring
- Rep-string
- Word wrap
- String case
- Align columns
- Literals/String
- Repeat a string
- Brace expansion
- Brace expansion using ranges
- Reverse a string
- Phrase reversals
- Comma quibbling
- Special characters
- String concatenation
- Substring/Top and tail
- Commatizing numbers
- Reverse words in a string
- Suffixation of decimal numbers
- Long literals, with continuations
- Numerical and alphabetical suffixes
- Abbreviations, easy
- Abbreviations, simple
- Abbreviations, automatic
- Song lyrics/poems/Mad Libs/phrases
- Mad Libs
- Magic 8-ball
- 99 Bottles of Beer
- The Name Game (a song)
- The Old lady swallowed a fly
- The Twelve Days of Christmas
- Tokenize
- Text between
- Tokenize a string
- Word break problem
- Tokenize a string with escaping
- Split a character string based on change of character
- Sequences
Julia
<lang ruby>const texts = [ """The quick brown fox jumped over the lazy dog.""", """I was looking at some rhododendrons in my back garden, dressed in my khaki shorts, when the telephone rang.
As I answered it, I cheerfully glimpsed that the July sun caused a fragment of black pine wax to ooze on the velvet quilt laying in my patio.""", """sphinx of black quartz, judge my vow."""]
const replacements = [
"ch" => "χ", "th" => "θ", "ps" => "ψ", "ph" => "f", r"s(\W)" => s"ς\1", "Ch" => "Χ", "Th" => "Θ", "Ps" => "Ψ", "Ph" => "F", "ee" => "h", "ck" => "k", "rh" => "r", "kh" => "χ", "oo" => "w", "a" => "α", "b" => "β", "d" => "δ", "e" => "ε", "f" => "φ", "g" => "γ", "h" => "η", "i" => "ι", "j" => "ι", "l" => "λ", "m" => "μ", "n" => "ν", "o" => "ο", "p" => "π", "q" => "κ", "r" => "ρ", "s" => "σ", "t" => "τ", "u" => "υ", "w" => "ω", "x" => "ξ", "z" => "ζ", "A" => "Α", "B" => "Β", "D" => "Δ", "E" => "Ε", "F" => "Φ", "G" => "Γ", "H" => "Η", "I" => "Ι", "J" => "I", "L" => "Λ", "M" => "Μ", "N" => "Ν", "O" => "Ο", "P" => "Π", "Q" => "Κ", "R" => "Ρ", "S" => "Σ", "T" => "Τ", "U" => "Υ", "W" => "Ω", "X" => "Ξ", "Z" => "Ζ"]
for txt in texts
println("$txt\n=>") for pair in replacements txt = replace(txt, pair) end println("$txt\n", "="^65)
end
</lang>
- Output:
The quick brown fox jumped over the lazy dog. => Θε κυιk βροων φοξ ιυμπεδ οvερ θε λαζy δογ. ================================================================= I was looking at some rhododendrons in my back garden, dressed in my khaki shorts, when the telephone rang. As I answered it, I cheerfully glimpsed that the July sun caused a fragment of black pine wax to ooze on the velvet quilt laying in my patio. => Ι ωας λωkινγ ατ σομε ροδοδενδρονς ιν μy βαk γαρδεν, δρεσσεδ ιν μy χαkι σηορτς, ωηεν θε τελεφονε ρανγ. Ας Ι ανσωερεδ ιτ, Ι χηρφυλλy γλιμψεδ θατ θε Iυλy συν cαυσεδ α φραγμεντ οφ βλαk πινε ωαξ το ωζε ον θε vελvετ κυιλτ λαyινγ ιν μy πατιο. ================================================================= sphinx of black quartz, judge my vow. => σφινξ οφ βλαk κυαρτζ, ιυδγε μy vοω. =================================================================
Wren
<lang ecmascript>import "./str" for Char, Greek
var English2Greek = Fn.new { |text|
// make appropriate substitutions using rarely used control characters // for Greek letters which have no single English letter equivalents var subs = [ ["v", "b"], ["j", "i"], ["y", "u"], ["ch", "\x01"], // chi (l/c) ["kh", "\x01"], // chi (l/c) ["ph", "f"], ["rh", "r"], ["th", "\x02"], // theta (l/c) ["Ch", "\x04"], // chi (u/c) ["Kh", "\x04"], // chi (u/c) ["Ph", "F"], ["Rh", "R"], ["Th", "\x05"], // theta (u/c) ["ee", "h"], ["ck", "q"], ["c", "q"], ["k", "q"], ["oo", "w"], ["ps", "\x03"], // psi(l/c) ["Ps", "\x06"], // psi(u/c) ["V", "B"], ["J", "I"], ["Y", "U"], ["CH", "\x04"], // chi (u/c) ["KH", "\x04"], // chi (u/c) ["PH", "F"], ["RH", "R"], ["TH", "\x05"], // theta (u/c) ["EE", "H"], ["CK", "Q"], ["C", "Q"], ["K", "Q"], ["OO", "W"], ["PS", "\x06"], // psi(u/c) ] for (sub in subs) text = text.replace(sub[0], sub[1])
// now look for final English lower case 's' and use 'DEL' to substitute for that var letters = text.toList for (i in 1...letters.count) { var c = letters[i] if ((Char.isWhitespace(c) || Char.isPunctuation(c)) && letters[i-1] == "s") { letters[i-1] = "\x7f" } }
// finally substitute the remaining English 'letters' with Greek ones // note that some of them look the same but are different codepoints var e2g = { "a": "α", "b": "β", "d": "δ", "e": "ε", "f": "φ", "g": "γ", "h": "η", "i": "ι", "l": "λ", "m": "μ", "n": "ν", "o": "ο", "p": "π", "q": "κ", "r": "ρ", "s": "σ", "t": "τ", "u": "υ", "w": "ω", "x": "ξ", "z": "ζ", "A": "Α", "B": "Β", "D": "Δ", "E": "Ε", "F": "Φ", "G": "Γ", "H": "Η", "I": "Ι", "L": "Λ", "M": "Μ", "N": "Ν", "O": "Ο", "P": "Π", "Q": "Κ", "R": "Ρ", "S": "Σ", "T": "Τ", "U": "Υ", "W": "Ω", "X": "Ξ", "Z": "Ζ", "\x01": "χ", "\x02": "θ", "\x03": "ψ", "\x7f": "ς", "\x04": "Χ", "\x05": "Θ", "\x06": "Ψ" }
var greek = List.filled(letters.count, null) for (i in 0...greek.count) { var c = letters[i] if (Char.isWhitespace(c) || Char.isPunctuation(c)) { greek[i] = c } else { greek[i] = e2g[letters[i]] } } return greek.join("")
}
var texts = [ "The quick brown fox jumped over the lazy dog.", """ I was looking at some rhododendrons in my back garden, dressed in my khaki shorts, when the telephone rang.
As I answered it, I cheerfully glimpsed that the July sun caused a fragment of black pine wax to ooze on the velvet quilt laying in my patio. """, "sphinx of black quartz, judge my vow." ] for (text in texts) {
System.print(text) System.print() System.print(English2Greek.call(text)) System.print("=" * 65)
} System.print("The last example using the names of the Greek letters instead:") var letters = Greek.names var alphabet = "αβγδεζηθικλμνξοπρςστυφχψω".codePoints.toList var e2gl = {} for (i in 0...alphabet.count) e2gl[String.fromCodePoint(alphabet[i])] = letters[i] var greek = English2Greek.call(texts[2]) var s = "" for (g in greek) {
var c if (Char.isWhitespace(g) || Char.isPunctuation(g)) { c = g } else { c = "<" + e2gl[g] + ">" } s = s + c
} System.print(s)</lang>
- Output:
The quick brown fox jumped over the lazy dog. Θε κυικ βροων φοξ ιυμπεδ οβερ θε λαζυ δογ. ================================================================= I was looking at some rhododendrons in my back garden, dressed in my khaki shorts, when the telephone rang. As I answered it, I cheerfully glimpsed that the July sun caused a fragment of black pine wax to ooze on the velvet quilt laying in my patio. Ι ωας λωκινγ ατ σομε ροδοδενδρονς ιν μυ βακ γαρδεν, δρεσσεδ ιν μυ χακι σηορτς, ωηεν θε τελεφονε ρανγ. Ας Ι ανσωερεδ ιτ, Ι χηρφυλλυ γλιμψεδ θατ θε Ιυλυ συν καυσεδ α φραγμεντ οφ βλακ πινε ωαξ το ωζε ον θε βελβετ κυιλτ λαυινγ ιν μυ πατιο. ================================================================= sphinx of black quartz, judge my vow. σφινξ οφ βλακ κυαρτζ, ιυδγε μυ βοω. ================================================================= The last example using the names of the Greek letters instead: <sigma><phi><iota><nu><xi> <omicron><phi> <beta><lambda><alpha><kappa> <kappa><upsilon><alpha><rho><tau><zeta>, <iota><upsilon><delta><gamma><epsilon> <mu><upsilon> <beta><omicron><omega>.