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
323e3d9d
Commit
323e3d9d
authored
Aug 28, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
suggestions for faster 'integrate' of ngrams
parent
b90eb786
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
ngrams_extraction.py
gargantext/util/toolchain/ngrams_extraction.py
+7
-4
No files found.
gargantext/util/toolchain/ngrams_extraction.py
View file @
323e3d9d
...
...
@@ -8,13 +8,15 @@ from gargantext.util.scheduling import scheduled
def
_integrate_associations
(
nodes_ngrams_count
,
ngrams_data
,
db
,
cursor
):
"""
@param ngrams_data a set like {('single word', 2), ('apple', 1),...}
£TODO: load whole word dictionary in ram and check existence before inserting to db => sequential insert => probably faster!
"""
print
(
'INTEGRATE'
)
# integrate ngrams
# integrate ngrams
(aka new words)
ngrams_ids
=
bulk_insert_ifnotexists
(
model
=
Ngram
,
uniquekey
=
'terms'
,
fields
=
(
'terms'
,
'n'
),
model
=
Ngram
,
# todo type should :str ~~> :str|:re) !!!
uniquekey
=
'terms'
,
# todo col 'terms' should be renamed 'form' ?
fields
=
(
'terms'
,
'n'
),
# todo replace by type ?
data
=
ngrams_data
,
cursor
=
cursor
,
)
...
...
@@ -77,6 +79,7 @@ def extract_ngrams(corpus, keys=DEFAULT_INDEX_FIELDS, do_subngrams = DEFAULT_IND
#print(language_iso2)
#>>> romain-stable-patch
#to do verify if document has no KEYS to index
# eg: use set intersect (+ loop becomes direct! with no continue)
for
key
in
keys
:
try
:
value
=
document
.
hyperdata
[
str
(
key
)]
...
...
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