Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BA Timeline Summarization
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kaiser
BA Timeline Summarization
Commits
5f9d59e8
Commit
5f9d59e8
authored
3 years ago
by
vvye
Browse files
Options
Downloads
Patches
Plain Diff
Fix another bug in open function
parent
cb2faec3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dataset.py
+2
-1
2 additions, 1 deletion
dataset.py
util.py
+2
-1
2 additions, 1 deletion
util.py
with
4 additions
and
2 deletions
dataset.py
+
2
−
1
View file @
5f9d59e8
...
...
@@ -156,9 +156,10 @@ def get_crisis_dataset():
if
gold_timeline_filename
.
startswith
(
'
.
'
):
continue
gold_timeline_file_path
=
topic_path
/
'
public
'
/
'
timelines
'
/
gold_timeline_filename
print
(
gold_timeline_file_path
)
gold_timeline_name
=
gold_timeline_filename
.
split
(
'
.
'
)[
0
]
gold_timeline
=
{}
with
open
(
gold_timeline_file_path
)
as
f
:
with
util
.
detect_encoding_and_
open
(
gold_timeline_file_path
)
as
f
:
lines
=
[
line
.
strip
()
for
line
in
f
.
readlines
()]
date_groups
=
[
list
(
y
)
for
x
,
y
in
itertools
.
groupby
(
lines
,
lambda
z
:
re
.
match
(
'
^-+$
'
,
z
))
if
not
x
]
for
date_group
in
date_groups
:
...
...
This diff is collapsed.
Click to expand it.
util.py
+
2
−
1
View file @
5f9d59e8
...
...
@@ -42,11 +42,12 @@ def detect_encoding_and_open(filename):
"""
raw_data
=
open
(
filename
,
'
rb
'
).
read
()
detected_encoding
=
chardet
.
detect
(
raw_data
)[
'
encoding
'
]
encodings
=
[
detected_encoding
,
'
utf-8
'
,
'
ansi
'
]
encodings
=
[
detected_encoding
,
'
utf-8
'
,
'
ansi
'
]
# these seem to work
for
encoding
in
encodings
:
f
=
open
(
filename
,
encoding
=
encoding
)
try
:
_
=
[
line
for
line
in
f
.
readlines
()]
f
.
seek
(
0
)
return
f
except
UnicodeDecodeError
:
f
.
close
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment