Encode 1.3.1 → 1.3.2
raw patch · 7 files changed
+52/−216 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Encode.cabal +1/−1
- Encode.hs +3/−3
- Encode/Arabic/ArabTeX.hs +7/−11
- Encode/Arabic/Buckwalter.hs +30/−28
- Encode/Arabic/Byte.hs +3/−159
- Exec/Decode/Main.hs +4/−7
- Exec/Encode/Main.hs +4/−7
Encode.cabal view
@@ -1,5 +1,5 @@ name: Encode -version: 1.3.1 +version: 1.3.2 license: GPL license-file: LICENSE extra-source-files: INSTALL, LicenseBSD, LicenseGPL, Setup.PL
Encode.hs view
@@ -1,5 +1,5 @@ -- -------------------------------------------------------------------------- --- $Revision: 935 $ $Date: 2010-02-13 18:23:52 +0100 (Sat, 13 Feb 2010) $ +-- $Revision: 937 $ $Date: 2010-02-14 13:54:54 +0100 (Sun, 14 Feb 2010) $ -- -------------------------------------------------------------------------- -- | @@ -43,9 +43,9 @@ import Version -version = Version [1, 3, min build 1] [] +version = Version [1, 3, min build 2] [] - where Version [build] [] = revised "$Revision: 935 $" + where Version [build] [] = revised "$Revision: 937 $" -- | The datatype introduced for the internal representation of Unicode code
Encode/Arabic/ArabTeX.hs view
@@ -1,5 +1,5 @@ -- -------------------------------------------------------------------------- --- $Revision: 934 $ $Date: 2010-02-13 17:26:58 +0100 (Sat, 13 Feb 2010) $ +-- $Revision: 937 $ $Date: 2010-02-14 13:54:54 +0100 (Sun, 14 Feb 2010) $ -- -------------------------------------------------------------------------- -- | @@ -41,7 +41,7 @@ import Version -version = revised "$Revision: 934 $" +version = revised "$Revision: 937 $" data ArabTeX = ArabTeX | Lagally | TeX @@ -154,12 +154,9 @@ _ -> [ j ++ f | j <- justAlif, f <- filterIt ] - "|" -> case sukun ? x of - - Just s -> if envQuote e then noChange else [[]] - Nothing -> if envQuote e then filterIt else noChange + _ | c `elem` ["'A", "|", "_W"] - "'A" -> case sukun ? x of + -> case sukun ? x of Just s -> if envQuote e then noChange else [[]] Nothing -> if envQuote e then filterIt else noChange @@ -627,9 +624,7 @@ rules = "+" |.| [] |+| - "*" |.| [] |+| - - "_W" |-| "w" |:| [] + "*" |.| [] |+| ruleVerbalSilentAlif |+| ruleMaqsuuraWithAlif @@ -1017,7 +1012,8 @@ silent = define [ ( "A", [ 0x0627 ] ), - ( "W", [ 0x0627 ] ) + ( "W", [ 0x0627 ] ), + ( "_W", [ 0x0648 ] ) ]
Encode/Arabic/Buckwalter.hs view
@@ -1,23 +1,27 @@ -- -------------------------------------------------------------------------- --- $Revision: 262 $ $Date: 2007-04-12 12:19:50 +0200 (Thu, 12 Apr 2007) $ +-- $Revision: 971 $ $Date: 2010-06-20 00:49:34 +0200 (Sun, 20 Jun 2010) $ -- -------------------------------------------------------------------------- -- | -- -- Module : Encode.Arabic.Buckwalter --- Copyright : Otakar Smrz 2005-2007 +-- Copyright : Otakar Smrz 2005-2010 -- License : GPL -- -- Maintainer : otakar.smrz mff.cuni.cz -- Stability : provisional -- Portability : portable -- --- Tim Buckwalter's notation is a one-to-one transliteration of the Arabic --- script for Modern Standard Arabic, using lower ASCII characters to encode --- the graphemes of the original script. This system has been very popular in --- Natural Language Processing, however, there are limits to its --- applicability due to numerous non-alphabetic codes involved. +-- Tim Buckwalter's notation is a one-to-one transliteration of the graphemes +-- of the Arabic script using lower ASCII characters only. This system is very +-- popular in Natural Language Processing, however, there are limits to its +-- applicability due to numerous non-alphabetic characters involved. -- +-- The XML-friendly variant of the notation replaces codes @>@, @&@, @<@ with +-- @O@, @W@, @I@, respectively. In this implementation, the 'decode' function +-- considers both of these conventions and converts from them, while the +-- 'encode' function produces the XML-friendly notation only. +-- -- /Encode::Arabic::Buckwalter/ in Perl: -- <http://search.cpan.org/dist/Encode-Arabic/lib/Encode/Arabic/Buckwalter.pm> @@ -35,12 +39,9 @@ import PureFP.OrdMap ---import Data.Map (Map) ---import qualified Data.Map as Map - import Version -version = revised "$Revision: 262 $" +version = revised "$Revision: 971 $" data Buckwalter = Buckwalter | Tim @@ -50,19 +51,14 @@ instance Encoding Buckwalter where - encode _ = recode (recoder decoded encoded) - - decode _ = recode (recoder encoded decoded) - + encode _ = recode encoder ---makeMapWith f = Map.fromListWith f ---lookupWith f m x = Map.findWithDefault (f x) x m + decode _ = recode decoder recode :: (Eq a, Enum a, Enum b, Ord a, OrdMap m) => m a b -> [a] -> [b] recode xry xs = [ lookupWith ((toEnum . fromEnum) x) xry x | x <- xs ] ---recode xry xs = [ lookupWith (toEnum . fromEnum) xry x | x <- xs ] recoder :: Ord a => [a] -> [b] -> Map a b @@ -70,20 +66,29 @@ recoder xs ys = makeMapWith const (zip xs ys) +encoder :: Map UPoint Char + +encoder = recoder decoded encoded + + +decoder :: Map Char UPoint + +decoder = recoder encoded decoded + + decoded :: [UPoint] decoded = map toEnum ( [] - ++ [0x0640] - ++ [0x0623, 0x0624, 0x0625] + ++ [0x0623, 0x0624, 0x0625] ++ [0x0623, 0x0624, 0x0625] ++ [0x060C, 0x061B, 0x061F] ++ [0x0621, 0x0622] ++ [0x0626 .. 0x063A] ++ [0x0641 .. 0x064A] ++ [0x067E, 0x0686, 0x06A4, 0x06AF] ++ [0x0660 .. 0x0669] ++ [0x0671] ++ [0x0651] - ++ [0x064B .. 0x0650] ++ [0x0670] - ++ [0x0652] + ++ [0x064B .. 0x0650] ++ [0x0670] ++ [0x0652] + ++ [0x0640] ) @@ -92,17 +97,14 @@ encoded = map id ( [] - ++ "_" - ++ "OWI" - -- ">&<" + ++ "OWI" ++ ">&<" ++ ",;?" ++ "'|" ++ "}AbptvjHxd*rzs$SDTZEg" ++ "fqklmnhwYy" ++ "PJVG" ++ ['0' .. '9'] ++ "{" - -- "A" ++ "~" - ++ "FNKaui" ++ "`" - ++ "o" + ++ "FNKaui" ++ "`" ++ "o" + ++ "_" )
Encode/Arabic/Byte.hs view
@@ -1,11 +1,11 @@ -- -------------------------------------------------------------------------- --- $Revision: 728 $ $Date: 2008-10-16 00:11:37 +0200 (Thu, 16 Oct 2008) $ +-- $Revision: 971 $ $Date: 2010-06-20 00:49:34 +0200 (Sun, 20 Jun 2010) $ -- -------------------------------------------------------------------------- -- | -- -- Module : Encode.Arabic.Byte --- Copyright : Otakar Smrz 2005-2007 +-- Copyright : Otakar Smrz 2005-2010 -- License : GPL -- -- Maintainer : otakar.smrz mff.cuni.cz @@ -43,12 +43,9 @@ import PureFP.OrdMap ---import Data.Map (Map) ---import qualified Data.Map as Map - import Version -version = revised "$Revision: 728 $" +version = revised "$Revision: 971 $" data WinArabic = WinArabic | CP1256 | Windows_1256 @@ -149,14 +146,9 @@ decode _ = recode (recoder upperCode isiri3342) ---makeMapWith f = Map.fromListWith f ---lookupWith f m x = Map.findWithDefault (f x) x m - - recode :: (Eq a, Enum a, Enum b, Ord a, OrdMap m) => m a b -> [a] -> [b] recode xry xs = [ lookupWith ((toEnum . fromEnum) x) xry x | x <- xs ] ---recode xry xs = [ lookupWith (toEnum . fromEnum) xry x | x <- xs ] recoder :: Ord a => [a] -> [b] -> Map a b @@ -414,151 +406,3 @@ 0xFFFD, 0x0640, 0x007C, 0x005C, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x064E, 0x0650, 0x064F, 0x064B, 0x064D, 0x064C, 0x0651, 0x0652, 0x0623, 0x0625, 0x0624, 0x0626, 0x0629, 0x0643, 0x064A, 0x0649] - - -{- - -allUPoint :: [UPoint] - -allUPoint = map toEnum ( [] - - ++ [0x0640] - ++ [0x0623, 0x0624, 0x0625] - ++ [0x060C, 0x061B, 0x061F] - ++ [0x0621, 0x0622] ++ [0x0626 .. 0x063A] ++ [0x0641 .. 0x064A] - ++ [0x067E, 0x0686, 0x06A4, 0x06AF] - ++ [0x0660 .. 0x0669] - ++ [0x0671] - ++ [0x0651] - ++ [0x064B .. 0x0650] ++ [0x0670] - ++ [0x0652] - - ) - -winArabic :: [Char] - -winArabic = map toEnum ( [] - - ++ [0xDC] - ++ [0xC3, 0xC4, 0xC5] - ++ [0xA1, 0xBA, 0xBF] - ++ [0xC1, 0xC2] ++ [0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, - 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, - 0xD4, 0xD5, 0xD6, 0xD8, 0xD9, 0xDA, 0xDB] - ++ [0xDD, 0xDE, 0xDF, 0xE1, 0xE3, 0xE4, 0xE5, - 0xE6, 0xEC, 0xED] - ++ [0x81, 0x8D, 0x3F, 0x90] - ++ [0x30 .. 0x39] - ++ [0x3F] - ++ [0xF8] - ++ [0xF0, 0xF1, 0xF2, 0xF3, 0xF5, 0xF6] ++ [0x3F] - ++ [0xFA] - - ) - - -isoArabic :: [Char] - -isoArabic = map toEnum ( [] - - ++ [0xE0] - ++ [0xC3, 0xC4, 0xC5] - ++ [0xAC, 0xBB, 0xBF] - ++ [0xC1, 0xC2] ++ [0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, - 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, - 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA] - ++ [0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, - 0xE8, 0xE9, 0xEA] - ++ [0x3F, 0x3F, 0x3F, 0x3F] - ++ [0x30 .. 0x39] - ++ [0x3F] - ++ [0xF1] - ++ [0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0] ++ [0x3F] - ++ [0xF2] - - ) - - --- Buckwalter - ++ "_" - ++ "OWI" - -- ">&<" - ++ ",;?" - ++ "'|" ++ "}AbptvjHxd*rzs$SDTZEg" ++ "fqklmnhwYy" - ++ "PJVG" - ++ ['0' .. '9'] - ++ "{" - -- "A" - ++ "~" - ++ "FNKaui" ++ "`" - ++ "o" - - --- MacArabic - ++ [0xE0] - ++ [0xC3, 0xC4, 0xC5] - ++ [0xAC, 0xBB, 0xBF] - ++ [0xC1, 0xC2] ++ [0xC6, 0xC7, 0xC8, 0xC9, 0xCA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1] - ++ [0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F] ++ [0x3F] - ++ [0x3F] - - --- cp1006 - ++ [0x3F] - ++ [0x3F, 0x3F, 0x3F] - ++ [0xAB, 0xAC, 0xAE] - ++ [0x3F, 0x3F] ++ [0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, - 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, - 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F] - ++ [0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, - 0x3F, 0x3F, 0x3F] - ++ [0x3F, 0x3F, 0x3F, 0x3F] - ++ [0x30 .. 0x39] - ++ [0x3F] - ++ [0x3F] - ++ [0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F] ++ [0x3F] - ++ [0x3F] - --}
Exec/Decode/Main.hs view
@@ -1,5 +1,5 @@ -- -------------------------------------------------------------------------- --- $Revision: 933 $ $Date: 2010-02-13 16:57:22 +0100 (Sat, 13 Feb 2010) $ +-- $Revision: 947 $ $Date: 2010-04-29 23:53:39 +0200 (Thu, 29 Apr 2010) $ -- -------------------------------------------------------------------------- -- | @@ -59,7 +59,7 @@ "show program's version" ] -copyleft = unlines ["Encode Arabic (C) 2009-2005 Otakar Smrz", +copyleft = unlines ["Encode Arabic (C) 2010-2005 Otakar Smrz", "GNU General Public License http://www.gnu.org/licenses/"] synopsis = unlines [copyleft, @@ -80,7 +80,7 @@ PrintVersion : _ -> tell (unlines [copyleft, unwords ["Encode Arabic", showVersion Main.version, - "February 2010"]]) + "April 2010"]]) LineOriented : _ -> execute True (tail opts) nons _ -> execute False opts nons @@ -148,7 +148,4 @@ "isiri3342" -> decode ISIRI3342 - "utf8" -> decode UTF8 - "utf" -> decode UTF - - _ -> decode Unicode + _ -> decode UTF
Exec/Encode/Main.hs view
@@ -1,5 +1,5 @@ -- -------------------------------------------------------------------------- --- $Revision: 933 $ $Date: 2010-02-13 16:57:22 +0100 (Sat, 13 Feb 2010) $ +-- $Revision: 947 $ $Date: 2010-04-29 23:53:39 +0200 (Thu, 29 Apr 2010) $ -- -------------------------------------------------------------------------- -- | @@ -59,7 +59,7 @@ "show program's version" ] -copyleft = unlines ["Encode Arabic (C) 2009-2005 Otakar Smrz", +copyleft = unlines ["Encode Arabic (C) 2010-2005 Otakar Smrz", "GNU General Public License http://www.gnu.org/licenses/"] synopsis = unlines [copyleft, @@ -80,7 +80,7 @@ PrintVersion : _ -> tell (unlines [copyleft, unwords ["Encode Arabic", showVersion Main.version, - "February 2010"]]) + "April 2010"]]) LineOriented : _ -> execute True (tail opts) nons _ -> execute False opts nons @@ -148,7 +148,4 @@ "isiri3342" -> encode ISIRI3342 - "utf8" -> encode UTF8 - "utf" -> encode UTF - - _ -> encode Unicode + _ -> encode UTF