freq 0.1.0.2 → 0.1.0.3
raw patch · 5 files changed
+9/−11 lines, 5 filessetup-changed
Files
- LICENSE +1/−1
- README.md +0/−6
- Setup.hs +2/−0
- freq.cabal +1/−2
- src/Freq/Internal.hs +5/−2
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2018, chessai+Copyright © 2018, chessai All rights reserved.
README.md view
@@ -5,9 +5,3 @@ ## Uses I currently use this to validate domain names, and so the training data available consists of about 6.5 Megabytes of Public Domain 19th and 20th century English novels. You can feed any training data you wish to 'freq' to achieve different results.--## Improvements-To improve further on the accuracy of this approach, I will experiment with a generalised dynamic n-gram approach, which will sacrifice slightly in performance for a potentially large gain in accuracy. --## Further-See my implementation of the [Linear Hadamard Spectral Test](https://github.com/chessai/lhst) for a different approach to a similar problem with much higher variance in the potentially random data, where a trained approach might be less accurate.
Setup.hs view
@@ -1,2 +1,4 @@ import Distribution.Simple++main :: IO () main = defaultMain
freq.cabal view
@@ -1,7 +1,7 @@ --------------------------------------------------------------------- name: freq-version: 0.1.0.2+version: 0.1.0.3 build-type: Simple cabal-version: >= 1.10 category: Data@@ -70,4 +70,3 @@ default-language: Haskell2010 ----------------------------------------------------------------------
src/Freq/Internal.hs view
@@ -251,7 +251,7 @@ in showFloat (PM.indexByteArray arr ix :: Double) ++ " " ++ extra ++ go (ix + 1) else "" where- !elemSz = P.div (PM.sizeofByteArray arr) (PM.sizeOf (undefined :: Double))+ !elemSz = P.div (PM.sizeofByteArray arr) (sizeOf (undefined :: Double)) showFloat :: P.RealFloat a => a -> String showFloat !x = Numeric.showFFloat (Just 2) x "" @@ -259,6 +259,9 @@ -- Internal Section -- -------------------------------------------------------------------- +sizeOf :: PM.Prim a => a -> Int+sizeOf x = I# (PM.sizeOf# x)+ word8ToInt :: Word8 -> Int word8ToInt !w = P.fromIntegral w {-# INLINE word8ToInt #-}@@ -282,7 +285,7 @@ ixedChars :: [(Word8,Word8)] !ixedChars = L.zip (P.enumFrom (0 :: Word8)) (S.toList allChars) ixs <- PM.newByteArray 256- square <- PM.newByteArray (szSq * PM.sizeOf (undefined :: Double))+ square <- PM.newByteArray (szSq * sizeOf (undefined :: Double)) let fillSquare :: Int -> ST s () fillSquare !i = if i < szSq then do