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
152
Issues
152
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
a8b8b4fc
Commit
a8b8b4fc
authored
Jul 17, 2023
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor termsInText
parent
04e82dd6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
WithList.hs
src/Gargantext/Core/Text/Terms/WithList.hs
+14
-6
No files found.
src/Gargantext/Core/Text/Terms/WithList.hs
View file @
a8b8b4fc
...
...
@@ -12,6 +12,7 @@ commentary with @some markup@.
-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ViewPatterns #-}
module
Gargantext.Core.Text.Terms.WithList
where
...
...
@@ -20,7 +21,7 @@ import Data.Ord
import
Data.Text
(
Text
,
concat
,
unwords
)
import
Gargantext.API.Ngrams.Types
(
NgramsTerm
(
..
))
import
Gargantext.Prelude
import
Gargantext.Core
(
Lang
(
ZH
)
,
defaultLanguage
)
import
Gargantext.Core
(
Lang
(
ZH
))
import
Gargantext.Core.Text.Context
import
Gargantext.Core.Text.Terms.Mono
(
monoTextsBySentence
)
import
Gargantext.Core.Types
(
TermsCount
)
...
...
@@ -86,12 +87,19 @@ buildPatterns = sortWith (Down . _pat_length) . concatMap buildPattern
--------------------------------------------------------------------------
-- Utils
type
MatchedText
=
Text
termsInText
::
Lang
->
Patterns
->
Text
->
[(
MatchedText
,
TermsCount
)]
termsInText
ZH
pats
txt
=
termsInText
defaultLanguage
pats
(
addSpaces
txt
)
termsInText
_
pats
txt
=
groupWithCounts
$
List
.
concat
$
map
(
map
unwords
)
$
extractTermsWithList
pats
txt
termsInText
lang
pats
(
manipulateText
lang
->
txt
)
=
groupWithCounts
$
List
.
concat
$
map
(
map
unwords
)
$
extractTermsWithList
pats
txt
-- | Manipulates the input 'Text' before passing it to 'termsInText'.
-- In particular, if the language is Chinese (ZH), we add spaces.
manipulateText
::
Lang
->
Text
->
Text
manipulateText
lang
txt
=
case
lang
of
ZH
->
addSpaces
txt
_
->
txt
--------------------------------------------------------------------------
extractTermsWithList
::
Patterns
->
Text
->
Corpus
[
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