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
6a2e10fb
Commit
6a2e10fb
authored
Jan 08, 2015
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[BUG FIX] Adding try/except for ugly encoded corpora.
parent
0c97f772
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
136 additions
and
127 deletions
+136
-127
EuropressFileParser.py
parsing/FileParsers/EuropressFileParser.py
+136
-127
No files found.
parsing/FileParsers/EuropressFileParser.py
View file @
6a2e10fb
...
@@ -42,7 +42,7 @@ class EuropressFileParser(FileParser):
...
@@ -42,7 +42,7 @@ class EuropressFileParser(FileParser):
# initialize the list of metadata
# initialize the list of metadata
metadata_list
=
[]
metadata_list
=
[]
# parse all the articles, one by one
# parse all the articles, one by one
try
:
for
html_article
in
html_articles
:
for
html_article
in
html_articles
:
metadata
=
{}
metadata
=
{}
...
@@ -59,7 +59,12 @@ class EuropressFileParser(FileParser):
...
@@ -59,7 +59,12 @@ class EuropressFileParser(FileParser):
metadata
[
'source'
]
=
name
.
text
.
encode
(
codif
)
metadata
[
'source'
]
=
name
.
text
.
encode
(
codif
)
for
header
in
html_article
.
xpath
(
"./tr/td/span[@class = 'DocHeader']"
):
for
header
in
html_article
.
xpath
(
"./tr/td/span[@class = 'DocHeader']"
):
try
:
text
=
header
.
text
text
=
header
.
text
except
Exception
as
error
:
print
(
error
)
if
isinstance
(
text
,
bytes
):
if
isinstance
(
text
,
bytes
):
text
=
text
.
decode
(
encoding
)
text
=
text
.
decode
(
encoding
)
...
@@ -177,6 +182,10 @@ class EuropressFileParser(FileParser):
...
@@ -177,6 +182,10 @@ class EuropressFileParser(FileParser):
metadata_list
.
append
(
metadata
)
metadata_list
.
append
(
metadata
)
count
+=
1
count
+=
1
except
Exception
as
error
:
print
(
error
)
pass
# from pprint import pprint
# from pprint import pprint
# pprint(metadata_list)
# pprint(metadata_list)
# return []
# return []
...
...
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