forked from GitHub/gf-core
Replace tabs for whitespace in source code
This commit is contained in:
@@ -17,7 +17,7 @@ import qualified Data.Map as Map
|
||||
-- to add a new one: define the Unicode range and the corresponding ASCII strings,
|
||||
-- which may be one or more characters long
|
||||
|
||||
-- conventions to be followed:
|
||||
-- conventions to be followed:
|
||||
-- each character is either [letter] or [letter+nonletters]
|
||||
-- when using a sparse range of unicodes, mark missing codes as "-" in transliterations
|
||||
-- characters can be invisible: ignored in translation to unicode
|
||||
@@ -33,7 +33,7 @@ transliterateWithFile name src isFrom =
|
||||
(if isFrom then appTransFromUnicode else appTransToUnicode) (getTransliterationFile name src)
|
||||
|
||||
transliteration :: String -> Maybe Transliteration
|
||||
transliteration s = Map.lookup s allTransliterations
|
||||
transliteration s = Map.lookup s allTransliterations
|
||||
|
||||
allTransliterations = Map.fromList [
|
||||
("amharic",transAmharic),
|
||||
@@ -67,25 +67,25 @@ data Transliteration = Trans {
|
||||
}
|
||||
|
||||
appTransToUnicode :: Transliteration -> String -> String
|
||||
appTransToUnicode trans =
|
||||
appTransToUnicode trans =
|
||||
concat .
|
||||
map (\c -> maybe c (return . toEnum) $
|
||||
Map.lookup c (trans_to_unicode trans)
|
||||
) .
|
||||
filter (flip notElem (invisible_chars trans)) .
|
||||
) .
|
||||
filter (flip notElem (invisible_chars trans)) .
|
||||
unchar
|
||||
|
||||
appTransFromUnicode :: Transliteration -> String -> String
|
||||
appTransFromUnicode trans =
|
||||
appTransFromUnicode trans =
|
||||
concat .
|
||||
map (\c -> maybe [toEnum c] id $
|
||||
map (\c -> maybe [toEnum c] id $
|
||||
Map.lookup c (trans_from_unicode trans)
|
||||
) .
|
||||
) .
|
||||
map fromEnum
|
||||
|
||||
|
||||
mkTransliteration :: String -> [String] -> [Int] -> Transliteration
|
||||
mkTransliteration name ts us =
|
||||
mkTransliteration name ts us =
|
||||
Trans (Map.fromList (tzip ts us)) (Map.fromList (uzip us ts)) [] name
|
||||
where
|
||||
tzip ts us = [(t,u) | (t,u) <- zip ts us, t /= "-"]
|
||||
@@ -102,7 +102,7 @@ getTransliterationFile name = uncurry (mkTransliteration name) . codes
|
||||
|
||||
unchar :: String -> [String]
|
||||
unchar s = case s of
|
||||
c:d:cs
|
||||
c:d:cs
|
||||
| isAlpha d -> [c] : unchar (d:cs)
|
||||
| isSpace d -> [c]:[d]: unchar cs
|
||||
| otherwise -> let (ds,cs2) = break (\x -> isAlpha x || isSpace x) cs in
|
||||
@@ -122,8 +122,8 @@ transThai = mkTransliteration "Thai" allTrans allCodes where
|
||||
allCodes = [0x0e00 .. 0x0e7f]
|
||||
|
||||
transDevanagari :: Transliteration
|
||||
transDevanagari =
|
||||
(mkTransliteration "Devanagari"
|
||||
transDevanagari =
|
||||
(mkTransliteration "Devanagari"
|
||||
allTransUrduHindi allCodes){invisible_chars = ["a"]} where
|
||||
allCodes = [0x0900 .. 0x095f] ++ [0x0966 .. 0x096f]
|
||||
|
||||
@@ -136,13 +136,13 @@ allTransUrduHindi = words $
|
||||
"- - - - - - - - q x g. z R R' f - " ++
|
||||
"N0 N1 N2 N3 N4 N5 N6 N7 N8 N9 "
|
||||
|
||||
|
||||
|
||||
transUrdu :: Transliteration
|
||||
transUrdu =
|
||||
transUrdu =
|
||||
(mkTransliteration "Urdu" allTrans allCodes) where
|
||||
allCodes = [0x0622 .. 0x062f] ++ [0x0630 .. 0x063a] ++ [0x0641,0x0642] ++ [0x06A9] ++ [0x0644 .. 0x0648] ++
|
||||
allCodes = [0x0622 .. 0x062f] ++ [0x0630 .. 0x063a] ++ [0x0641,0x0642] ++ [0x06A9] ++ [0x0644 .. 0x0648] ++
|
||||
[0x0654,0x0658,0x0679,0x067e,0x0686,0x0688,0x0691,0x0698,0x06af,0x06c1,0x06c3,0x06cc,0x06ba,0x06be,0x06d2] ++
|
||||
[0x06f0 .. 0x06f9] ++ [0x061f,0x06D4]
|
||||
[0x06f0 .. 0x06f9] ++ [0x061f,0x06D4]
|
||||
allTrans = words $
|
||||
"A - w^ - y^ a b - t C j H K d " ++ -- 0622 - 062f
|
||||
"Z r z s X S Z- t- z- e G " ++ -- 0630 - 063a
|
||||
@@ -151,22 +151,22 @@ transUrdu =
|
||||
"N0 N1 N2 N3 N4 N5 N6 N7 N8 N9 " ++ "? ."
|
||||
|
||||
transSindhi :: Transliteration
|
||||
transSindhi =
|
||||
transSindhi =
|
||||
(mkTransliteration "Sindhi" allTrans allCodes) where
|
||||
allCodes = [0x062e] ++ [0x0627 .. 0x062f] ++ [0x0630 .. 0x063a] ++ [0x0641 .. 0x0648] ++
|
||||
[0x067a,0x067b,0x067d,0x067e,0x067f] ++ [0x0680 .. 0x068f] ++
|
||||
[0x0699,0x0918,0x06a6,0x061d,0x06a9,0x06af,0x06b3,0x06bb,0x06be,0x06f6,0x064a,0x06b1, 0x06aa, 0x06fd, 0x06fe] ++
|
||||
[0x06f0 .. 0x06f9] ++ [0x061f,0x06D4]
|
||||
[0x06f0 .. 0x06f9] ++ [0x061f,0x06D4]
|
||||
allTrans = words $
|
||||
"K a b - t C j H - d " ++ -- 0626 - 062f
|
||||
"Z r z s X S Z- t- z- e G " ++ -- 0630 - 063a
|
||||
"f q - L m n - W " ++ -- 0641 - 0648
|
||||
"T! B T p T' " ++ -- 067a,067b,067d,067e,067f
|
||||
"B' - - Y' J' - c c' - - d! - d' D - D' " ++ -- 0680 - 068f
|
||||
"R - F' - k' g G' t' h' e' y c! k A M " ++ -- 0699, 0918, 06a6, 061d, 06a9,06af,06b3,06bb,06be,06f6,06cc,06b1
|
||||
"R - F' - k' g G' t' h' e' y c! k A M " ++ -- 0699, 0918, 06a6, 061d, 06a9,06af,06b3,06bb,06be,06f6,06cc,06b1
|
||||
"N0 N1 N2 N3 N4 N5 N6 N7 N8 N9 " ++ "? ."
|
||||
|
||||
|
||||
|
||||
|
||||
transArabic :: Transliteration
|
||||
transArabic = mkTransliteration "Arabic" allTrans allCodes where
|
||||
@@ -175,8 +175,8 @@ transArabic = mkTransliteration "Arabic" allTrans allCodes where
|
||||
"W r z s C S D T Z c G " ++ -- 0630 - 063a
|
||||
" f q k l m n h w y. y a. u. i. a u " ++ -- 0641 - 064f
|
||||
"i v2 o a: V+ V- i: a+ " ++ -- 0650 - 0657
|
||||
"A* q?" -- 0671 (used by AED)
|
||||
allCodes = [0x0621..0x062f] ++ [0x0630..0x063a] ++
|
||||
"A* q?" -- 0671 (used by AED)
|
||||
allCodes = [0x0621..0x062f] ++ [0x0630..0x063a] ++
|
||||
[0x0641..0x064f] ++ [0x0650..0x0657] ++ [0x0671,0x061f]
|
||||
|
||||
|
||||
@@ -193,16 +193,16 @@ transPersian = (mkTransliteration "Persian/Farsi" allTrans allCodes)
|
||||
" V A: A? w? A- y? A b t. t t- j H K d " ++ -- 0621 - 062f
|
||||
"W r z s C S D T Z c G " ++ -- 0630 - 063a
|
||||
" f q - l m n h v - y. a. u. i. a u " ++ -- 0640 - 064f
|
||||
"i v2 o a: V+ V- i: a+ " ++ -- 0650 - 0657
|
||||
"i v2 o a: V+ V- i: a+ " ++ -- 0650 - 0657
|
||||
"p c^ J k g y q? Z0"
|
||||
allCodes = [0x0621..0x062f] ++ [0x0630..0x063a] ++
|
||||
[0x0641..0x064f] ++ [0x0650..0x0657] ++
|
||||
allCodes = [0x0621..0x062f] ++ [0x0630..0x063a] ++
|
||||
[0x0641..0x064f] ++ [0x0650..0x0657] ++
|
||||
[0x067e,0x0686,0x0698,0x06a9,0x06af,0x06cc,0x061f,0x200c]
|
||||
|
||||
transNepali :: Transliteration
|
||||
transNepali = mkTransliteration "Nepali" allTrans allCodes where
|
||||
allTrans = words $
|
||||
"z+ z= " ++
|
||||
"z+ z= " ++
|
||||
"- V M h: - H A i: I: f F Z - - - e: " ++
|
||||
"E: - - O W k K g G n: C c j J Y q " ++
|
||||
"Q x X N t T d D n - p P b B m y " ++
|
||||
@@ -241,7 +241,7 @@ transGreek = mkTransliteration "modern Greek" allTrans allCodes where
|
||||
"i= A B G D E Z H V I K L M N X O " ++
|
||||
"P R - S T Y F C Q W I- Y- a' e' h' i' " ++
|
||||
"y= a b g d e z h v i k l m n x o " ++
|
||||
"p r s* s t y f c q w i- y- o' y' w' - "
|
||||
"p r s* s t y f c q w i- y- o' y' w' - "
|
||||
allCodes = [0x0380 .. 0x03cf]
|
||||
|
||||
transAncientGreek :: Transliteration
|
||||
@@ -261,32 +261,32 @@ transAncientGreek = mkTransliteration "ancient Greek" allTrans allCodes where
|
||||
"y) y( y)` y(` y)' y(' y)~ y(~ - Y( - Y(` - Y(' - Y(~ " ++
|
||||
"w) w( w)` w(` w)' w(' w)~ w(~ W) W( W)` W(` W)' W(' W)~ W(~ " ++
|
||||
"a` a' e` e' h` h' i` i' o` o' y` y' w` w' - - " ++
|
||||
"a|) a|( a|)` a|(` a|)' a|(' a|)~ a|(~ - - - - - - - - " ++ -- 1f80-
|
||||
"h|) h|( h|)` h|(` h|)' h|(' h|)~ h|(~ - - - - - - - - " ++ -- 1f90-
|
||||
"w|) w|( w|)` w|(` w|)' w|(' w|)~ w|(~ - - - - - - - - " ++ -- 1fa0-
|
||||
"a|) a|( a|)` a|(` a|)' a|(' a|)~ a|(~ - - - - - - - - " ++ -- 1f80-
|
||||
"h|) h|( h|)` h|(` h|)' h|(' h|)~ h|(~ - - - - - - - - " ++ -- 1f90-
|
||||
"w|) w|( w|)` w|(` w|)' w|(' w|)~ w|(~ - - - - - - - - " ++ -- 1fa0-
|
||||
"a. a_ a|` a| a|' - a~ a|~ - - - - - - - - " ++ -- 1fb0-
|
||||
"- - h|` h| h|' - h~ h|~ - - - - - - - - " ++ -- 1fc0-
|
||||
"i. i_ i=` i=' - - i~ i=~ - - - - - - - - " ++ -- 1fd0-
|
||||
"y. y_ y=` y=' r) r( y~ y=~ - - - - - - - - " ++ -- 1fe0-
|
||||
"y. y_ y=` y=' r) r( y~ y=~ - - - - - - - - " ++ -- 1fe0-
|
||||
"- - w|` w| w|' - w~ w|~ - - - - - - - - " ++ -- 1ff0-
|
||||
-- HL, Private Use Area Code Points (New Athena Unicode, Cardo, ALPHABETUM, Antioch)
|
||||
-- see: http://apagreekkeys.org/technicalDetails.html
|
||||
-- GreekKeys Support by Donald Mastronarde
|
||||
"- - - - - - - - - e. o. R) Y) Y)` Y)' Y)~ " ++ -- e1a0-e1af
|
||||
"- - - - - - - - - e. o. R) Y) Y)` Y)' Y)~ " ++ -- e1a0-e1af
|
||||
"e~ e)~ e(~ e_ e_' e_` e_) e_( e_)` e_(` e_)' e_(' E)~ E(~ E_ E. " ++ -- e1b0-e1bf
|
||||
"o~ o)~ o(~ o_ o_' o_` o_) o_( o_)` o_(` o_)' o_(' O)~ O(~ O_ O. " ++ -- e1c0-e1cf
|
||||
"a_` - a_~ a_)` a_(` a_)~ a_(~ - a.` a.) a.)` a.(' a.(` - - - " ++ -- eaf0-eaff
|
||||
"a_' - - - a_) a_( - a_)' - a_(' a.' a.( a.)' - - - " ++ -- eb00-eb0f
|
||||
"a_` - a_~ a_)` a_(` a_)~ a_(~ - a.` a.) a.)` a.(' a.(` - - - " ++ -- eaf0-eaff
|
||||
"a_' - - - a_) a_( - a_)' - a_(' a.' a.( a.)' - - - " ++ -- eb00-eb0f
|
||||
"e_)~ e_(~ - - - - - e_~ - - - - - - - - " ++ -- eb20-eb2f
|
||||
"- - - - - - i_~ - i_` i_' - - i_) i_)' i_( i_(' " ++ -- eb30-eb3f
|
||||
"- - - - - - i_~ - i_` i_' - - i_) i_)' i_( i_(' " ++ -- eb30-eb3f
|
||||
"i.' i.) i.)' i.( i.` i.)` - i.(' i.(` - - - - - - - " ++ -- eb40-eb4f
|
||||
"- - - - i_)` i_(` - i_)~ i_(~ - o_~ o_)~ o_(~ - - - " ++ -- eb50-eb5f
|
||||
"y_` " ++ -- eb6f
|
||||
"y_~ y_)` - - - y_(` - y_)~ y_(~ - y_' - - y_) y_( y_)' " ++ -- eb70-eb7f
|
||||
"y_(' y.' y.( y.` y.) y.)' - - y.)` y.(' y.(` - - - - - " -- eb80-eb8f
|
||||
allCodes = -- [0x00B0 .. 0x00Bf]
|
||||
[0x0380 .. 0x03cf] ++ [0x1f00 .. 0x1fff]
|
||||
++ [0xe1a0 .. 0xe1af]
|
||||
allCodes = -- [0x00B0 .. 0x00Bf]
|
||||
[0x0380 .. 0x03cf] ++ [0x1f00 .. 0x1fff]
|
||||
++ [0xe1a0 .. 0xe1af]
|
||||
++ [0xe1b0 .. 0xe1bf]
|
||||
++ [0xe1c0 .. 0xe1cf]
|
||||
++ [0xeaf0 .. 0xeaff]
|
||||
@@ -297,36 +297,34 @@ transAncientGreek = mkTransliteration "ancient Greek" allTrans allCodes where
|
||||
++ [0xeb50 .. 0xeb5f] ++ [0xeb6f]
|
||||
++ [0xeb70 .. 0xeb7f]
|
||||
++ [0xeb80 .. 0xeb8f]
|
||||
|
||||
transAmharic :: Transliteration
|
||||
|
||||
transAmharic :: Transliteration
|
||||
transAmharic = mkTransliteration "Amharic" allTrans allCodes where
|
||||
|
||||
allTrans = words $
|
||||
|
||||
" h. h- h' h( h) h h? h* l. l- l' l( l) l l? l* "++
|
||||
" H. H- H' H( H) H H? H* m. m- m' m( m) m m? m* "++
|
||||
" s. s- s' s( s) s s? s* r. r- r' r( r) r r? r* "++
|
||||
" - - - - - - - - x. x- x' x( x) x x? x* "++
|
||||
" q. q- q' q( q) q q? q* - - - - - - - - "++
|
||||
" - - - - - - - - - - - - - - - - "++
|
||||
" b. b- b' b( b) b b? b* v. v- v' v( v) v v? v* "++
|
||||
" t. t- t' t( t) t t? t* c. c- c' c( c) c c? c* "++
|
||||
" X. X- X' X( X) X X? - - - - X* - - - - "++
|
||||
" n. n- n' n( n) n n? n* N. N- N' N( N) N N? N* "++
|
||||
" a u i A E e o e* k. k- k' k( k) k k? - "++
|
||||
" - - - k* - - - - - - - - - - - - "++
|
||||
" - - - - - - - - w. w- w' w( w) w w? w* "++
|
||||
" - - - - - - - - z. z- z' z( z) z z? z* "++
|
||||
" Z. Z- Z' Z( Z) Z Z? Z* y. y- y' y( y) y y? y* "++
|
||||
" d. d- d' d( d) d d? d* - - - - - - - - "++
|
||||
" j. j- j' j( j) j j? j* g. g- g' g( g) g g? - "++
|
||||
" - - - g* - - - - - - - - - - - - "++
|
||||
" T. T- T' T( T) T T? T* C. C- C' C( C) C C? C* "++
|
||||
" P. P- P' P( P) P P? P* S. S- S' S( S) S S? S* "++
|
||||
" - - - - - - - - f. f- f' f( f) f f? f*"++
|
||||
" p. p- p' p( p) p p? p*"
|
||||
allCodes = [0x1200..0x1357]
|
||||
|
||||
allTrans = words $
|
||||
" h. h- h' h( h) h h? h* l. l- l' l( l) l l? l* "++
|
||||
" H. H- H' H( H) H H? H* m. m- m' m( m) m m? m* "++
|
||||
" s. s- s' s( s) s s? s* r. r- r' r( r) r r? r* "++
|
||||
" - - - - - - - - x. x- x' x( x) x x? x* "++
|
||||
" q. q- q' q( q) q q? q* - - - - - - - - "++
|
||||
" - - - - - - - - - - - - - - - - "++
|
||||
" b. b- b' b( b) b b? b* v. v- v' v( v) v v? v* "++
|
||||
" t. t- t' t( t) t t? t* c. c- c' c( c) c c? c* "++
|
||||
" X. X- X' X( X) X X? - - - - X* - - - - "++
|
||||
" n. n- n' n( n) n n? n* N. N- N' N( N) N N? N* "++
|
||||
" a u i A E e o e* k. k- k' k( k) k k? - "++
|
||||
" - - - k* - - - - - - - - - - - - "++
|
||||
" - - - - - - - - w. w- w' w( w) w w? w* "++
|
||||
" - - - - - - - - z. z- z' z( z) z z? z* "++
|
||||
" Z. Z- Z' Z( Z) Z Z? Z* y. y- y' y( y) y y? y* "++
|
||||
" d. d- d' d( d) d d? d* - - - - - - - - "++
|
||||
" j. j- j' j( j) j j? j* g. g- g' g( g) g g? - "++
|
||||
" - - - g* - - - - - - - - - - - - "++
|
||||
" T. T- T' T( T) T T? T* C. C- C' C( C) C C? C* "++
|
||||
" P. P- P' P( P) P P? P* S. S- S' S( S) S S? S* "++
|
||||
" - - - - - - - - f. f- f' f( f) f f? f*"++
|
||||
" p. p- p' p( p) p p? p*"
|
||||
allCodes = [0x1200..0x1357]
|
||||
|
||||
-- by Prasad 31/5/2013
|
||||
transSanskrit :: Transliteration
|
||||
transSanskrit = (mkTransliteration "Sanskrit" allTrans allCodes) {invisible_chars = ["a"]} where
|
||||
|
||||
Reference in New Issue
Block a user