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
24b52471
Commit
24b52471
authored
Sep 13, 2016
by
delanoe
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/romain-testing' into testing
parents
d1c00c07
309a940e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
EUROPRESSE.py
gargantext/util/parsers/EUROPRESSE.py
+7
-4
ngrams_extraction.py
gargantext/util/toolchain/ngrams_extraction.py
+8
-5
No files found.
gargantext/util/parsers/EUROPRESSE.py
View file @
24b52471
...
@@ -70,7 +70,7 @@ class EuropresseParser(Parser):
...
@@ -70,7 +70,7 @@ class EuropresseParser(Parser):
except
Exception
as
error
:
except
Exception
as
error
:
html_articles
=
None
html_articles
=
None
print
(
"Europresse lxml error:"
,
error
)
print
(
"Europresse lxml error:"
,
str
(
error
)
)
# all except detail_header are mandatory to parse the article
# all except detail_header are mandatory to parse the article
name_xpath
=
"./header/div/span[@class = 'DocPublicationName']"
name_xpath
=
"./header/div/span[@class = 'DocPublicationName']"
...
@@ -113,7 +113,10 @@ class EuropresseParser(Parser):
...
@@ -113,7 +113,10 @@ class EuropresseParser(Parser):
# parse all the articles, one by one
# parse all the articles, one by one
if
html_articles
is
not
None
:
if
html_articles
is
None
:
filename
=
file
.
name
if
hasattr
(
file
,
'name'
)
else
'unknown file'
print
(
"WARNING: europresse (skip) 1 file with no parsable content: "
+
filename
)
else
:
for
html_article
in
html_articles
:
for
html_article
in
html_articles
:
try
:
try
:
# s'il n'y a pas du tout de header on doit skip
# s'il n'y a pas du tout de header on doit skip
...
...
gargantext/util/toolchain/ngrams_extraction.py
View file @
24b52471
...
@@ -98,9 +98,7 @@ def extract_ngrams(corpus, keys=DEFAULT_INDEX_FIELDS, do_subngrams = DEFAULT_IND
...
@@ -98,9 +98,7 @@ def extract_ngrams(corpus, keys=DEFAULT_INDEX_FIELDS, do_subngrams = DEFAULT_IND
tokens
=
tuple
(
normalize_forms
(
token
[
0
])
for
token
in
ngram
)
tokens
=
tuple
(
normalize_forms
(
token
[
0
])
for
token
in
ngram
)
if
do_subngrams
:
if
do_subngrams
:
# ex tokens = ["very", "cool", "exemple"]
# ex tokens = ["very", "cool", "exemple"]
# subterms = [['very', 'cool'],
# subterms = [['very', 'cool'],...]
# ['very', 'cool', 'exemple'],
# ['cool', 'exemple']]
subterms
=
subsequences
(
tokens
)
subterms
=
subsequences
(
tokens
)
else
:
else
:
...
@@ -108,11 +106,16 @@ def extract_ngrams(corpus, keys=DEFAULT_INDEX_FIELDS, do_subngrams = DEFAULT_IND
...
@@ -108,11 +106,16 @@ def extract_ngrams(corpus, keys=DEFAULT_INDEX_FIELDS, do_subngrams = DEFAULT_IND
for
seqterm
in
subterms
:
for
seqterm
in
subterms
:
ngram
=
' '
.
join
(
seqterm
)
ngram
=
' '
.
join
(
seqterm
)
if
len
(
ngram
)
>
1
:
nbwords
=
len
(
seqterm
)
nbchars
=
len
(
ngram
)
if
nbchars
>
1
:
if
nbchars
>
255
:
# max ngram length (DB constraint)
ngram
=
ngram
[:
255
]
# doc <=> ngram index
# doc <=> ngram index
nodes_ngrams_count
[(
document
.
id
,
ngram
)]
+=
1
nodes_ngrams_count
[(
document
.
id
,
ngram
)]
+=
1
# add fields : terms n
# add fields : terms n
ngrams_data
.
add
((
ngram
[:
255
],
len
(
seqterm
)
,
))
ngrams_data
.
add
((
ngram
,
nbwords
,
))
except
:
except
:
#value not in doc
#value not in doc
continue
continue
...
...
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