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
153
Issues
153
List
Board
Labels
Milestones
Merge Requests
10
Merge Requests
10
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
37a36aba
Commit
37a36aba
authored
Sep 13, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[refactoring] rewrite for better record syntax
parent
bfc3b776
Pipeline
#1801
passed with stage
in 33 minutes and 6 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
176 additions
and
111 deletions
+176
-111
package.yaml
package.yaml
+2
-0
API.hs
src/Gargantext/API.hs
+1
-1
Searx.hs
src/Gargantext/API/Node/Corpus/Searx.hs
+0
-1
Search.hs
src/Gargantext/API/Search.hs
+0
-1
IMT.hs
src/Gargantext/Core/Ext/IMT.hs
+50
-49
IMTUser.hs
src/Gargantext/Core/Ext/IMTUser.hs
+84
-43
Distances.hs
src/Gargantext/Core/Methods/Distances.hs
+3
-0
NodeStory.hs
src/Gargantext/Core/NodeStory.hs
+21
-6
Patch.hs
src/Gargantext/Core/Text/List/Social/Patch.hs
+15
-8
Search.hs
src/Gargantext/Core/Text/Search.hs
+0
-2
No files found.
package.yaml
View file @
37a36aba
...
@@ -22,9 +22,11 @@ default-extensions:
...
@@ -22,9 +22,11 @@ default-extensions:
-
FlexibleInstances
-
FlexibleInstances
-
GeneralizedNewtypeDeriving
-
GeneralizedNewtypeDeriving
-
MultiParamTypeClasses
-
MultiParamTypeClasses
-
NamedFieldPuns
-
NoImplicitPrelude
-
NoImplicitPrelude
-
OverloadedStrings
-
OverloadedStrings
-
RankNTypes
-
RankNTypes
-
RecordWildCards
library
:
library
:
source-dirs
:
src
source-dirs
:
src
ghc-options
:
ghc-options
:
...
...
src/Gargantext/API.hs
View file @
37a36aba
...
@@ -59,7 +59,7 @@ import System.IO (FilePath)
...
@@ -59,7 +59,7 @@ import System.IO (FilePath)
data
Mode
=
Dev
|
Mock
|
Prod
data
Mode
=
Dev
|
Mock
|
Prod
deriving
(
Show
,
Read
,
Generic
)
deriving
(
Show
,
Read
,
Generic
)
-- | startGargantext takes as parameters port number and Ini file.
-- | startGargantext takes as parameters port number and Ini file.
startGargantext
::
Mode
->
PortNumber
->
FilePath
->
IO
()
startGargantext
::
Mode
->
PortNumber
->
FilePath
->
IO
()
...
...
src/Gargantext/API/Node/Corpus/Searx.hs
View file @
37a36aba
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TemplateHaskell #-}
module
Gargantext.API.Node.Corpus.Searx
where
module
Gargantext.API.Node.Corpus.Searx
where
...
...
src/Gargantext/API/Search.hs
View file @
37a36aba
...
@@ -10,7 +10,6 @@ Portability : POSIX
...
@@ -10,7 +10,6 @@ Portability : POSIX
Count API part of Gargantext.
Count API part of Gargantext.
-}
-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveAnyClass #-}
...
...
src/Gargantext/Core/Ext/IMT.hs
View file @
37a36aba
...
@@ -33,73 +33,74 @@ data School = School { school_shortName :: Text
...
@@ -33,73 +33,74 @@ data School = School { school_shortName :: Text
schools
::
[
School
]
schools
::
[
School
]
schools
=
[
School
schools
=
[
School
(
"Mines Albi-Carmaux"
)
{
school_shortName
=
"Mines Albi-Carmaux"
(
"Mines Albi-Carmaux - École nationale supérieure des Mines d'Albi‐Carmaux"
)
,
school_longName
=
"Mines Albi-Carmaux - École nationale supérieure des Mines d'Albi‐Carmaux"
(
"469216"
)
,
school_id
=
"469216"
}
,
School
,
School
(
"Mines Alès"
)
{
school_shortName
=
"Mines Alès"
(
"EMA - École des Mines d'Alès"
)
,
school_longName
=
"EMA - École des Mines d'Alès"
(
"6279"
)
,
school_id
=
"6279"
}
,
School
,
School
(
"Mines Douai"
)
{
school_shortName
=
"Mines Douai"
(
"Mines Douai EMD - École des Mines de Douai"
)
,
school_longName
=
"Mines Douai EMD - École des Mines de Douai"
(
"224096"
)
,
school_id
=
"224096"
}
,
School
,
School
(
"Mines Lille"
)
{
school_shortName
=
"Mines Lille"
(
"Mines Lille - École des Mines de Lille"
)
,
school_longName
=
"Mines Lille - École des Mines de Lille"
(
"144103"
)
,
school_id
=
"144103"
}
,
School
,
School
(
"IMT Lille Douai"
)
{
school_shortName
=
"IMT Lille Douai"
(
"IMT Lille Douai"
)
,
school_longName
=
"IMT Lille Douai"
(
"497330"
)
,
school_id
=
"497330"
}
,
School
,
School
(
"Mines Nantes"
)
{
school_shortName
=
"Mines Nantes"
(
"Mines Nantes - Mines Nantes"
)
,
school_longName
=
"Mines Nantes - Mines Nantes"
(
"84538"
)
,
school_id
=
"84538"
}
,
School
,
School
(
"Télécom Bretagne"
)
{
school_shortName
=
"Télécom Bretagne"
(
"Télécom Bretagne"
)
,
school_longName
=
"Télécom Bretagne"
(
"301262"
)
,
school_id
=
"301262"
}
,
School
,
School
(
"IMT Atlantique"
)
{
school_shortName
=
"IMT Atlantique"
(
"IMT Atlantique - IMT Atlantique Bretagne-Pays de la Loire"
)
,
school_longName
=
"IMT Atlantique - IMT Atlantique Bretagne-Pays de la Loire"
(
"481355"
)
,
school_id
=
"481355"
}
,
School
,
School
(
"Mines Saint-Étienne"
)
{
school_shortName
=
"Mines Saint-Étienne"
(
"Mines Saint-Étienne MSE - École des Mines de Saint-Étienne"
)
,
school_longName
=
"Mines Saint-Étienne MSE - École des Mines de Saint-Étienne"
(
"29212"
)
,
school_id
=
"29212"
}
,
School
,
School
(
"Télécom École de Management"
)
{
school_shortName
=
"Télécom École de Management"
(
"TEM - Télécom Ecole de Management"
)
,
school_longName
=
"TEM - Télécom Ecole de Management"
(
"301442"
)
,
school_id
=
"301442"
}
,
School
,
School
(
"IMT Business School"
)
{
school_shortName
=
"IMT Business School"
(
"IMT Business School"
)
,
school_longName
=
"IMT Business School"
(
"542824"
)
,
school_id
=
"542824"
}
,
School
,
School
(
"Télécom ParisTech"
)
{
school_shortName
=
"Télécom ParisTech"
(
"Télécom ParisTech"
)
,
school_longName
=
"Télécom ParisTech"
(
"300362"
)
,
school_id
=
"300362"
}
,
School
,
School
(
"Télécom SudParis"
)
{
school_shortName
=
"Télécom SudParis"
(
"TSP - Télécom SudParis"
)
,
school_longName
=
"TSP - Télécom SudParis"
(
"352124"
)
,
school_id
=
"352124"
}
,
School
,
School
(
"ARMINES"
)
{
school_shortName
=
"ARMINES"
(
"ARMINES"
)
,
school_longName
=
"ARMINES"
(
"300362"
)
,
school_id
=
"300362"
}
,
School
,
School
(
"Eurecom"
)
{
school_shortName
=
"Eurecom"
(
"Eurecom"
)
,
school_longName
=
"Eurecom"
(
"421532"
)
,
school_id
=
"421532"
}
,
School
,
School
(
"Mines ParisTech"
)
{
school_shortName
=
"Mines ParisTech"
(
"MINES ParisTech - École nationale supérieure des mines de Paris"
)
,
school_longName
=
"MINES ParisTech - École nationale supérieure des mines de Paris"
(
"301492"
)
,
school_id
=
"301492"
}
]
]
mapIdSchool
::
Map
Text
Text
mapIdSchool
::
Map
Text
Text
mapIdSchool
=
M
.
fromList
$
Gargantext
.
Prelude
.
map
(
\
(
School
n
_
i
)
->
(
i
,
n
))
schools
mapIdSchool
=
M
.
fromList
$
Gargantext
.
Prelude
.
map
(
\
(
School
{
school_shortName
,
school_id
})
->
(
school_id
,
school_shortName
))
schools
hal_data
::
IO
(
Either
Prelude
.
String
(
DV
.
Vector
CsvHal
))
hal_data
::
IO
(
Either
Prelude
.
String
(
DV
.
Vector
CsvHal
))
hal_data
=
do
hal_data
=
do
...
...
src/Gargantext/Core/Ext/IMTUser.hs
View file @
37a36aba
...
@@ -75,37 +75,39 @@ data IMTUser = IMTUser
...
@@ -75,37 +75,39 @@ data IMTUser = IMTUser
-- | CSV instance
-- | CSV instance
instance
FromNamedRecord
IMTUser
where
instance
FromNamedRecord
IMTUser
where
parseNamedRecord
r
=
IMTUser
<$>
r
.:
"id"
parseNamedRecord
r
=
do
<*>
r
.:
"entite"
id
<-
r
.:
"id"
<*>
r
.:
"mail"
entite
<-
r
.:
"entite"
<*>
r
.:
"nom"
mail
<-
r
.:
"mail"
<*>
r
.:
"prenom"
nom
<-
r
.:
"nom"
<*>
r
.:
"fonction"
prenom
<-
r
.:
"prenom"
<*>
r
.:
"fonction2"
fonction
<-
r
.:
"fonction"
<*>
r
.:
"tel"
fonction2
<-
r
.:
"fonction2"
<*>
r
.:
"fax"
tel
<-
r
.:
"tel"
<*>
r
.:
"service"
fax
<-
r
.:
"fax"
<*>
r
.:
"groupe"
service
<-
r
.:
"service"
<*>
r
.:
"entite2"
groupe
<-
r
.:
"groupe"
<*>
r
.:
"service2"
entite2
<-
r
.:
"entite2"
<*>
r
.:
"groupe2"
service2
<-
r
.:
"service2"
<*>
r
.:
"bureau"
groupe2
<-
r
.:
"groupe2"
<*>
r
.:
"url"
bureau
<-
r
.:
"bureau"
<*>
r
.:
"pservice"
url
<-
r
.:
"url"
<*>
r
.:
"pfonction"
pservice
<-
r
.:
"pservice"
<*>
r
.:
"afonction"
pfonction
<-
r
.:
"pfonction"
<*>
r
.:
"afonction2"
afonction
<-
r
.:
"afonction"
<*>
r
.:
"grprech"
afonction2
<-
r
.:
"afonction2"
<*>
r
.:
"appellation"
grprech
<-
r
.:
"grprech"
<*>
r
.:
"lieu"
appellation
<-
r
.:
"appellation"
<*>
r
.:
"aprecision"
lieu
<-
r
.:
"lieu"
<*>
r
.:
"atel"
aprecision
<-
r
.:
"aprecision"
<*>
r
.:
"sexe"
atel
<-
r
.:
"atel"
<*>
r
.:
"statut"
sexe
<-
r
.:
"sexe"
<*>
r
.:
"idutilentite"
statut
<-
r
.:
"statut"
<*>
r
.:
"actif"
idutilentite
<-
r
.:
"idutilentite"
<*>
r
.:
"idutilsiecoles"
actif
<-
r
.:
"actif"
<*>
r
.:
"date_modification"
idutilsiecoles
<-
r
.:
"idutilsiecoles"
date_modification
<-
r
.:
"date_modification"
pure
$
IMTUser
{
..
}
headerCSVannuaire
::
Header
headerCSVannuaire
::
Header
headerCSVannuaire
=
headerCSVannuaire
=
...
@@ -136,15 +138,54 @@ deserialiseFromFile' filepath = deserialise <$> BL.readFile filepath
...
@@ -136,15 +138,54 @@ deserialiseFromFile' filepath = deserialise <$> BL.readFile filepath
------------------------------------------------------------------------
------------------------------------------------------------------------
imtUser2gargContact
::
IMTUser
->
HyperdataContact
imtUser2gargContact
::
IMTUser
->
HyperdataContact
imtUser2gargContact
(
IMTUser
id'
entite'
mail'
nom'
prenom'
fonction'
_fonction2'
tel'
_fax'
--imtUser2gargContact (IMTUser id' entite' mail' nom' prenom' fonction' _fonction2' tel' _fax'
service'
_groupe'
_entite2
_service2
_group2
bureau'
url'
_pservice'
_pfonction'
_afonction'
_afonction2'
-- service' _groupe' _entite2 _service2 _group2 bureau' url' _pservice' _pfonction' _afonction' _afonction2'
_grprech'
_appellation'
lieu'
_aprecision'
_atel'
_sexe'
_statut'
_idutilentite'
-- _grprech' _appellation' lieu' _aprecision' _atel' _sexe' _statut' _idutilentite'
_actif'
_idutilsiecoles'
date_modification'
)
-- _actif' _idutilsiecoles' date_modification')
=
HyperdataContact
(
Just
"IMT Annuaire"
)
(
Just
qui
)
[
ou
]
((
<>
)
<$>
(
fmap
(
\
p
->
p
<>
" "
)
prenom'
)
<*>
nom'
)
entite'
date_modification'
Nothing
Nothing
-- = HyperdataContact (Just "IMT Annuaire") (Just qui) [ou] ((<>) <$> (fmap (\p -> p <> " ") prenom') <*> nom') entite' date_modification' Nothing Nothing
where
imtUser2gargContact
(
IMTUser
{
id
qui
=
ContactWho
id'
prenom'
nom'
(
catMaybes
[
service'
])
[]
,
entite
ou
=
ContactWhere
(
toList
entite'
)
(
toList
service'
)
fonction'
bureau'
(
Just
"France"
)
lieu'
contact
Nothing
Nothing
,
mail
contact
=
Just
$
ContactTouch
mail'
tel'
url'
,
nom
-- meta = ContactMetaData (Just "IMT annuaire") date_modification'
,
prenom
toList
Nothing
=
[]
,
fonction
toList
(
Just
x
)
=
[
x
]
,
tel
,
service
,
bureau
,
url
,
lieu
,
date_modification
})
=
HyperdataContact
{
_hc_bdd
=
Just
"IMT Annuaire"
,
_hc_who
=
Just
qui
,
_hc_where
=
[
ou
]
,
_hc_title
=
title
,
_hc_source
=
entite
,
_hc_lastValidation
=
date_modification
,
_hc_uniqIdBdd
=
Nothing
,
_hc_uniqId
=
Nothing
}
where
title
=
(
<>
)
<$>
(
fmap
(
\
p
->
p
<>
" "
)
prenom
)
<*>
nom
qui
=
ContactWho
{
_cw_id
=
id
,
_cw_firstName
=
prenom
,
_cw_lastName
=
nom
,
_cw_keywords
=
catMaybes
[
service
]
,
_cw_freetags
=
[]
}
ou
=
ContactWhere
{
_cw_organization
=
toList
entite
,
_cw_labTeamDepts
=
toList
service
,
_cw_role
=
fonction
,
_cw_office
=
bureau
,
_cw_country
=
Just
"France"
,
_cw_city
=
lieu
,
_cw_touch
=
contact
,
_cw_entry
=
Nothing
,
_cw_exit
=
Nothing
}
contact
=
Just
$
ContactTouch
{
_ct_mail
=
mail
,
_ct_phone
=
tel
,
_ct_url
=
url
}
-- meta = ContactMetaData (Just "IMT annuaire") date_modification'
toList
Nothing
=
[]
toList
(
Just
x
)
=
[
x
]
src/Gargantext/Core/Methods/Distances.hs
View file @
37a36aba
...
@@ -50,3 +50,6 @@ instance Arbitrary GraphMetric where
...
@@ -50,3 +50,6 @@ instance Arbitrary GraphMetric where
arbitrary
=
elements
[
minBound
..
maxBound
]
arbitrary
=
elements
[
minBound
..
maxBound
]
------------------------------------------------------------------------
------------------------------------------------------------------------
src/Gargantext/Core/NodeStory.hs
View file @
37a36aba
...
@@ -82,7 +82,9 @@ readNodeStoryEnv :: NodeStoryDir -> IO NodeStoryEnv
...
@@ -82,7 +82,9 @@ readNodeStoryEnv :: NodeStoryDir -> IO NodeStoryEnv
readNodeStoryEnv
nsd
=
do
readNodeStoryEnv
nsd
=
do
mvar
<-
nodeStoryVar
nsd
Nothing
[
0
]
mvar
<-
nodeStoryVar
nsd
Nothing
[
0
]
saver
<-
mkNodeStorySaver
nsd
mvar
saver
<-
mkNodeStorySaver
nsd
mvar
pure
$
NodeStoryEnv
mvar
saver
(
nodeStoryVar
nsd
(
Just
mvar
))
pure
$
NodeStoryEnv
{
_nse_var
=
mvar
,
_nse_saver
=
saver
,
_nse_getter
=
nodeStoryVar
nsd
(
Just
mvar
)
}
------------------------------------------------------------------------
------------------------------------------------------------------------
mkNodeStorySaver
::
NodeStoryDir
->
MVar
NodeListStory
->
IO
(
IO
()
)
mkNodeStorySaver
::
NodeStoryDir
->
MVar
NodeListStory
->
IO
(
IO
()
)
...
@@ -212,7 +214,9 @@ repoToNodeListStory (Repo _v s h) = NodeStory $ Map.fromList ns
...
@@ -212,7 +214,9 @@ repoToNodeListStory (Repo _v s h) = NodeStory $ Map.fromList ns
h'
=
ngramsStatePatch_migration
h
h'
=
ngramsStatePatch_migration
h
ns
=
List
.
map
(
\
(
n
,
ns'
)
ns
=
List
.
map
(
\
(
n
,
ns'
)
->
(
n
,
let
hs
=
fromMaybe
[]
(
Map
.
lookup
n
h'
)
in
->
(
n
,
let
hs
=
fromMaybe
[]
(
Map
.
lookup
n
h'
)
in
Archive
(
List
.
length
hs
)
ns'
hs
Archive
{
_a_version
=
List
.
length
hs
,
_a_state
=
ns'
,
_a_history
=
hs
}
)
)
)
$
Map
.
toList
s'
)
$
Map
.
toList
s'
...
@@ -276,10 +280,17 @@ instance Serialise NgramsStatePatch'
...
@@ -276,10 +280,17 @@ instance Serialise NgramsStatePatch'
-- TODO Semigroup instance for unions
-- TODO Semigroup instance for unions
-- TODO check this
-- TODO check this
instance
(
Semigroup
s
,
Semigroup
p
)
=>
Semigroup
(
Archive
s
p
)
where
instance
(
Semigroup
s
,
Semigroup
p
)
=>
Semigroup
(
Archive
s
p
)
where
(
<>
)
(
Archive
_v
_s
p
)
(
Archive
v'
s'
p'
)
=
Archive
v'
s'
(
p'
<>
p
)
(
<>
)
(
Archive
{
_a_history
=
p
})
(
Archive
{
_a_version
=
v'
,
_a_state
=
s'
,
_a_history
=
p'
})
=
Archive
{
_a_version
=
v'
,
_a_state
=
s'
,
_a_history
=
p'
<>
p
}
instance
Monoid
(
Archive
NgramsState'
NgramsStatePatch'
)
where
instance
Monoid
(
Archive
NgramsState'
NgramsStatePatch'
)
where
mempty
=
Archive
0
mempty
[]
mempty
=
Archive
{
_a_version
=
0
,
_a_state
=
mempty
,
_a_history
=
[]
}
instance
(
FromJSON
s
,
FromJSON
p
)
=>
FromJSON
(
Archive
s
p
)
where
instance
(
FromJSON
s
,
FromJSON
p
)
=>
FromJSON
(
Archive
s
p
)
where
parseJSON
=
genericParseJSON
$
unPrefix
"_a_"
parseJSON
=
genericParseJSON
$
unPrefix
"_a_"
...
@@ -293,13 +304,17 @@ initNodeStory :: Monoid s => NodeId -> NodeStory s p
...
@@ -293,13 +304,17 @@ initNodeStory :: Monoid s => NodeId -> NodeStory s p
initNodeStory
ni
=
NodeStory
$
Map
.
singleton
ni
initArchive
initNodeStory
ni
=
NodeStory
$
Map
.
singleton
ni
initArchive
initArchive
::
Monoid
s
=>
Archive
s
p
initArchive
::
Monoid
s
=>
Archive
s
p
initArchive
=
Archive
0
mempty
[]
initArchive
=
Archive
{
_a_version
=
0
,
_a_state
=
mempty
,
_a_history
=
[]
}
initNodeListStoryMock
::
NodeListStory
initNodeListStoryMock
::
NodeListStory
initNodeListStoryMock
=
NodeStory
$
Map
.
singleton
nodeListId
archive
initNodeListStoryMock
=
NodeStory
$
Map
.
singleton
nodeListId
archive
where
where
nodeListId
=
0
nodeListId
=
0
archive
=
Archive
0
ngramsTableMap
[]
archive
=
Archive
{
_a_version
=
0
,
_a_state
=
ngramsTableMap
,
_a_history
=
[]
}
ngramsTableMap
=
Map
.
singleton
TableNgrams
.
NgramsTerms
ngramsTableMap
=
Map
.
singleton
TableNgrams
.
NgramsTerms
$
Map
.
fromList
$
Map
.
fromList
[
(
n
^.
ne_ngrams
,
ngramsElementToRepo
n
)
[
(
n
^.
ne_ngrams
,
ngramsElementToRepo
n
)
...
...
src/Gargantext/Core/Text/List/Social/Patch.hs
View file @
37a36aba
...
@@ -70,9 +70,11 @@ Children are not modified in this specific case.
...
@@ -70,9 +70,11 @@ Children are not modified in this specific case.
-- | Old list get -1 score
-- | Old list get -1 score
-- New list get +1 score
-- New list get +1 score
-- Hence others lists lay around 0 score
-- Hence others lists lay around 0 score
addScorePatch
fl
(
t
,
(
NgramsPatch
children'
(
Patch
.
Replace
old_list
new_list
)))
=
addScorePatch
fl
(
t
,
(
NgramsPatch
{
_patch_children
,
_patch_list
=
Patch
.
Replace
old_list
new_list
}))
=
-- Adding new 'Children' score
-- Adding new 'Children' score
addScorePatch
fl'
(
t
,
NgramsPatch
children'
Patch
.
Keep
)
addScorePatch
fl'
(
t
,
NgramsPatch
{
_patch_children
,
_patch_list
=
Patch
.
Keep
})
where
where
-- | Adding new 'ListType' score
-- | Adding new 'ListType' score
fl'
=
fl
&
flc_scores
.
at
t
%~
(
score
fls_listType
old_list
(
-
1
))
fl'
=
fl
&
flc_scores
.
at
t
%~
(
score
fls_listType
old_list
(
-
1
))
...
@@ -80,8 +82,9 @@ addScorePatch fl (t, (NgramsPatch children' (Patch.Replace old_list new_list)))
...
@@ -80,8 +82,9 @@ addScorePatch fl (t, (NgramsPatch children' (Patch.Replace old_list new_list)))
&
flc_cont
%~
(
HashMap
.
delete
t
)
&
flc_cont
%~
(
HashMap
.
delete
t
)
-- | Patching existing Ngrams with children
-- | Patching existing Ngrams with children
addScorePatch
fl
(
p
,
NgramsPatch
children'
Patch
.
Keep
)
=
addScorePatch
fl
(
p
,
NgramsPatch
{
_patch_children
foldl'
addChild
fl
$
patchMSet_toList
children'
,
_patch_list
=
Patch
.
Keep
})
=
foldl'
addChild
fl
$
patchMSet_toList
_patch_children
where
where
-- | Adding a child
-- | Adding a child
addChild
fl'
(
t
,
Patch
.
Replace
Nothing
(
Just
_
))
=
doLink
(
1
)
p
t
fl'
addChild
fl'
(
t
,
Patch
.
Replace
Nothing
(
Just
_
))
=
doLink
(
1
)
p
t
fl'
...
@@ -92,20 +95,24 @@ addScorePatch fl (p, NgramsPatch children' Patch.Keep) =
...
@@ -92,20 +95,24 @@ addScorePatch fl (p, NgramsPatch children' Patch.Keep) =
addChild
fl'
_
=
fl'
addChild
fl'
_
=
fl'
-- | Inserting a new Ngrams
-- | Inserting a new Ngrams
addScorePatch
fl
(
t
,
NgramsReplace
Nothing
(
Just
nre
))
=
addScorePatch
fl
(
t
,
NgramsReplace
{
_patch_old
=
Nothing
,
_patch_new
=
Just
nre
})
=
childrenScore
1
t
(
nre
^.
nre_children
)
childrenScore
1
t
(
nre
^.
nre_children
)
$
fl
&
flc_scores
.
at
t
%~
(
score
fls_listType
$
nre
^.
nre_list
)
1
$
fl
&
flc_scores
.
at
t
%~
(
score
fls_listType
$
nre
^.
nre_list
)
1
&
flc_cont
%~
(
HashMap
.
delete
t
)
&
flc_cont
%~
(
HashMap
.
delete
t
)
addScorePatch
fl
(
t
,
NgramsReplace
(
Just
old_nre
)
maybe_new_nre
)
=
addScorePatch
fl
(
t
,
NgramsReplace
{
_patch_old
=
Just
old_nre
,
_patch_new
=
maybe_new_nre
})
=
let
fl'
=
childrenScore
(
-
1
)
t
(
old_nre
^.
nre_children
)
let
fl'
=
childrenScore
(
-
1
)
t
(
old_nre
^.
nre_children
)
$
fl
&
flc_scores
.
at
t
%~
(
score
fls_listType
$
old_nre
^.
nre_list
)
(
-
1
)
$
fl
&
flc_scores
.
at
t
%~
(
score
fls_listType
$
old_nre
^.
nre_list
)
(
-
1
)
&
flc_cont
%~
(
HashMap
.
delete
t
)
&
flc_cont
%~
(
HashMap
.
delete
t
)
in
case
maybe_new_nre
of
in
case
maybe_new_nre
of
Nothing
->
fl'
Nothing
->
fl'
Just
new_nre
->
addScorePatch
fl'
(
t
,
NgramsReplace
Nothing
(
Just
new_nre
))
Just
new_nre
->
addScorePatch
fl'
(
t
,
NgramsReplace
{
_patch_old
=
Nothing
,
_patch_new
=
Just
new_nre
})
addScorePatch
fl
(
_
,
NgramsReplace
Nothing
Nothing
)
=
fl
addScorePatch
fl
(
_
,
NgramsReplace
{
_patch_old
=
Nothing
,
_patch_new
=
Nothing
})
=
fl
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- | Utils
-- | Utils
...
...
src/Gargantext/Core/Text/Search.hs
View file @
37a36aba
...
@@ -13,8 +13,6 @@ Starting from this model, a specific Gargantext engine will be made
...
@@ -13,8 +13,6 @@ Starting from this model, a specific Gargantext engine will be made
(using more metrics scores/features).
(using more metrics scores/features).
-}
-}
{-# LANGUAGE NamedFieldPuns #-}
module
Gargantext.Core.Text.Search
where
module
Gargantext.Core.Text.Search
where
import
Data.SearchEngine
import
Data.SearchEngine
...
...
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