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
f9e2dbd5
Commit
f9e2dbd5
authored
Jun 03, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extended possibility for subsequences of long terms in indexation (but disabled by default)
parent
3ff6aa00
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
12 deletions
+20
-12
constants.py
gargantext/constants.py
+6
-5
ngrams_extraction.py
gargantext/util/toolchain/ngrams_extraction.py
+14
-7
No files found.
gargantext/constants.py
View file @
f9e2dbd5
...
@@ -239,14 +239,15 @@ DEFAULT_ALL_LOWERCASE_FLAG = True # lowercase ngrams before recording
...
@@ -239,14 +239,15 @@ DEFAULT_ALL_LOWERCASE_FLAG = True # lowercase ngrams before recording
# good for variants like same term
# good for variants like same term
# occurring at sentence beginning)
# occurring at sentence beginning)
DEFAULT_INDEX_SUBGRAMS
=
False
# False <=> traditional
DEFAULT_INDEX_SUBGRAMS
=
False
# False <=> traditional
# True <=>
# True <=>
# when ngram is like:
# when ngram is like:
# "very cool example"
# "very cool example"
# then also count:
# then also count: "very", "cool"
# "very cool" and "cool example"
# "example", "very cool" and
# (n-1 length ngrams, at initial
# "cool example".
# indexing after extraction)
# (all 1 to n-1 length ngrams,
# at indexing after extraction)
...
...
gargantext/util/toolchain/ngrams_extraction.py
View file @
f9e2dbd5
...
@@ -87,7 +87,7 @@ def extract_ngrams(corpus, keys=('title', 'abstract', ), do_subngrams = DEFAULT_
...
@@ -87,7 +87,7 @@ def extract_ngrams(corpus, keys=('title', 'abstract', ), do_subngrams = DEFAULT_
subterms
=
[
tokens
]
subterms
=
[
tokens
]
for
seqterm
in
subterms
:
for
seqterm
in
subterms
:
ngram
=
normalize_term
(
' '
.
join
(
seqterm
))
ngram
=
normalize_term
s
(
' '
.
join
(
seqterm
))
if
len
(
ngram
)
>
1
:
if
len
(
ngram
)
>
1
:
# doc <=> ngram index
# doc <=> ngram index
nodes_ngrams_count
[(
document
.
id
,
ngram
)]
+=
1
nodes_ngrams_count
[(
document
.
id
,
ngram
)]
+=
1
...
@@ -136,20 +136,27 @@ def normalize_terms(term_str, do_lowercase=DEFAULT_ALL_LOWERCASE_FLAG):
...
@@ -136,20 +136,27 @@ def normalize_terms(term_str, do_lowercase=DEFAULT_ALL_LOWERCASE_FLAG):
def
subsequences
(
sequence
):
def
subsequences
(
sequence
):
"""
"""
For an array of length n, returns an array of subarrays
For an array of length n, returns an array of subarrays
with the original and all its sub arrays of length n-1
with the original and all its sub arrays of length
s 1 to
n-1
Ex: subsequences([
"Aaa","Bbb", "Ccc", "Ddd"
])
Ex: subsequences([
'Aa','Bb','Cc','Dd'
])
[
[
['Aaa', 'Bbb', 'Ccc'],
['Aa'],
['Aaa', 'Bbb', 'Ccc', 'Ddd'],
['Aa', 'Bb'],
['Bbb', 'Ccc', 'Ddd']
['Aa', 'Bb', 'Cc'],
['Aa', 'Bb', 'Cc', 'Dd'],
['Bb'],
['Bb', 'Cc'],
['Bb', 'Cc', 'Dd'],
['Cc'],
['Cc', 'Dd'],
['Dd']
]
]
"""
"""
l
=
len
(
sequence
)
l
=
len
(
sequence
)
li
=
[]
li
=
[]
lsave
=
li
.
append
lsave
=
li
.
append
for
i
in
range
(
l
):
for
i
in
range
(
l
):
for
j
in
range
(
i
+
(
l
-
1
)
,
l
+
1
):
for
j
in
range
(
i
+
1
,
l
+
1
):
if
i
!=
j
:
if
i
!=
j
:
lsave
(
sequence
[
i
:
j
])
lsave
(
sequence
[
i
:
j
])
# debug
# debug
...
...
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