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
407b96ab
Commit
407b96ab
authored
May 12, 2015
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] Bug ngrams must be < 255
parent
852f71b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
corpustools.py
parsing/corpustools.py
+9
-9
No files found.
parsing/corpustools.py
View file @
407b96ab
...
...
@@ -128,7 +128,7 @@ def parse_resources(corpus, user=None, user_id=None):
nodes
.
append
(
node
)
#
# TODO: mark node-resources associations as parsed
#
#
dbg
.
show
(
'insert
%
d documents'
%
len
(
nodes
))
session
.
add_all
(
nodes
)
session
.
commit
()
...
...
@@ -205,7 +205,7 @@ def extract_ngrams(corpus, keys):
language
.
id
:
language
.
iso2
for
language
in
session
.
query
(
Language
)
}
ngrams_data
=
set
()
ngrams_language_data
=
set
()
ngrams_tag_data
=
set
()
...
...
@@ -241,7 +241,7 @@ def extract_ngrams(corpus, keys):
#tag_id = 14
#print('tag_id_2', tag_id)
node_ngram_list
[
node_id
][
terms
]
+=
1
ngrams_data
.
add
((
n
,
terms
))
ngrams_data
.
add
((
n
,
terms
[:
255
]
))
ngrams_language_data
.
add
((
terms
,
language_id
))
ngrams_tag_data
.
add
((
terms
,
tag_id
))
...
...
@@ -268,7 +268,7 @@ def extract_ngrams(corpus, keys):
ngram.terms = tmp__ngrams.terms
'''
%
(
Ngram
.
__table__
.
name
,
))
# insert, then get the ids back
cursor
.
execute
(
'''
INSERT INTO
%
s (n, terms)
...
...
@@ -279,8 +279,8 @@ def extract_ngrams(corpus, keys):
WHERE
id IS NULL
'''
%
(
Ngram
.
__table__
.
name
,
))
cursor
.
execute
(
'''
UPDATE
tmp__ngrams
...
...
@@ -293,14 +293,14 @@ def extract_ngrams(corpus, keys):
AND
tmp__ngrams.id IS NULL
'''
%
(
Ngram
.
__table__
.
name
,
))
# get all ids
ngram_ids
=
dict
()
cursor
.
execute
(
'SELECT id, terms FROM tmp__ngrams'
)
for
row
in
cursor
.
fetchall
():
ngram_ids
[
row
[
1
]]
=
row
[
0
]
#
#
dbg
.
show
(
'insert associations'
)
node_ngram_data
=
list
()
for
node_id
,
ngrams
in
node_ngram_list
.
items
():
...
...
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