Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Przemyslaw Kaminski
haskell-gargantext
Commits
cc89bb12
Commit
cc89bb12
authored
Jul 24, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[LEARN API]
parent
ae1c032e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
34 deletions
+31
-34
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+6
-2
Tools.hs
src/Gargantext/API/Ngrams/Tools.hs
+5
-8
Node.hs
src/Gargantext/API/Node.hs
+3
-0
Learn.hs
src/Gargantext/Database/Learn.hs
+16
-19
Metrics.hs
src/Gargantext/Database/Metrics.hs
+1
-1
NgramsByNode.hs
src/Gargantext/Database/Metrics/NgramsByNode.hs
+0
-4
No files found.
src/Gargantext/API/Ngrams.hs
View file @
cc89bb12
...
...
@@ -99,18 +99,22 @@ instance ToParamSchema TODO where
------------------------------------------------------------------------
--data FacetFormat = Table | Chart
data
TabType
=
Docs
|
Terms
|
Sources
|
Authors
|
Institutes
|
Trash
data
TabType
=
Docs
|
Trash
|
MoreFav
|
MoreTrash
|
Terms
|
Sources
|
Authors
|
Institutes
|
Contacts
deriving
(
Generic
,
Enum
,
Bounded
)
instance
FromHttpApiData
TabType
where
parseUrlPiece
"Docs"
=
pure
Docs
parseUrlPiece
"Trash"
=
pure
Trash
parseUrlPiece
"MoreFav"
=
pure
MoreFav
parseUrlPiece
"MoreTrash"
=
pure
MoreTrash
parseUrlPiece
"Terms"
=
pure
Terms
parseUrlPiece
"Sources"
=
pure
Sources
parseUrlPiece
"Institutes"
=
pure
Institutes
parseUrlPiece
"Authors"
=
pure
Authors
parseUrlPiece
"Trash"
=
pure
Trash
parseUrlPiece
"Contacts"
=
pure
Contacts
...
...
src/Gargantext/API/Ngrams/Tools.hs
View file @
cc89bb12
...
...
@@ -33,7 +33,6 @@ import qualified Data.Set as Set
type
RootTerm
=
Text
getListNgrams
::
RepoCmdM
env
err
m
=>
[
ListId
]
->
NgramsType
->
m
(
Map
Text
NgramsRepoElement
)
...
...
@@ -68,7 +67,7 @@ mapTermListRoot :: RepoCmdM env err m
->
m
(
Map
Text
(
ListType
,
(
Maybe
Text
)))
mapTermListRoot
nodeIds
ngramsType
=
do
ngrams
<-
getListNgrams
nodeIds
ngramsType
pure
$
Map
.
fromList
[(
t
,
(
_nre_list
nre
,
_nre_root
nre
))
pure
$
Map
.
fromList
[
(
t
,
(
_nre_list
nre
,
_nre_root
nre
))
|
(
t
,
nre
)
<-
Map
.
toList
ngrams
]
...
...
@@ -104,14 +103,12 @@ getCoocByNgrams = getCoocByNgrams' identity
getCoocByNgrams'
::
(
Ord
a
,
Ord
c
)
=>
(
b
->
Set
c
)
->
Diagonal
->
Map
a
b
->
Map
(
a
,
a
)
Int
getCoocByNgrams'
f
(
Diagonal
diag
)
m
=
Map
.
fromList
[((
t1
,
t2
)
,
maybe
0
Set
.
size
$
Set
.
intersection
<$>
(
fmap
f
$
Map
.
lookup
t1
m
)
<*>
(
fmap
f
$
Map
.
lookup
t2
m
)
Map
.
fromList
[(
(
t1
,
t2
)
,
maybe
0
Set
.
size
$
Set
.
intersection
<$>
(
fmap
f
$
Map
.
lookup
t1
m
)
<*>
(
fmap
f
$
Map
.
lookup
t2
m
)
)
|
(
t1
,
t2
)
<-
case
diag
of
True
->
[
(
x
,
y
)
|
x
<-
Map
.
keys
m
,
y
<-
Map
.
keys
m
,
x
<=
y
]
False
->
listToCombi
identity
(
Map
.
keys
m
)
]
src/Gargantext/API/Node.hs
View file @
cc89bb12
...
...
@@ -63,6 +63,7 @@ import Gargantext.Database.Schema.NodeNode (nodeNodesCategory)
import
Gargantext.Database.Tree
(
treeDB
)
import
Gargantext.Database.Types.Node
import
Gargantext.Database.Utils
-- (Cmd, CmdM)
import
Gargantext.Database.Learn
(
FavOrTrash
(
..
),
moreLike
)
import
Gargantext.Prelude
import
Gargantext.Prelude.Utils
(
hash
)
import
Gargantext.Viz.Chart
...
...
@@ -329,6 +330,8 @@ getTable cId ft o l order =
case
ft
of
(
Just
Docs
)
->
runViewDocuments
cId
False
o
l
order
(
Just
Trash
)
->
runViewDocuments
cId
True
o
l
order
(
Just
MoreFav
)
->
moreLike
cId
o
l
order
IsFav
(
Just
MoreTrash
)
->
moreLike
cId
o
l
order
IsTrash
_
->
panic
"not implemented"
getPairing
::
ContactId
->
Maybe
TabType
...
...
src/Gargantext/Database/Learn.hs
View file @
cc89bb12
...
...
@@ -27,27 +27,22 @@ import Gargantext.Prelude
import
Gargantext.Text.Learn
import
qualified
Data.List
as
List
import
qualified
Data.Text
as
Text
import
Gargantext.Database.Schema.NodeNode
(
nodeNodesCategory
)
--import Gargantext.Database.Utils (Cmd)
--import Gargantext.Database.Schema.Node (HasNodeError)
import
Gargantext.API
import
Gargantext.API.Settings
import
Gargantext.Database.Flow
(
FlowCmdM
)
--import Gargantext.Database.Schema.NodeNode (nodeNodesCategory)
import
Gargantext.Database.Utils
(
Cmd
)
import
Gargantext.Core.Types
(
Offset
,
Limit
)
data
FavOrTrash
=
IsFav
|
IsTrash
deriving
(
Eq
)
--moreLike :: FlowCmdM env error m => FavOrTrash -> CorpusId -> m (Events Bool, [FacetDoc])
moreLike
::
FlowCmdM
DevEnv
GargError
m
=>
FavOrTrash
->
CorpusId
->
m
[
FacetDoc
]
moreLike
ft
cId
=
do
moreLike
::
CorpusId
->
Maybe
Offset
->
Maybe
Limit
->
Maybe
OrderBy
->
FavOrTrash
->
Cmd
err
[
FacetDoc
]
moreLike
cId
o
l
order
ft
=
do
priors
<-
getPriors
ft
cId
moreLikeWith
priors
ft
cId
moreLikeWith
cId
o
l
order
ft
priors
---------------------------------------------------------------------------
getPriors
::
F
lowCmdM
DevEnv
GargError
m
=>
FavOrTrash
->
CorpusId
->
m
(
Events
Bool
)
getPriors
::
F
avOrTrash
->
CorpusId
->
Cmd
err
(
Events
Bool
)
getPriors
ft
cId
=
do
docs_trash
<-
runViewDocuments
cId
True
Nothing
Nothing
Nothing
...
...
@@ -61,11 +56,12 @@ getPriors ft cId = do
pure
priors
moreLikeWith
::
FlowCmdM
DevEnv
GargError
m
=>
Events
Bool
->
FavOrTrash
->
CorpusId
->
m
[
FacetDoc
]
moreLikeWith
priors
ft
cId
=
do
moreLikeWith
::
CorpusId
->
Maybe
Offset
->
Maybe
Limit
->
Maybe
OrderBy
->
FavOrTrash
->
Events
Bool
->
Cmd
err
[
FacetDoc
]
moreLikeWith
cId
o
l
order
ft
priors
=
do
docs_test
<-
filter
(
\
(
FacetDoc
_
_
_
_
f
_
)
->
f
==
0
)
<$>
runViewDocuments
cId
False
Nothing
Nothing
Nothing
<$>
runViewDocuments
cId
False
o
l
order
let
results
=
map
fst
$
filter
((
==
)
(
Just
$
not
$
fav2bool
ft
)
.
snd
)
...
...
@@ -86,7 +82,8 @@ text (FacetDoc _ _ _ h _ _) = title <> "" <> Text.take 100 abstr
---------------------------------------------------------------------------
apply
::
(
FlowCmdM
DevEnv
GargError
m
)
=>
FavOrTrash
->
CorpusId
->
[
NodeId
]
->
m
[
Int
]
{-
apply :: (FlowCmdM env e m) => FavOrTrash -> CorpusId -> [NodeId] -> m [Int]
apply favTrash cId ns = case favTrash of
IsFav -> nodeNodesCategory $ map (\n -> (cId, n, 2)) ns
IsTrash -> nodeNodesCategory $ map (\n -> (cId, n, 0)) ns
...
...
@@ -98,6 +95,6 @@ moreLikeAndApply ft cId = do
moreLikeWithAndApply :: FlowCmdM DevEnv GargError m => Events Bool -> FavOrTrash -> CorpusId -> m [Int]
moreLikeWithAndApply priors ft cId = do
ids
<-
map
facetDoc_id
<$>
moreLikeWith
priors
ft
cId
ids <- map facetDoc_id <$> moreLikeWith
cId ft priors
apply ft cId ids
-}
src/Gargantext/Database/Metrics.hs
View file @
cc89bb12
...
...
@@ -35,7 +35,6 @@ import Gargantext.Text.Metrics (scored, Scored(..), {-localMetrics, toScored-})
import
qualified
Data.Map
as
Map
--import qualified Data.Vector.Storable as Vec
getMetrics
::
FlowCmdM
env
err
m
=>
CorpusId
->
Maybe
ListId
->
TabType
->
Maybe
Limit
->
m
(
Map
Text
(
ListType
,
Maybe
Text
),
[
Scored
Text
])
...
...
@@ -72,6 +71,7 @@ getNgrams :: (FlowCmdM env err m)
=>
CorpusId
->
Maybe
ListId
->
TabType
->
m
(
Map
Text
(
ListType
,
Maybe
Text
),
Map
Text
(
Maybe
RootTerm
))
getNgrams
cId
maybeListId
tabType
=
do
lId
<-
case
maybeListId
of
Nothing
->
defaultList
cId
Just
lId'
->
pure
lId'
...
...
src/Gargantext/Database/Metrics/NgramsByNode.hs
View file @
cc89bb12
...
...
@@ -298,10 +298,6 @@ getNodesByNgramsMaster ucId mcId = Map.unionsWith (<>)
<$>
mapM
(
selectNgramsByNodeMaster
1000
ucId
mcId
)
[
0
,
500
..
10000
]
type
Limit
=
Int
type
Offset
=
Int
selectNgramsByNodeMaster
::
Int
->
UserCorpusId
->
MasterCorpusId
->
Int
->
Cmd
err
[(
NodeId
,
Text
)]
selectNgramsByNodeMaster
n
ucId
mcId
p
=
runPGSQuery
queryNgramsByNodeMaster'
...
...
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