cld2 0.1.0.1 → 0.1.1.0
raw patch · 2 files changed
+18/−13 lines, 2 filesdep +hashablenew-uploaderPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: hashable
API changes (from Hackage documentation)
- Text.CLD2: chunkLanguage :: Chunk -> Language
- Text.CLD2: chunkOffset :: Chunk -> Int
- Text.CLD2: chunkSize :: Chunk -> Int
- Text.CLD2: debugFlagCr :: DebugFlags -> Bool
- Text.CLD2: debugFlagEcho :: DebugFlags -> Bool
- Text.CLD2: debugFlagHtml :: DebugFlags -> Bool
- Text.CLD2: debugFlagQuiet :: DebugFlags -> Bool
- Text.CLD2: debugFlagScoreAsQuads :: DebugFlags -> Bool
- Text.CLD2: debugFlagVerbose :: DebugFlags -> Bool
- Text.CLD2: hintContentLanguage :: Hints -> Maybe String
- Text.CLD2: hintEncoding :: Hints -> Encoding
- Text.CLD2: hintLanguage :: Hints -> Language
- Text.CLD2: hintTLD :: Hints -> Maybe String
- Text.CLD2: instance Bounded Encoding
- Text.CLD2: instance Bounded Language
- Text.CLD2: instance Data Chunk
- Text.CLD2: instance Data DebugFlags
- Text.CLD2: instance Data Encoding
- Text.CLD2: instance Data Hints
- Text.CLD2: instance Data Language
- Text.CLD2: instance Data Result
- Text.CLD2: instance Enum Encoding
- Text.CLD2: instance Enum Language
- Text.CLD2: instance Eq Chunk
- Text.CLD2: instance Eq DebugFlags
- Text.CLD2: instance Eq Encoding
- Text.CLD2: instance Eq Hints
- Text.CLD2: instance Eq Language
- Text.CLD2: instance Eq Result
- Text.CLD2: instance Ord Chunk
- Text.CLD2: instance Ord DebugFlags
- Text.CLD2: instance Ord Encoding
- Text.CLD2: instance Ord Hints
- Text.CLD2: instance Ord Language
- Text.CLD2: instance Ord Result
- Text.CLD2: instance Show Chunk
- Text.CLD2: instance Show DebugFlags
- Text.CLD2: instance Show Encoding
- Text.CLD2: instance Show Hints
- Text.CLD2: instance Show Language
- Text.CLD2: instance Show Result
- Text.CLD2: instance Typeable Chunk
- Text.CLD2: instance Typeable DebugFlags
- Text.CLD2: instance Typeable Encoding
- Text.CLD2: instance Typeable Hints
- Text.CLD2: instance Typeable Language
- Text.CLD2: instance Typeable Result
- Text.CLD2: resultChunks :: Result -> [Chunk]
- Text.CLD2: resultIsReliable :: Result -> Bool
- Text.CLD2: resultSimple :: Result -> Language
- Text.CLD2: resultTextBytes :: Result -> Int
- Text.CLD2: resultTop3 :: Result -> (Language, Language, Language)
- Text.CLD2: resultTop3Percent :: Result -> (Int, Int, Int)
- Text.CLD2: resultTop3Score :: Result -> (Double, Double, Double)
+ Text.CLD2: [chunkLanguage] :: Chunk -> Language
+ Text.CLD2: [chunkOffset] :: Chunk -> Int
+ Text.CLD2: [chunkSize] :: Chunk -> Int
+ Text.CLD2: [debugFlagCr] :: DebugFlags -> Bool
+ Text.CLD2: [debugFlagEcho] :: DebugFlags -> Bool
+ Text.CLD2: [debugFlagHtml] :: DebugFlags -> Bool
+ Text.CLD2: [debugFlagQuiet] :: DebugFlags -> Bool
+ Text.CLD2: [debugFlagScoreAsQuads] :: DebugFlags -> Bool
+ Text.CLD2: [debugFlagVerbose] :: DebugFlags -> Bool
+ Text.CLD2: [hintContentLanguage] :: Hints -> Maybe String
+ Text.CLD2: [hintEncoding] :: Hints -> Encoding
+ Text.CLD2: [hintLanguage] :: Hints -> Language
+ Text.CLD2: [hintTLD] :: Hints -> Maybe String
+ Text.CLD2: [resultChunks] :: Result -> [Chunk]
+ Text.CLD2: [resultIsReliable] :: Result -> Bool
+ Text.CLD2: [resultSimple] :: Result -> Language
+ Text.CLD2: [resultTextBytes] :: Result -> Int
+ Text.CLD2: [resultTop3Percent] :: Result -> (Int, Int, Int)
+ Text.CLD2: [resultTop3Score] :: Result -> (Double, Double, Double)
+ Text.CLD2: [resultTop3] :: Result -> (Language, Language, Language)
+ Text.CLD2: instance Data.Data.Data Text.CLD2.Chunk
+ Text.CLD2: instance Data.Data.Data Text.CLD2.DebugFlags
+ Text.CLD2: instance Data.Data.Data Text.CLD2.Encoding
+ Text.CLD2: instance Data.Data.Data Text.CLD2.Hints
+ Text.CLD2: instance Data.Data.Data Text.CLD2.Language
+ Text.CLD2: instance Data.Data.Data Text.CLD2.Result
+ Text.CLD2: instance Data.Hashable.Class.Hashable Text.CLD2.Chunk
+ Text.CLD2: instance Data.Hashable.Class.Hashable Text.CLD2.DebugFlags
+ Text.CLD2: instance Data.Hashable.Class.Hashable Text.CLD2.Encoding
+ Text.CLD2: instance Data.Hashable.Class.Hashable Text.CLD2.Hints
+ Text.CLD2: instance Data.Hashable.Class.Hashable Text.CLD2.Language
+ Text.CLD2: instance Data.Hashable.Class.Hashable Text.CLD2.Result
+ Text.CLD2: instance GHC.Classes.Eq Text.CLD2.Chunk
+ Text.CLD2: instance GHC.Classes.Eq Text.CLD2.DebugFlags
+ Text.CLD2: instance GHC.Classes.Eq Text.CLD2.Encoding
+ Text.CLD2: instance GHC.Classes.Eq Text.CLD2.Hints
+ Text.CLD2: instance GHC.Classes.Eq Text.CLD2.Language
+ Text.CLD2: instance GHC.Classes.Eq Text.CLD2.Result
+ Text.CLD2: instance GHC.Classes.Ord Text.CLD2.Chunk
+ Text.CLD2: instance GHC.Classes.Ord Text.CLD2.DebugFlags
+ Text.CLD2: instance GHC.Classes.Ord Text.CLD2.Encoding
+ Text.CLD2: instance GHC.Classes.Ord Text.CLD2.Hints
+ Text.CLD2: instance GHC.Classes.Ord Text.CLD2.Language
+ Text.CLD2: instance GHC.Classes.Ord Text.CLD2.Result
+ Text.CLD2: instance GHC.Enum.Bounded Text.CLD2.Encoding
+ Text.CLD2: instance GHC.Enum.Bounded Text.CLD2.Language
+ Text.CLD2: instance GHC.Enum.Enum Text.CLD2.Encoding
+ Text.CLD2: instance GHC.Enum.Enum Text.CLD2.Language
+ Text.CLD2: instance GHC.Generics.Generic Text.CLD2.Chunk
+ Text.CLD2: instance GHC.Generics.Generic Text.CLD2.DebugFlags
+ Text.CLD2: instance GHC.Generics.Generic Text.CLD2.Encoding
+ Text.CLD2: instance GHC.Generics.Generic Text.CLD2.Hints
+ Text.CLD2: instance GHC.Generics.Generic Text.CLD2.Language
+ Text.CLD2: instance GHC.Generics.Generic Text.CLD2.Result
+ Text.CLD2: instance GHC.Show.Show Text.CLD2.Chunk
+ Text.CLD2: instance GHC.Show.Show Text.CLD2.DebugFlags
+ Text.CLD2: instance GHC.Show.Show Text.CLD2.Encoding
+ Text.CLD2: instance GHC.Show.Show Text.CLD2.Hints
+ Text.CLD2: instance GHC.Show.Show Text.CLD2.Language
+ Text.CLD2: instance GHC.Show.Show Text.CLD2.Result
Files
- cld2.cabal +5/−2
- src/Text/CLD2.hs +13/−11
cld2.cabal view
@@ -1,9 +1,9 @@ name: cld2-version: 0.1.0.1+version: 0.1.1.0 synopsis: Haskell bindings to Google's Compact Language Detector 2 description: This package provides simple Haskell bindings for Compact Language Detector 2, a language-detection library used by Google Chrome.- See https://code.google.com/p/cld2/ for more information on CLD2.+ See <https://code.google.com/p/cld2/> for more information on CLD2. homepage: https://github.com/dfoxfranke/haskell-cld2 license: Apache-2.0 license-file: LICENSE@@ -45,6 +45,7 @@ location: https://github.com/dfoxfranke/haskell-cld2.git library+ ghc-options: -Wall c-sources: cbits/cld2_generated_cjk_compatible.cc, cbits/cld2_generated_deltaocta0122.cc, cbits/cld2_generated_distinctocta0122.cc,@@ -70,10 +71,12 @@ cbits/scoreonescriptspan.cc, cbits/tote.cc, cbits/utf8statetable.cc+ cc-options: -std=c++98 extra-libraries: stdc++ exposed-modules: Text.CLD2 build-depends: base ==4.*, bytestring < 0.11,+ hashable, text < 1.3 hs-source-dirs: src default-language: Haskell2010
src/Text/CLD2.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE Trustworthy, DeriveDataTypeable #-}+{-# LANGUAGE Trustworthy, DeriveDataTypeable, DeriveAnyClass, DeriveGeneric #-} {-# OPTIONS_HADDOCK show-extensions #-} {-@@ -37,20 +37,21 @@ import Control.Exception(AsyncException(..),AssertionFailed(..),mask_,throwIO) import Data.Bits(Bits(..), (.|.))-import Data.ByteString(ByteString) import Data.ByteString.Unsafe(unsafeUseAsCStringLen) import Data.Data(Data) import Data.Functor((<$>))+import Data.Hashable(Hashable) import Data.Text(Text) import Data.Text.Encoding(encodeUtf8) import Data.Typeable(Typeable) import Foreign.C.Error(Errno(..), eNOMEM, eOK) import Foreign.C.String(CString, withCString) import Foreign.C.Types(CShort(..),CInt(..),CChar(..),CDouble(..),CSize(..))-import Foreign.Ptr(Ptr(..), nullPtr)+import Foreign.Ptr(Ptr, nullPtr) import Foreign.Marshal.Alloc(alloca, free) import Foreign.Marshal.Array(peekArray, allocaArray) import Foreign.Storable(peek)+import GHC.Generics(Generic) import System.IO.Unsafe(unsafePerformIO) -- | An enumeration of all languages recognized by CLD2@@ -669,7 +670,7 @@ | Cld2Language_X_Sharada | Cld2Language_X_Sora_Sompeng | Cld2Language_X_Takri- deriving (Eq,Ord,Show,Bounded,Enum,Typeable,Data)+ deriving (Eq,Ord,Show,Bounded,Enum,Typeable,Data,Generic,Hashable) -- | An enumeration of character encodings which can be included in 'Hints' data Encoding =@@ -748,7 +749,7 @@ | Cld2Encoding_SOFTBANK_SHIFT_JIS | Cld2Encoding_KDDI_ISO_2022_JP | Cld2Encoding_SOFTBANK_ISO_2022_JP- deriving (Eq,Ord,Show,Bounded,Enum,Typeable,Data)+ deriving (Eq,Ord,Show,Bounded,Enum,Typeable,Data,Generic,Hashable) -- | A collection of contextual clues which can help improve the -- accuracy of language detection@@ -761,7 +762,7 @@ hintEncoding :: Encoding, -- | A hint from any other available context hintLanguage :: Language }- deriving (Eq,Ord,Show,Typeable,Data)+ deriving (Eq,Ord,Show,Typeable,Data,Generic,Hashable) -- | The default set of hints, which is @Hints@ @Nothing@ @Nothing@ @Cld2Encoding_UNKNOWN_ENCODING@ @Cld2Language_UNKNOWN_LANGUAGE@ defaultHints :: Hints@@ -774,7 +775,7 @@ debugFlagVerbose :: Bool, debugFlagQuiet :: Bool, debugFlagEcho :: Bool }- deriving (Eq,Ord,Show,Typeable,Data)+ deriving (Eq,Ord,Show,Typeable,Data,Generic,Hashable) -- | The default set of debugging flags, all @False@ defaultDebugFlags :: DebugFlags@@ -788,7 +789,7 @@ chunkSize :: Int, -- | The detected language of this chunk chunkLanguage :: Language }- deriving (Eq,Ord,Show,Typeable,Data)+ deriving (Eq,Ord,Show,Typeable,Data,Generic,Hashable) -- | The result of performing language detection on a corpus data Result = Result {@@ -806,7 +807,7 @@ resultTextBytes :: Int, -- | Whether this result should be considered reliable resultIsReliable :: Bool }- deriving (Eq,Ord,Show,Typeable,Data)+ deriving (Eq,Ord,Show,Typeable,Data,Generic,Hashable) foreign import ccall "cld2_haskell_shim" c_cld2_haskell_shim :: Ptr CInt -> Ptr CChar -> CInt -> CInt -> CString -> CString -> CInt -> CInt@@ -824,7 +825,7 @@ takeBit :: (Bits a) => a -> Bool -> a takeBit x True = x-takeBit x False = zeroBits+takeBit _x False = zeroBits flagsToCInt :: DebugFlags -> CInt flagsToCInt (DebugFlags a b c d e f) =@@ -911,7 +912,7 @@ peekArray 3 cPercent3 [cScore0, cScore1, cScore2] <- peekArray 3 cScore3- cNumChunks <- fromEnum <$> peek cNumChunksPtr+ _cNumChunks <- fromEnum <$> peek cNumChunksPtr cTextBytes <- peek cTextBytesPtr cIsReliable <- peek cIsReliablePtr let theSimple =@@ -942,6 +943,7 @@ theSimple theTop3 theTop3Percent (theScore0, theScore1, theScore2) theChunks theTextBytes theIsReliable+ -- | Call 'detectLanguageDebug' with all debug flags disabled and -- call 'unsafePerformIO' on the result. This is the recommended