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
151e8522
Unverified
Commit
151e8522
authored
Jun 06, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eleve: mean noNaNs
parent
ab1b7497
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
Eleve.hs
src/Gargantext/Text/Eleve.hs
+8
-4
No files found.
src/Gargantext/Text/Eleve.hs
View file @
151e8522
...
...
@@ -154,6 +154,9 @@ toTree k (Node c e cs) = Tree.Node (k, c, Just e) (map (uncurry toTree) $ Map.t
nan
::
Floating
e
=>
e
nan
=
0
/
0
noNaNs
::
P
.
RealFloat
e
=>
[
e
]
->
[
e
]
noNaNs
=
filter
(
not
.
P
.
isNaN
)
updateIfDefined
::
P
.
RealFloat
e
=>
e
->
e
->
e
updateIfDefined
e0
e
|
P
.
isNaN
e
=
e0
|
otherwise
=
e
...
...
@@ -170,7 +173,7 @@ entropyTrie pred (Node c () children) = Node c e (map (entropyTrie pred) childre
------------------------------------------------------------------------
normalizeLevel
::
Entropy
e
=>
[
e
]
->
e
->
e
normalizeLevel
=
checkDiff
(
go
.
filter
(
not
.
P
.
isNaN
)
)
normalizeLevel
=
checkDiff
(
go
.
noNaNs
)
where
-- checkDiff f es e = let e' = f es e in if e == e' then e' else trace ("normalizeLevel: diff " <> show e <> " " <> show e') e'
...
...
@@ -199,7 +202,7 @@ nodeChildren (Leaf _) = Map.empty
class
IsTrie
trie
where
buildTrie
::
Floating
e
=>
[[
Token
]]
->
trie
Token
e
nodeEntropy
::
Floating
e
=>
Getting
e
i
e
->
trie
k
i
->
e
nodeEntropy
::
Entropy
e
=>
Getting
e
i
e
->
trie
k
i
->
e
nodeChild
::
Ord
k
=>
k
->
trie
k
e
->
trie
k
e
findTrie
::
Ord
k
=>
[
k
]
->
trie
k
e
->
trie
k
e
normalizeEntropy
::
Entropy
e
...
...
@@ -255,7 +258,7 @@ levels = L.takeWhile (not . L.null) . L.iterate (L.concatMap subForest) . pure
subForest
(
Node
_
_
children
)
=
Map
.
elems
children
entropyLevels
::
Entropy
e
=>
Getting
e
i
e
->
Trie
k
i
->
[[
e
]]
entropyLevels
inE
=
fmap
(
filter
(
not
.
P
.
isNaN
)
.
map
(
nodeEntropy
inE
))
.
levels
entropyLevels
inE
=
fmap
(
noNaNs
.
map
(
nodeEntropy
inE
))
.
levels
------------------------------------------------------------------------
...
...
@@ -269,7 +272,8 @@ instance IsTrie Tries where
,
_bwd
=
buildTrie
(
reverse
<$>
tts
)
}
nodeEntropy
inE
(
Tries
fwd
bwd
)
=
mean
[
nodeEntropy
inE
fwd
,
nodeEntropy
inE
bwd
]
nodeEntropy
inE
(
Tries
fwd
bwd
)
=
mean
$
noNaNs
[
nodeEntropy
inE
fwd
,
nodeEntropy
inE
bwd
]
findTrie
ks
(
Tries
fwd
bwd
)
=
Tries
(
findTrie
ks
fwd
)
(
findTrie
(
reverse
ks
)
bwd
)
...
...
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