Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
6bbe13d0
Commit
6bbe13d0
authored
Oct 08, 2015
by
delanoe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PARAMETERS] of the ngram workflow.
parent
51e6eb60
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
12 deletions
+25
-12
cooccurrences.py
analysis/cooccurrences.py
+4
-2
functions.py
analysis/functions.py
+2
-2
cvalue.py
ngram/cvalue.py
+2
-2
workflow.py
ngram/workflow.py
+17
-6
No files found.
analysis/cooccurrences.py
View file @
6bbe13d0
...
@@ -8,6 +8,8 @@ from gargantext_web.db import Node, Ngram, NodeNgram, NodeNgramNgram, \
...
@@ -8,6 +8,8 @@ from gargantext_web.db import Node, Ngram, NodeNgram, NodeNgramNgram, \
from
gargantext_web.db
import
session
,
cache
,
get_or_create_node
,
bulk_insert
from
gargantext_web.db
import
session
,
cache
,
get_or_create_node
,
bulk_insert
from
analysis.lists
import
WeightedMatrix
,
UnweightedList
,
Translations
from
analysis.lists
import
WeightedMatrix
,
UnweightedList
,
Translations
# keep list
def
cooc
(
corpus
=
None
def
cooc
(
corpus
=
None
,
field_X
=
None
,
field_Y
=
None
,
field_X
=
None
,
field_Y
=
None
,
miam_id
=
None
,
stop_id
=
None
,
group_id
=
None
,
miam_id
=
None
,
stop_id
=
None
,
group_id
=
None
...
@@ -104,13 +106,13 @@ def cooc(corpus=None
...
@@ -104,13 +106,13 @@ def cooc(corpus=None
# Cooc is symetric, take only the main cooccurrences and cut at the limit
# Cooc is symetric, take only the main cooccurrences and cut at the limit
cooc_query
=
(
cooc_query
.
filter
(
Node
.
parent_id
==
corpus
.
id
,
Node
.
type_id
==
doc_id
)
cooc_query
=
(
cooc_query
.
filter
(
NodeNgramX
.
ngram_id
<
NodeNgramY
.
ngram_id
)
.
filter
(
NodeNgramX
.
ngram_id
<
NodeNgramY
.
ngram_id
)
.
group_by
(
NodeNgramX
.
ngram_id
,
NodeNgramY
.
ngram_id
)
.
group_by
(
NodeNgramX
.
ngram_id
,
NodeNgramY
.
ngram_id
)
.
order_by
(
desc
(
func
.
count
()))
.
order_by
(
desc
(
func
.
count
()))
.
limit
(
limit
)
#
.limit(limit)
)
)
matrix
=
WeightedMatrix
(
cooc_query
)
matrix
=
WeightedMatrix
(
cooc_query
)
...
...
analysis/functions.py
View file @
6bbe13d0
...
@@ -229,10 +229,10 @@ def get_cooc(request=None, corpus=None, cooc_id=None, type='node_link', size=siz
...
@@ -229,10 +229,10 @@ def get_cooc(request=None, corpus=None, cooc_id=None, type='node_link', size=siz
#print(n)
#print(n)
#print(m)
#print(m)
nodes_included
=
3
00
#int(round(size/20,0))
nodes_included
=
10
00
#int(round(size/20,0))
#nodes_excluded = int(round(size/10,0))
#nodes_excluded = int(round(size/10,0))
nodes_specific
=
3
00
#int(round(size/10,0))
nodes_specific
=
10
00
#int(round(size/10,0))
#nodes_generic = int(round(size/10,0))
#nodes_generic = int(round(size/10,0))
# TODO user the included score for the node size
# TODO user the included score for the node size
...
...
ngram/cvalue.py
View file @
6bbe13d0
...
@@ -36,7 +36,7 @@ ngrams = {'adenoic cystic basal cell carcinoma' : 5
...
@@ -36,7 +36,7 @@ ngrams = {'adenoic cystic basal cell carcinoma' : 5
}
}
'''
'''
def
getNgrams
(
corpus
=
None
,
limit
=
1
6
0
):
def
getNgrams
(
corpus
=
None
,
limit
=
1
00
0
):
'''
'''
getNgrams :: Corpus -> [(Int, String, String, Float)]
getNgrams :: Corpus -> [(Int, String, String, Float)]
'''
'''
...
@@ -63,7 +63,7 @@ def getNgrams(corpus=None, limit=160):
...
@@ -63,7 +63,7 @@ def getNgrams(corpus=None, limit=160):
PrintException
()
PrintException
()
return
(
terms
)
return
(
terms
)
def
compute_cvalue
(
corpus
=
None
,
limit
=
1
6
0
):
def
compute_cvalue
(
corpus
=
None
,
limit
=
1
00
0
):
'''
'''
computeCvalue :: Corpus
computeCvalue :: Corpus
frequency :: String -> Int -> Int
frequency :: String -> Int -> Int
...
...
ngram/workflow.py
View file @
6bbe13d0
...
@@ -7,17 +7,28 @@ from ngram.group import compute_groups
...
@@ -7,17 +7,28 @@ from ngram.group import compute_groups
from
ngram.miam
import
compute_miam
from
ngram.miam
import
compute_miam
from
gargantext_web.db
import
get_or_create_node
from
gargantext_web.db
import
get_or_create_node
def
ngram_workflow
(
corpus
):
def
ngram_workflow
(
corpus
,
n
=
5000
):
'''
'''
All the workflow to filter the ngrams.
All the workflow to filter the ngrams.
'''
'''
compute_tfidf
(
corpus
)
compute_tfidf_global
(
corpus
)
compute_tfidf_global
(
corpus
)
compute_cvalue
(
corpus
,
limit
=
10000
)
# size
compute_specificity
(
corpus
,
limit
=
10000
)
part
=
round
(
n
*
0.8
)
compute_cvalue
(
corpus
,
limit
=
part
)
# size
part
=
round
(
part
*
0.6
)
compute_specificity
(
corpus
,
limit
=
part
)
part
=
round
(
part
*
0.5
)
# compute_stop(corpus)
# compute_stop(corpus)
compute_groups
(
corpus
,
limit_inf
=
1000
,
limit_sup
=
5000
)
compute_groups
(
corpus
,
limit_inf
=
part
,
limit_sup
=
n
)
compute_miam
(
corpus
,
limit
=
3000
)
# size
compute_miam
(
corpus
,
limit
=
part
)
# size
compute_tfidf
(
corpus
)
#corpus=session.query(Node).filter(Node.id==244250).first()
#corpus=session.query(Node).filter(Node.id==244250).first()
#ngram_workflow(corpus)
#ngram_workflow(corpus)
...
...
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