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
195
Issues
195
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
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
5d74f5b4
Commit
5d74f5b4
authored
Apr 24, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WIP/RESEARCH] Niveau Texte.
parent
e21d93ed
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
3 deletions
+69
-3
Text.hs
src/Gargantext/Text.hs
+69
-3
No files found.
src/Gargantext/Text.hs
View file @
5d74f5b4
...
...
@@ -13,10 +13,14 @@ Text gathers terms in unit of contexts.
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module
Gargantext.Text
where
import
Data.Functor
import
Data.Traversable
(
Traversable
)
import
Data.Text
(
Text
,
split
)
import
qualified
Data.Text
as
DT
...
...
@@ -25,12 +29,74 @@ import NLP.FullStop (segment)
import
Gargantext.Core
import
Gargantext.Prelude
hiding
(
filter
)
-----------------------------------------------------------------
-- | Why not use data ?
data
Niveau
=
NiveauTexte
Texte
|
NiveauParagraphe
Paragraphe
|
NiveauPhrase
Phrase
|
NiveauMultiTerme
MultiTerme
|
NiveauMot
Mot
|
NiveauLettre
Lettre
deriving
(
Show
)
-- | Why use newtype ?
newtype
Texte
=
Texte
Text
newtype
Paragraphe
=
Paragraphe
Text
newtype
Phrase
=
Phrase
Text
newtype
MultiTerme
=
MultiTerme
Text
newtype
Mot
=
Mot
Text
newtype
Lettre
=
Lettre
Text
-- | Type syn seems obvious
type
Titre
=
Phrase
-----------------------------------------------------------------
instance
Show
Texte
where
show
(
Texte
t
)
=
show
t
instance
Show
Paragraphe
where
show
(
Paragraphe
p
)
=
show
p
instance
Show
Phrase
where
show
(
Phrase
p
)
=
show
p
instance
Show
MultiTerme
where
show
(
MultiTerme
mt
)
=
show
mt
instance
Show
Mot
where
show
(
Mot
t
)
=
show
t
type
Config
=
Lang
->
Context
type
Context
=
Text
->
[
Text
]
data
Viz
=
Graph
|
Phylo
|
Chart
instance
Show
Lettre
where
show
(
Lettre
l
)
=
show
l
-----------------------------------------------------------------
class
Collage
sup
inf
where
dec
::
sup
->
[
inf
]
inc
::
[
inf
]
->
sup
instance
Collage
Texte
Paragraphe
where
dec
(
Texte
t
)
=
map
Paragraphe
$
DT
.
splitOn
"
\n
"
t
inc
=
Texte
.
DT
.
intercalate
"
\n
"
.
map
(
\
(
Paragraphe
t
)
->
t
)
instance
Collage
Paragraphe
Phrase
where
dec
(
Paragraphe
t
)
=
map
Phrase
$
sentences
t
inc
=
Paragraphe
.
DT
.
unwords
.
map
(
\
(
Phrase
p
)
->
p
)
instance
Collage
Phrase
MultiTerme
where
dec
(
Phrase
t
)
=
map
MultiTerme
$
DT
.
words
t
inc
=
Phrase
.
DT
.
unwords
.
map
(
\
(
MultiTerme
p
)
->
p
)
instance
Collage
MultiTerme
Mot
where
dec
(
MultiTerme
mt
)
=
map
Mot
$
DT
.
words
mt
inc
=
MultiTerme
.
DT
.
intercalate
" "
.
map
(
\
(
Mot
m
)
->
m
)
-- | We could use Type Classes but we lose the Sum Type classification
toMultiTerme
::
Niveau
->
[
MultiTerme
]
toMultiTerme
(
NiveauTexte
(
Texte
t
))
=
undefined
toMultiTerme
(
NiveauPhrase
p
)
=
dec
p
toMultiTerme
(
NiveauMultiTerme
mt
)
=
[
mt
]
toMultiTerme
(
NiveauMot
m
)
=
undefined
-------------------------------------------------------------------
-- Contexts of text
sentences
::
Text
->
[
Text
]
...
...
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