Commit e887a14c authored by Alexandre Delanoë's avatar Alexandre Delanoë

[DOCTEST] added.

parent 565e11e2
......@@ -111,20 +111,28 @@ library
default-language: Haskell2010
ghc-options: -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Werror
test-suite garg-test-ngrams
test-suite garg-doctest
type: exitcode-stdio-1.0
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
default-language: Haskell2010
main-is: Main.hs
hs-source-dirs:
test
src-doctest
ghc-options: -Wall -Werror -threaded -rtsopts -with-rtsopts=-N
build-depends:
extra
, text
, doctest
, Glob
, QuickCheck
, base
, gargantext
default-language: Haskell2010
test-suite garg-test
type: exitcode-stdio-1.0
main-is: Main.hs
other-modules:
Ngrams.Lang
Ngrams.Lang.En
Ngrams.Lang.Fr
Ngrams.Lang.Occurrences
Ngrams.Metrics
Parsers.WOS
hs-source-dirs:
src-test
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
build-depends:
extra
, text
......@@ -132,3 +140,11 @@ test-suite garg-test-ngrams
, gargantext
, hspec
, QuickCheck
other-modules:
Ngrams.Lang
Ngrams.Lang.En
Ngrams.Lang.Fr
Ngrams.Lang.Occurrences
Ngrams.Metrics
Parsers.WOS
default-language: Haskell2010
......@@ -104,9 +104,9 @@ library:
- zip
- path-io
tests:
garg-test-ngrams:
garg-test:
main: Main.hs
source-dirs: test
source-dirs: src-test
ghc-options:
- -threaded
- -rtsopts
......@@ -116,3 +116,17 @@ tests:
- gargantext
- hspec
- QuickCheck
garg-doctest:
main: Main.hs
source-dirs: src-doctest
ghc-options:
- -Werror
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- doctest
- Glob
- QuickCheck
- base
- gargantext
import System.FilePath.Glob
import Test.DocTest
main :: IO ()
main = glob "src/**/*.hs" >>= doctest
......@@ -66,6 +66,7 @@ groupNgrams ((x,"NN",_):(o,"IN",_):(det,"DT",_):(y,"NNP",yy):xs) = groupNg
groupNgrams ((x,_,"PERSON"):(y,yy,"PERSON"):xs) = groupNgrams ((x <> " " <> y,yy,"PERSON"):xs)
groupNgrams ((x,_,"ORGANIZATION"):(y,yy,"ORGANIZATION"):xs) = groupNgrams ((x <> " " <> y,yy,"ORGANIZATION"):xs)
groupNgrams ((x,_,"LOCATION"):(y,yy,"LOCATION"):xs) = groupNgrams ((x <> " " <> y,yy,"LOCATION"):xs)
groupNgrams (x:xs) = (x:(groupNgrams xs))
......
{-|
Module : Data.Gargantext.Ngrams.Metrics
Description : Short description
Copyright : (c) Some Guy, 2013
Someone Else, 2014
License : GPL-3
Maintainer : sample@email.com
Stability : experimental
Portability : POSIX
Here is a longer description of this module, containing some
commentary with @some markup@.
-}
module Data.Gargantext.Ngrams.Metrics (levenshtein
, levenshteinNorm
, damerauLevenshtein
......@@ -11,6 +25,9 @@ import Data.Text (Text)
import GHC.Real (Ratio)
import qualified Data.Text.Metrics as DTM
{- * Example de titre
-}
-- | This module provide metrics to compare Text
-- starting as an API rexporting main functions of the great lib
-- text-metrics of Mark Karpov
......@@ -20,7 +37,7 @@ import qualified Data.Text.Metrics as DTM
-- the Levenshtein distance is a string metric for measuring
-- the difference between two sequences.
-- See: https://en.wikipedia.org/wiki/Levenshtein_distance
--
levenshtein :: Text -> Text -> Int
levenshtein = DTM.levenshtein
......@@ -28,7 +45,7 @@ levenshtein = DTM.levenshtein
-- Result is a non-negative rational number (represented as @'Ratio'
-- 'Data.Numeric.Natural'@), where 0 signifies no similarity between the
-- strings, while 1 means exact match.
--
levenshteinNorm :: Text -> Text -> Ratio Int
levenshteinNorm = DTM.levenshteinNorm
......@@ -37,12 +54,12 @@ levenshteinNorm = DTM.levenshteinNorm
-- operations also includes transposition of two /adjacent/ characters.
-- See also:
-- <https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance>
--
damerauLevenshtein :: Text -> Text -> Int
damerauLevenshtein = DTM.damerauLevenshtein
-- damerau-Levenshtein distance normalized
--
damerauLevenshteinNorm :: Text -> Text -> Ratio Int
damerauLevenshteinNorm = DTM.damerauLevenshteinNorm
......
......@@ -26,7 +26,6 @@ data Language = EN | FR -- | DE | IT | SP
-- > SP == spanish (not implemented yet)
-- > ... add your language and help us to implement it (:
type Ngrams = (Text, Text, Text)
-- | TODO add Symbolic Node / Document
......
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DeriveGeneric #-}
-- {-# LANGUAGE DuplicateRecordFields #-}
module Data.Gargantext.Types.Node where
......
......@@ -7,4 +7,6 @@ extra-deps:
- aeson-1.0.2.1
- duckling-0.1.3.0
- protolude-0.2
- generic-lens-0.4.0.1
- GenericPretty-1.2.1
resolver: lts-9.2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment