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

[DOCTEST] added.

parent 565e11e2
...@@ -111,20 +111,28 @@ library ...@@ -111,20 +111,28 @@ library
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Werror ghc-options: -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Werror
test-suite garg-test-ngrams test-suite garg-doctest
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N main-is: Main.hs
default-language: Haskell2010
hs-source-dirs: 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 main-is: Main.hs
other-modules: hs-source-dirs:
Ngrams.Lang src-test
Ngrams.Lang.En ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
Ngrams.Lang.Fr
Ngrams.Lang.Occurrences
Ngrams.Metrics
Parsers.WOS
build-depends: build-depends:
extra extra
, text , text
...@@ -132,3 +140,11 @@ test-suite garg-test-ngrams ...@@ -132,3 +140,11 @@ test-suite garg-test-ngrams
, gargantext , gargantext
, hspec , hspec
, QuickCheck , 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: ...@@ -104,9 +104,9 @@ library:
- zip - zip
- path-io - path-io
tests: tests:
garg-test-ngrams: garg-test:
main: Main.hs main: Main.hs
source-dirs: test source-dirs: src-test
ghc-options: ghc-options:
- -threaded - -threaded
- -rtsopts - -rtsopts
...@@ -116,3 +116,17 @@ tests: ...@@ -116,3 +116,17 @@ tests:
- gargantext - gargantext
- hspec - hspec
- QuickCheck - 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 ...@@ -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,_,"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,_,"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)) 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 module Data.Gargantext.Ngrams.Metrics (levenshtein
, levenshteinNorm , levenshteinNorm
, damerauLevenshtein , damerauLevenshtein
...@@ -11,6 +25,9 @@ import Data.Text (Text) ...@@ -11,6 +25,9 @@ import Data.Text (Text)
import GHC.Real (Ratio) import GHC.Real (Ratio)
import qualified Data.Text.Metrics as DTM import qualified Data.Text.Metrics as DTM
{- * Example de titre
-}
-- | This module provide metrics to compare Text -- | This module provide metrics to compare Text
-- starting as an API rexporting main functions of the great lib -- starting as an API rexporting main functions of the great lib
-- text-metrics of Mark Karpov -- text-metrics of Mark Karpov
...@@ -20,7 +37,7 @@ import qualified Data.Text.Metrics as DTM ...@@ -20,7 +37,7 @@ import qualified Data.Text.Metrics as DTM
-- the Levenshtein distance is a string metric for measuring -- the Levenshtein distance is a string metric for measuring
-- the difference between two sequences. -- the difference between two sequences.
-- See: https://en.wikipedia.org/wiki/Levenshtein_distance -- See: https://en.wikipedia.org/wiki/Levenshtein_distance
--
levenshtein :: Text -> Text -> Int levenshtein :: Text -> Text -> Int
levenshtein = DTM.levenshtein levenshtein = DTM.levenshtein
...@@ -28,7 +45,7 @@ levenshtein = DTM.levenshtein ...@@ -28,7 +45,7 @@ levenshtein = DTM.levenshtein
-- Result is a non-negative rational number (represented as @'Ratio' -- Result is a non-negative rational number (represented as @'Ratio'
-- 'Data.Numeric.Natural'@), where 0 signifies no similarity between the -- 'Data.Numeric.Natural'@), where 0 signifies no similarity between the
-- strings, while 1 means exact match. -- strings, while 1 means exact match.
--
levenshteinNorm :: Text -> Text -> Ratio Int levenshteinNorm :: Text -> Text -> Ratio Int
levenshteinNorm = DTM.levenshteinNorm levenshteinNorm = DTM.levenshteinNorm
...@@ -37,12 +54,12 @@ levenshteinNorm = DTM.levenshteinNorm ...@@ -37,12 +54,12 @@ levenshteinNorm = DTM.levenshteinNorm
-- operations also includes transposition of two /adjacent/ characters. -- operations also includes transposition of two /adjacent/ characters.
-- See also: -- See also:
-- <https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance> -- <https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance>
--
damerauLevenshtein :: Text -> Text -> Int damerauLevenshtein :: Text -> Text -> Int
damerauLevenshtein = DTM.damerauLevenshtein damerauLevenshtein = DTM.damerauLevenshtein
-- damerau-Levenshtein distance normalized -- damerau-Levenshtein distance normalized
--
damerauLevenshteinNorm :: Text -> Text -> Ratio Int damerauLevenshteinNorm :: Text -> Text -> Ratio Int
damerauLevenshteinNorm = DTM.damerauLevenshteinNorm damerauLevenshteinNorm = DTM.damerauLevenshteinNorm
......
...@@ -26,7 +26,6 @@ data Language = EN | FR -- | DE | IT | SP ...@@ -26,7 +26,6 @@ data Language = EN | FR -- | DE | IT | SP
-- > SP == spanish (not implemented yet) -- > SP == spanish (not implemented yet)
-- > ... add your language and help us to implement it (: -- > ... add your language and help us to implement it (:
type Ngrams = (Text, Text, Text) type Ngrams = (Text, Text, Text)
-- | TODO add Symbolic Node / Document -- | TODO add Symbolic Node / Document
......
{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveGeneric #-}
-- {-# LANGUAGE DuplicateRecordFields #-}
module Data.Gargantext.Types.Node where module Data.Gargantext.Types.Node where
......
...@@ -7,4 +7,6 @@ extra-deps: ...@@ -7,4 +7,6 @@ extra-deps:
- aeson-1.0.2.1 - aeson-1.0.2.1
- duckling-0.1.3.0 - duckling-0.1.3.0
- protolude-0.2 - protolude-0.2
- generic-lens-0.4.0.1
- GenericPretty-1.2.1
resolver: lts-9.2 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