Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
141
Issues
141
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
3870ee90
Commit
3870ee90
authored
Oct 08, 2020
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve text2ngrams to strip spaces
parent
5392065c
Pipeline
#1129
canceled with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
Terms.hs
src/Gargantext/Core/Text/Terms.hs
+5
-5
Ngrams.hs
src/Gargantext/Database/Schema/Ngrams.hs
+8
-6
No files found.
src/Gargantext/Core/Text/Terms.hs
View file @
3870ee90
...
...
@@ -55,7 +55,7 @@ import Gargantext.Core.Text.Terms.Mono.Token.En (tokenize)
import
Gargantext.Core.Text.Terms.Multi
(
multiterms
)
import
Gargantext.Core.Types
import
Gargantext.Database.Prelude
(
Cmd
)
import
Gargantext.Database.Schema.Ngrams
(
Ngrams
(
..
),
NgramsType
(
..
))
import
Gargantext.Database.Schema.Ngrams
(
Ngrams
(
..
),
NgramsType
(
..
)
,
ngramsTerms
,
text2ngrams
)
import
Gargantext.Prelude
...
...
@@ -118,11 +118,11 @@ class ExtractNgramsT h
filterNgramsT
::
Int
->
Map
Ngrams
(
Map
NgramsType
Int
)
->
Map
Ngrams
(
Map
NgramsType
Int
)
filterNgramsT
s
ms
=
Map
.
fromList
$
map
(
\
a
->
filter'
s
a
)
$
Map
.
toList
ms
filterNgramsT
s
ms
=
Map
.
fromList
$
map
filter'
$
Map
.
toList
ms
where
filter'
s'
(
ng
@
(
Ngrams
t
n
),
y
)
=
case
(
Text
.
length
t
)
<
s'
of
True
->
(
ng
,
y
)
False
->
(
Ngrams
(
Text
.
take
s'
t
)
n
,
y
)
filter'
(
ng
,
y
)
|
Text
.
length
(
ng
^.
ngramsTerms
)
<
s
=
(
ng
,
y
)
|
otherwise
=
(
text2ngrams
(
Text
.
take
s
(
ng
^.
ngramsTerms
))
,
y
)
-- =======================================================
...
...
src/Gargantext/Database/Schema/Ngrams.hs
View file @
3870ee90
...
...
@@ -25,7 +25,7 @@ import Control.Monad (mzero)
import
Data.Aeson
import
Data.Aeson.Types
(
toJSONKeyText
)
import
Data.Map
(
Map
,
fromList
,
lookup
)
import
Data.Text
(
Text
,
splitOn
,
pack
)
import
Data.Text
(
Text
,
splitOn
,
pack
,
strip
)
import
Gargantext.Core.Types
(
TODO
(
..
))
import
Gargantext.Prelude
import
Prelude
(
Functor
)
...
...
@@ -140,16 +140,18 @@ fromNgramsTypeId id = lookup id
------------------------------------------------------------------------
-- | TODO put it in Gargantext.Core.Text.Ngrams
data
Ngrams
=
Ngrams
{
_ngramsTerms
::
Text
,
_ngramsSize
::
Int
}
deriving
(
Generic
,
Show
,
Eq
,
Ord
)
data
Ngrams
=
Unsafe
Ngrams
{
_ngramsTerms
::
Text
,
_ngramsSize
::
Int
}
deriving
(
Generic
,
Show
,
Eq
,
Ord
)
makeLenses
''
N
grams
instance
PGS
.
ToRow
Ngrams
where
toRow
(
Ngrams
t
s
)
=
[
toField
t
,
toField
s
]
toRow
(
Unsafe
Ngrams
t
s
)
=
[
toField
t
,
toField
s
]
text2ngrams
::
Text
->
Ngrams
text2ngrams
txt
=
Ngrams
txt
$
length
$
splitOn
" "
txt
text2ngrams
txt
=
UnsafeNgrams
txt'
$
length
$
splitOn
" "
txt'
where
txt'
=
strip
txt
-------------------------------------------------------------------------
-- | TODO put it in Gargantext.Core.Text.Ngrams
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment