Browse Source

rename Lib to Text.Spellcheck

main
Sam Hatfield 2 years ago
parent
commit
0c8686c031
Signed by: sehqlr
GPG Key ID: 7338CA919BC087F3
  1. 3
      app/Main.hs
  2. 2
      bench/Main.hs
  3. 13
      src/Text/Spellcheck.hs
  4. 2
      test/Spec.hs

3
app/Main.hs

@ -1,9 +1,8 @@
{-# LANGUAGE OverloadedStrings #-}
import Lib
import Text.Spellcheck
import qualified Data.Text as T
import qualified Data.List as L
import qualified Dhall
import Options.Applicative
import Data.Semigroup ((<>))

2
bench/Main.hs

@ -1,5 +1,5 @@
import Criterion.Main
import Lib
import Text.Spellcheck
main :: IO ()
main = defaultMain [

13
src/Lib.hs → src/Text/Spellcheck.hs

@ -12,22 +12,13 @@ file and a prose file, and returns a stream of words and possible
substitutions. The library is responsible for generating that list.
-}
{-# LANGUAGE OverloadedStrings #-}
module Lib (Suggestion(..), spellcheck, suggestions, lDistance) where
module Text.Spellcheck (Suggestion(..), spellcheck, suggestions, lDistance) where
import qualified Data.Text as T
import Data.List
import Data.Array
data Suggestion a = Suggestion Int a
instance (Show a) => Show (Suggestion a) where
show (Suggestion i a) = "Suggestion" ++ show a ++ ", distance " ++ show i
instance (Eq a) => Eq (Suggestion a) where
(Suggestion a b) == (Suggestion c d) = (a == c) && (b == d)
instance (Ord a) => Ord (Suggestion a) where
(Suggestion i _) <= (Suggestion j _) = i <= j
data Suggestion a = Suggestion Int a deriving (Show, Ord, Eq)
spellcheck :: (Ord a) => [[a]] -> [[a]] -> [([a], [Suggestion [a]])]
spellcheck dict words = zip words $ map (suggestions dict) words

2
test/Spec.hs

@ -9,7 +9,7 @@ import Test.Tasty
import Test.Tasty.Hedgehog
import Test.Tasty.TH
import Lib
import Text.Spellcheck
import Data.Text as T hiding (head, last, length, null)
import Data.List

Loading…
Cancel
Save