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
0306f30d
Commit
0306f30d
authored
10 years ago
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] Async parse and ngrams extract methods: ok
parent
dd61109b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
+10
-10
views.py
gargantext_web/views.py
+3
-8
models.py
node/models.py
+7
-2
No files found.
gargantext_web/views.py
View file @
0306f30d
...
...
@@ -5,11 +5,10 @@ from django.http import Http404, HttpResponse, HttpResponseRedirect
from
django.template.loader
import
get_template
from
django.template
import
Context
#from documents.models import Project, Corpus, Document
from
node.models
import
Language
,
ResourceType
,
Resource
,
\
Node
,
NodeType
,
Node_Resource
,
Project
,
Corpus
,
\
Node_Ngram
,
NodeNgramNgram
from
node.admin
import
CorpusForm
,
ProjectForm
,
ResourceForm
from
django.contrib.auth.models
import
User
...
...
@@ -237,12 +236,8 @@ def project(request, project_id):
)
try
:
#corpus.parse_resources.apply_async((), countdown=1)
corpus
.
parse_resources
()
# async
corpus
.
children
.
filter
(
type_id
=
type_document
.
pk
)
.
extract_ngrams
(
keys
=
[
'title'
,])
#corpus.children.filter(type_id=type_document.pk).extract_ngrams(keys=['title',])
#corpus.parse_and_extract_ngrams(keys=['title',])
corpus
.
parse_and_extract_ngrams
.
apply_async
((),
countdown
=
1
)
except
Exception
as
error
:
print
(
error
)
...
...
This diff is collapsed.
Click to expand it.
node/models.py
View file @
0306f30d
...
...
@@ -157,7 +157,6 @@ class Node(CTENode):
node_resource
.
save
()
return
resource
@
current_app
.
task
(
filter
=
task_method
)
def
parse_resources
(
self
,
verbose
=
False
):
# parse all resources into a list of metadata
metadata_list
=
[]
...
...
@@ -200,7 +199,6 @@ class Node(CTENode):
self
.
node_resource
.
update
(
parsed
=
True
)
@
current_app
.
task
(
filter
=
task_method
)
def
extract_ngrams
(
self
,
keys
,
ngramsextractorscache
=
None
,
ngramscaches
=
None
):
# if there is no cache...
if
ngramsextractorscache
is
None
:
...
...
@@ -235,6 +233,13 @@ class Node(CTENode):
for
ngram_text
,
weight
in
associations
.
items
()
])
@
current_app
.
task
(
filter
=
task_method
)
def
parse_and_extract_ngrams
(
self
,
keys
=
None
,
ngramsextractorscache
=
None
,
ngramscaches
=
None
,
verbose
=
False
):
self
.
parse_resources
()
type_document
=
NodeType
.
objects
.
get
(
name
=
'Document'
)
self
.
children
.
filter
(
type_id
=
type_document
.
pk
)
.
extract_ngrams
(
keys
=
[
'title'
,])
class
Node_Metadata
(
models
.
Model
):
node
=
models
.
ForeignKey
(
Node
)
metadata
=
models
.
ForeignKey
(
Metadata
)
...
...
This diff is collapsed.
Click to expand it.
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