Commit f910cd90 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[test] packages version bump, trying to fix ngrams test

parent 801e3852
......@@ -4998,4 +4998,4 @@
"repo": "https://github.com/athanclark/purescript-zeta-extra.git",
"version": "v0.0.1"
}
}
\ No newline at end of file
}
......@@ -5,7 +5,7 @@ import
pkgs.fetchFromGitHub {
owner = "justinwoo";
repo = "easy-purescript-nix";
rev = "7ebddd8613cf6736dbecef9fce4c32f2a104ef82";
rev = "c8c32741bc09e2ac0a94d5140cf51fa5de809e24";
sha256 = "1g1hlybld298kimd1varvwiflpb0k7sdqlmcqha3kswjvy5z4k6k";
}
) {
......
......@@ -7,7 +7,7 @@ let
owner = "justinwoo";
repo = "easy-dhall-nix";
rev = "90957969850a44481c6e150350c56e8b53b29e1e";
sha256 = "12v4ql1nm1famz8r80k1xkkdgj7285vy2vn16iili0qwvz3i98ah";
sha256 = "1hsmp3cb0k554kh0jlfzpdzx2b8ndyh2gdykmw9hw41haaw16mmi";
}
) {
inherit pkgs;
......
......@@ -21,11 +21,11 @@
};
"affjax" = {
name = "affjax";
version = "v10.1.0";
version = "v11.0.0";
src = pkgs.fetchgit {
url = "https://github.com/slamdata/purescript-affjax.git";
rev = "v10.1.0";
sha256 = "129g7x9icaqj158snzl0ilbd0dipl4bmk49is8dh8jvh0z97k700";
rev = "v11.0.0";
sha256 = "0dfwayw6h49hm5ikq6sic0yi44w8hmqx4nx5xfavqk4ary1z3ifq";
};
};
"ansi" = {
......@@ -57,11 +57,11 @@
};
"argonaut-core" = {
name = "argonaut-core";
version = "v5.0.2";
version = "v5.1.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript-contrib/purescript-argonaut-core.git";
rev = "v5.0.2";
sha256 = "1rfd1brvzp9akx6hypxql2qv9bhlcqks1xwqfqqf31dqvcl7vvhc";
rev = "v5.1.0";
sha256 = "0x52vz5pdiamwq9cznm5mkhfcgk6raapqwdj7cmiblkflra32lhr";
};
};
"argonaut-traversals" = {
......@@ -192,11 +192,11 @@
};
"debug" = {
name = "debug";
version = "v4.0.0";
version = "v4.0.1";
src = pkgs.fetchgit {
url = "https://github.com/garyb/purescript-debug.git";
rev = "v4.0.0";
sha256 = "0gwjj80akys0h111i74n429fmny992gx0r4rk1n98gqlqm5cmi21";
rev = "v4.0.1";
sha256 = "03xmchfzx7anks6b3yrrhf5b0bx7n390c814nhhxdl98936wydg4";
};
};
"distributive" = {
......@@ -651,11 +651,11 @@
};
"parsing" = {
name = "parsing";
version = "v5.0.3";
version = "v5.1.0";
src = pkgs.fetchgit {
url = "https://github.com/purescript-contrib/purescript-parsing.git";
rev = "v5.0.3";
sha256 = "0m5xvb5kis28laj3navyyakyq408vw115c2dvngf1vljzh1hk5kj";
rev = "v5.1.0";
sha256 = "199wjj02hh7wzkvh036vqv3369jrw1dpcb11n0nnqlqvvihfcy87";
};
};
"partial" = {
......
......@@ -26,6 +26,17 @@ let
yarn pulp repl
'';
test-ps = pkgs.writeShellScriptBin "test-ps" ''
#!/usr/bin/env bash
set -e
echo "Compiling"
build-purs
echo "Testing"
# yarn pulp browserify --skip-compile -t dist/bundle.js --src-path output
yarn pulp test --src-path output --test-path output
'';
in
pkgs.mkShell {
buildInputs = [
......@@ -35,6 +46,7 @@ pkgs.mkShell {
build
repl
pkgs.yarn
test-ps
];
shellHook = ''
......
......@@ -2,39 +2,60 @@ module Gargantext.Components.NgramsTable.Spec where
import Prelude
import Data.Maybe (Maybe(..))
import Data.Map as Map
import Data.Set as Set
import Data.Tuple (Tuple(..))
import Gargantext.Components.NgramsTable.Core (highlightNgrams, NgramsElement(..), NgramsTable(..))
import Gargantext.Types (TermList(..))
import Test.Spec (Spec, describe, it)
import Test.Spec.Assertions (shouldEqual)
-- import Test.Spec.QuickCheck (quickCheck')
import Data.Map as Map
import Data.Set as Set
{-
import Gargantext.Components.NgramsTable.Core (highlightNgrams, NgramsElement(..), NgramsRepoElement(..), NgramsTable(..), NgramsTerm, normNgram)
import Gargantext.Types (CTabNgramType(..), TermList(..))
ne :: String -> TermList -> CTabNgramType -> NgramsElement
ne ngrams list ngramType = NgramsElement { ngrams: normed
, size: 1 -- TODO
, list
, occurrences: 0
, parent: Nothing
, root: Nothing
, children: Set.empty
}
where
normed = normNgram ngramType ngrams
tne :: String -> TermList -> CTabNgramType -> Tuple NgramsTerm NgramsElement
tne ngrams list ngramType = Tuple normed (ne ngrams list ngramType)
where
normed = normNgram ngramType ngrams
nre :: String -> TermList -> CTabNgramType -> NgramsRepoElement
nre ngrams list ngramType = NgramsRepoElement { size: 1 -- TODO
, list
, parent: Nothing
, root: Nothing
, children: Set.empty
}
tnre :: String -> TermList -> CTabNgramType -> Tuple NgramsTerm NgramsRepoElement
tnre ngrams list ngramType = Tuple normed (nre ngrams list ngramType)
where
normed = normNgram ngramType ngrams
spec :: Spec Unit
spec = do
let ne ngrams list =
NgramsElement
{ ngrams
, list
, occurrences: 0
, parent: Nothing
, root: Nothing
, children: Set.empty
}
tne ngrams list = Tuple ngrams (ne ngrams list)
describe "NgramsTable.highlightNgrams" do
it "works on a simple example" do
let ngramType = CTabSources
let table = NgramsTable
(Map.fromFoldable [tne "graph" GraphTerm
,tne "which" StopTerm
,tne "stops" StopTerm
,tne "candidate" CandidateTerm
])
{ ngrams_repo_elements: Map.fromFoldable [ tnre "which" StopTerm ngramType
, tnre "stops" StopTerm ngramType
, tnre "candidate" CandidateTerm ngramType
]
, ngrams_scores: Map.fromFoldable [] }
input = "this is a graph about a biography which stops at every candidate"
output = [Tuple "this is a " Nothing
,Tuple "graph" (Just GraphTerm)
,Tuple " about a biography " Nothing
,Tuple "which" (Just StopTerm)
,Tuple " " Nothing
......@@ -45,51 +66,53 @@ spec = do
highlightNgrams CTabTerms table input `shouldEqual` output
it "works when pattern overlaps" do
let ngramType = CTabSources
let table = NgramsTable
(Map.fromFoldable [tne "is" StopTerm
,tne "a" StopTerm
,tne "of" StopTerm
,tne "new" GraphTerm
,tne "the" GraphTerm
,tne "state" GraphTerm
])
{ ngrams_repo_elements: Map.fromFoldable [ tnre "is" StopTerm ngramType
, tnre "a" StopTerm ngramType
, tnre "of" StopTerm ngramType
]
, ngrams_scores: Map.fromFoldable [] }
input = "This is a new state of the"
output = [Tuple "This " Nothing
,Tuple "is" (Just StopTerm)
,Tuple " " Nothing
,Tuple "a" (Just StopTerm)
,Tuple " " Nothing
,Tuple "new" (Just GraphTerm)
,Tuple "new" Nothing
,Tuple " " Nothing
,Tuple "state" (Just GraphTerm)
,Tuple "state" Nothing
,Tuple " " Nothing
,Tuple "of" (Just StopTerm)
,Tuple " " Nothing
,Tuple "the" (Just GraphTerm)
,Tuple "the" Nothing
]
highlightNgrams CTabTerms table input `shouldEqual` output
it "works when pattern overlaps 2" do
let ngramType = CTabSources
let table = NgramsTable
(Map.fromFoldable [tne "from" GraphTerm
,tne "i" StopTerm
,tne "images" GraphTerm
])
{ ngrams_repo_elements: Map.fromFoldable [ tnre "from" CandidateTerm ngramType
, tnre "i" StopTerm ngramType
, tnre "images" CandidateTerm ngramType
]
, ngrams_scores: Map.fromFoldable [] }
input = "This is from space images"
output = [Tuple "This is " Nothing
,Tuple "from" (Just GraphTerm)
,Tuple "from" (Just CandidateTerm)
,Tuple " space " Nothing
,Tuple "images" (Just GraphTerm)
,Tuple "images" (Just CandidateTerm)
]
highlightNgrams CTabTerms table input `shouldEqual` output
it "works with punctuation" do
let ngramType = CTabSources
let table = NgramsTable
(Map.fromFoldable [tne "graph" GraphTerm])
{ ngrams_repo_elements: Map.fromFoldable [ tnre "graph" CandidateTerm ngramType ]
, ngrams_scores: Map.fromFoldable [] }
input = "before graph, after"
output = [Tuple "before " Nothing
,Tuple "graph" (Just GraphTerm)
,Tuple "graph" (Just CandidateTerm)
,Tuple ", after" Nothing
]
highlightNgrams CTabTerms table input `shouldEqual` output
-}
This source diff could not be displayed because it is too large. You can view the blob instead.
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