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
6af8ff7b
Commit
6af8ff7b
authored
May 22, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Ngrams] cosmetics.
parent
8b76e18c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
Eleve.hs
src/Gargantext/Text/Eleve.hs
+8
-7
No files found.
src/Gargantext/Text/Eleve.hs
View file @
6af8ff7b
...
...
@@ -25,19 +25,19 @@ example = map terminal
$
chunkAlong
3
1
$
words
"New York and New York is a big apple"
data
Terminal
=
Debut
|
Terminal
Text
|
Fin
data
Terminal
=
Terminal
Text
|
Fin
deriving
(
Ord
,
Eq
,
Show
)
isDebutFin
::
Terminal
->
Bool
isDebutFin
x
=
case
x
of
Debut
->
True
isFin
::
Terminal
->
Bool
isFin
x
=
case
x
of
Fin
->
True
_
->
False
terminal
::
[
Text
]
->
[
Terminal
]
--terminal xs = [Debut] <> (map Terminal xs) <> [Fin]
terminal
xs
=
(
map
Terminal
xs
)
<>
[
Fin
]
data
Arbre
k
e
=
Noeud
{
_noeud_count
::
Double
,
_noeud_entropy
::
e
,
_noeud_fils
::
Map
k
(
Arbre
k
e
)
...
...
@@ -69,7 +69,7 @@ entropyArbre :: Arbre Terminal () -> Arbre Terminal Double
entropyArbre
(
Feuille
c
)
=
Feuille
c
entropyArbre
(
Noeud
c
_e
fils
)
=
(
Noeud
c
e
(
map
entropyArbre
fils
))
where
e
=
sum
$
map
(
\
(
k
,
f
)
->
case
is
Debut
Fin
k
of
e
=
sum
$
map
(
\
(
k
,
f
)
->
case
isFin
k
of
True
->
(
_noeud_count
f
)
/
c
*
log
c
False
->
-
c'
*
log
c'
where
...
...
@@ -79,7 +79,7 @@ entropyArbre (Noeud c _e fils) = (Noeud c e (map entropyArbre fils))
normalizeArbre
::
Arbre
Terminal
Double
->
Arbre
Terminal
Double
normalizeArbre
(
Feuille
c
)
=
Feuille
c
normalizeArbre
(
Noeud
c
e
f
)
=
Noeud
c
e
(
Map
.
map
(
\
n
->
normalizeLevel
n
$
Map
.
elems
f
)
f
)
normalizeArbre
(
Noeud
c
e
f
)
=
Noeud
c
e
(
Map
.
map
(
\
a
->
normalizeLevel
a
$
Map
.
elems
f
)
f
)
normalizeLevel
::
Arbre
Terminal
Double
->
[
Arbre
Terminal
Double
]
->
Arbre
Terminal
Double
normalizeLevel
(
Feuille
c
)
_
=
Feuille
c
...
...
@@ -95,3 +95,4 @@ buildArbre = normalizeArbre . entropyArbre . insertArbres
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