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
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
Christian Merten
haskell-gargantext
Commits
543bad9d
Commit
543bad9d
authored
Mar 02, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[METRICS] TFICF right order of parameters and clean.
parent
01ccce76
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
18 deletions
+14
-18
NgramsByNode.hs
src/Gargantext/Database/Metrics/NgramsByNode.hs
+3
-5
TFICF.hs
src/Gargantext/Text/Metrics/TFICF.hs
+11
-13
No files found.
src/Gargantext/Database/Metrics/NgramsByNode.hs
View file @
543bad9d
...
...
@@ -54,9 +54,7 @@ ngramsGroup l n = Text.intercalate " "
sortTficf
::
(
Map
Text
(
Double
,
Set
Text
))
->
[(
Double
,
Set
Text
)]
sortTficf
=
List
.
reverse
.
List
.
sortOn
fst
.
elems
sortTficf
=
List
.
sortOn
fst
.
elems
getTficf'
::
UserCorpusId
->
MasterCorpusId
->
(
Text
->
Text
)
...
...
@@ -76,8 +74,8 @@ type Infra = Context
toTficfData
::
Infra
->
Supra
->
Map
Text
(
Double
,
Set
Text
)
toTficfData
(
ti
,
mi
)
(
ts
,
ms
)
=
fromList
[
(
t
,
(
tficf
(
TficfInfra
(
Total
ti
)
(
Count
n
))
(
TficfSupra
(
Total
ts
)
(
Count
$
maybe
0
fst
$
Map
.
lookup
t
m
s
))
fromList
[
(
t
,
(
tficf
(
TficfInfra
(
Count
n
)(
Total
ti
))
(
TficfSupra
(
Count
$
maybe
0
fst
$
Map
.
lookup
t
ms
)(
Total
t
s
))
,
ns
)
)
...
...
src/Gargantext/Text/Metrics/TFICF.hs
View file @
543bad9d
...
...
@@ -9,16 +9,18 @@ Portability : POSIX
Definition of TFICF : Term Frequency - Inverse of Context Frequency
TFICF is a generalization of [TFIDF](https://en.wikipedia.org/wiki/Tf%E2%80%93idf).
-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
module
Gargantext.Text.Metrics.TFICF
where
--import Data.Text (Text)
import
Gargantext.Prelude
type
TFICF
=
Double
data
TficfContext
n
m
=
TficfInfra
n
m
|
TficfSupra
n
m
deriving
(
Show
)
...
...
@@ -26,17 +28,13 @@ data TficfContext n m = TficfInfra n m
data
Total
=
Total
{
unTotal
::
!
Double
}
data
Count
=
Count
{
unCount
::
!
Double
}
-- | TFICF is a generalization of TFIDF
-- https://en.wikipedia.org/wiki/Tf%E2%80%93idf
tficf
::
TficfContext
Total
Count
->
TficfContext
Total
Count
->
Double
tficf
(
TficfInfra
(
Total
it
)
(
Count
ic
))
(
TficfSupra
(
Total
st
)
(
Count
sc
))
=
tficf'
it
ic
st
sc
where
tficf'
::
Double
->
Double
->
Double
->
Double
->
Double
tficf'
it'
ic'
st'
sc'
|
it'
>=
ic'
&&
st'
>=
sc'
=
(
ic'
/
it'
)
/
log
(
sc'
/
st'
)
|
otherwise
=
panic
"Frequency impossible"
tficf
::
TficfContext
Count
Total
->
TficfContext
Count
Total
->
TFICF
tficf
(
TficfInfra
(
Count
ic
)
(
Total
it
)
)
(
TficfSupra
(
Count
sc
)
(
Total
st
)
)
|
it
>=
ic
&&
st
>=
sc
=
(
ic
/
it
)
/
log
(
sc
/
st
)
|
otherwise
=
panic
"Frequency impossible"
tficf
_
_
=
panic
"Undefined for these contexts"
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