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
a2f0376a
Commit
a2f0376a
authored
May 20, 2016
by
delanoe
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'romain-refactoring' into unstable
parents
766250e3
049dc862
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
183 additions
and
93 deletions
+183
-93
_Parser.py
gargantext/util/parsers/_Parser.py
+19
-2
__init__.py
gargantext/util/toolchain/__init__.py
+4
-0
metric_tfidf.py
gargantext/util/toolchain/metric_tfidf.py
+152
-85
ngrams_extraction.py
gargantext/util/toolchain/ngrams_extraction.py
+1
-1
ngramlists.py
gargantext/views/api/ngramlists.py
+7
-5
No files found.
gargantext/util/parsers/_Parser.py
View file @
a2f0376a
...
@@ -126,10 +126,27 @@ class Parser:
...
@@ -126,10 +126,27 @@ class Parser:
break
break
except
KeyError
:
except
KeyError
:
language_keyerrors
[
key
]
=
language_symbol
language_keyerrors
[
key
]
=
language_symbol
# languages can find Language objects from any code iso2 or iso3
# --------------------------------------------------------------
# > languages['fr']
# <Language iso3="fra" iso2="fr" implemented="True" name="French">
# > languages['fra']
# <Language iso3="fra" iso2="fr" implemented="True" name="French">
if
language
is
not
None
:
if
language
is
not
None
:
hyperdata
[
'language_iso2'
]
=
language
.
iso2
hyperdata
[
'language_iso3'
]
=
language
.
iso3
hyperdata
[
'language_name'
]
=
language
.
name
hyperdata
[
'language_name'
]
=
language
.
name
hyperdata
[
'language_iso3'
]
=
language
.
iso3
if
(
language
.
iso2
is
not
None
):
# NB: language can be recognized through iso3 but have no iso2!!
# because there's *more* languages in iso3 codes (iso-639-3)
# exemple:
# > languages['dnj']
# <Language iso3="dnj" iso2="None" implemented="False" name="Dan">
# ----
hyperdata
[
'language_iso2'
]
=
language
.
iso2
else
:
# 'None' would become json 'null' ==> "__unknown__" more stable
hyperdata
[
'language_iso2'
]
=
"__unknown__"
elif
language_keyerrors
:
elif
language_keyerrors
:
print
(
'Unrecognized language:
%
s'
%
', '
.
join
(
print
(
'Unrecognized language:
%
s'
%
', '
.
join
(
'
%
s="
%
s"'
%
(
key
,
value
)
for
key
,
value
in
language_keyerrors
.
items
()
'
%
s="
%
s"'
%
(
key
,
value
)
for
key
,
value
in
language_keyerrors
.
items
()
...
...
gargantext/util/toolchain/__init__.py
View file @
a2f0376a
...
@@ -54,6 +54,10 @@ def parse_extract_indexhyperdata(corpus):
...
@@ -54,6 +54,10 @@ def parse_extract_indexhyperdata(corpus):
corpus
.
status
(
'Workflow'
,
progress
=
1
)
corpus
.
status
(
'Workflow'
,
progress
=
1
)
corpus
.
save_hyperdata
()
corpus
.
save_hyperdata
()
session
.
commit
()
session
.
commit
()
# FIXME: 'Workflow' will still be uncomplete when 'Index' and 'Lists' will
# get stacked into hyperdata['statuses'], but doing corpus.status()
# will return only the 1st uncomplete action (corpus.status() doesn't
# understand "subactions")
# apply actions
# apply actions
print
(
'CORPUS #
%
d'
%
(
corpus
.
id
))
print
(
'CORPUS #
%
d'
%
(
corpus
.
id
))
...
...
gargantext/util/toolchain/metric_tfidf.py
View file @
a2f0376a
This diff is collapsed.
Click to expand it.
gargantext/util/toolchain/ngrams_extraction.py
View file @
a2f0376a
...
@@ -56,7 +56,7 @@ def extract_ngrams(corpus, keys=('title', 'abstract', )):
...
@@ -56,7 +56,7 @@ def extract_ngrams(corpus, keys=('title', 'abstract', )):
ngramsextractor
=
ngramsextractors
[
language_iso2
]
ngramsextractor
=
ngramsextractors
[
language_iso2
]
except
KeyError
:
except
KeyError
:
# skip document
# skip document
print
(
'Unsupported language: `
%
s`
'
%
(
language_iso2
,
))
print
(
'Unsupported language: `
%
s`
(doc #
%
i)'
%
(
language_iso2
,
document
.
id
))
# and remember that for later processes (eg stemming)
# and remember that for later processes (eg stemming)
document
.
hyperdata
[
'__skipped__'
]
=
'ngrams_extraction'
document
.
hyperdata
[
'__skipped__'
]
=
'ngrams_extraction'
document
.
save_hyperdata
()
document
.
save_hyperdata
()
...
...
gargantext/views/api/ngramlists.py
View file @
a2f0376a
...
@@ -74,8 +74,10 @@ def _query_grouped_ngrams(groupings_id, details=False, scoring_metric_id=None):
...
@@ -74,8 +74,10 @@ def _query_grouped_ngrams(groupings_id, details=False, scoring_metric_id=None):
- details: if False, send just the array of ngram_ids
- details: if False, send just the array of ngram_ids
if True, send triples with (ngram_id, term, scoring)
if True, send triples with (ngram_id, term, scoring)
^^^^^^^
^^^^^^^
- scoring_metric_id: id of a scoring metric node (TFIDF or OCCS)
deprecated: scoring_metric_id: id of a scoring metric node (TFIDF or OCCS)
(for details and sorting)
(for details and sorting)
(no more OCCS counts of subforms)
"""
"""
if
not
details
:
if
not
details
:
# simple contents
# simple contents
...
@@ -86,12 +88,12 @@ def _query_grouped_ngrams(groupings_id, details=False, scoring_metric_id=None):
...
@@ -86,12 +88,12 @@ def _query_grouped_ngrams(groupings_id, details=False, scoring_metric_id=None):
.
query
(
.
query
(
NodeNgramNgram
.
ngram2_id
,
NodeNgramNgram
.
ngram2_id
,
Ngram
.
terms
,
Ngram
.
terms
,
NodeNodeNgram
.
score
# NodeNodeNgram.score #
)
)
.
join
(
Ngram
,
NodeNgramNgram
.
ngram2_id
==
Ngram
.
id
)
.
join
(
Ngram
,
NodeNgramNgram
.
ngram2_id
==
Ngram
.
id
)
.
join
(
NodeNodeNgram
,
NodeNgramNgram
.
ngram2_id
==
NodeNodeNgram
.
ngram_id
)
#
.join(NodeNodeNgram, NodeNgramNgram.ngram2_id == NodeNodeNgram.ngram_id)
.
filter
(
NodeNodeNgram
.
node1_id
==
scoring_metric_id
)
#
.filter(NodeNodeNgram.node1_id == scoring_metric_id)
.
order_by
(
desc
(
NodeNodeNgram
.
score
))
#
.order_by(desc(NodeNodeNgram.score))
)
)
# main filter
# main filter
...
...
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