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
6cd3ec54
Commit
6cd3ec54
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
bc5985ce
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 @
6cd3ec54
...
...
@@ -239,14 +239,15 @@ DEFAULT_ALL_LOWERCASE_FLAG = True # lowercase ngrams before recording
# good for variants like same term
# occurring at sentence beginning)
DEFAULT_INDEX_SUBGRAMS
=
False
# False <=> traditional
DEFAULT_INDEX_SUBGRAMS
=
False
# False <=> traditional
# True <=>
# when ngram is like:
# "very cool example"
# then also count:
# "very cool" and "cool example"
# (n-1 length ngrams, at initial
# indexing after extraction)
# then also count: "very", "cool"
# "example", "very cool" and
# "cool example".
# (all 1 to n-1 length ngrams,
# at indexing after extraction)
...
...
gargantext/util/toolchain/ngrams_extraction.py
View file @
6cd3ec54
...
...
@@ -87,7 +87,7 @@ def extract_ngrams(corpus, keys=('title', 'abstract', ), do_subngrams = DEFAULT_
subterms
=
[
tokens
]
for
seqterm
in
subterms
:
ngram
=
normalize_term
(
' '
.
join
(
seqterm
))
ngram
=
normalize_term
s
(
' '
.
join
(
seqterm
))
if
len
(
ngram
)
>
1
:
# doc <=> ngram index
nodes_ngrams_count
[(
document
.
id
,
ngram
)]
+=
1
...
...
@@ -136,20 +136,27 @@ def normalize_terms(term_str, do_lowercase=DEFAULT_ALL_LOWERCASE_FLAG):
def
subsequences
(
sequence
):
"""
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'],
['Aaa', 'Bbb', 'Ccc', 'Ddd'],
['Bbb', 'Ccc', 'Ddd']
['Aa'],
['Aa', 'Bb'],
['Aa', 'Bb', 'Cc'],
['Aa', 'Bb', 'Cc', 'Dd'],
['Bb'],
['Bb', 'Cc'],
['Bb', 'Cc', 'Dd'],
['Cc'],
['Cc', 'Dd'],
['Dd']
]
"""
l
=
len
(
sequence
)
li
=
[]
lsave
=
li
.
append
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
:
lsave
(
sequence
[
i
:
j
])
# 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