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
32ad8ed1
Commit
32ad8ed1
authored
3 years ago
by
vvye
Browse files
Options
Downloads
Patches
Plain Diff
Rename sentence summarization to sentence shortening for clarity
parent
bb521dda
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
run.py
+1
-1
1 addition, 1 deletion
run.py
sentence_shortening.py
+5
-5
5 additions, 5 deletions
sentence_shortening.py
timeline_generation.py
+4
-4
4 additions, 4 deletions
timeline_generation.py
with
10 additions
and
10 deletions
run.py
+
1
−
1
View file @
32ad8ed1
...
...
@@ -72,7 +72,7 @@ if __name__ == '__main__':
required
=
True
)
parser
.
add_argument
(
'
--length_constraint
'
,
type
=
str
,
choices
=
[
'
sentences
'
,
'
tokens
'
],
default
=
'
sentence
s
'
,
choices
=
[
'
sentences
'
,
'
tokens
'
],
default
=
'
token
s
'
,
help
=
'
what constraint to impose on the length of the generated timeline
'
'
(number of sentences or number of tokens)
'
)
parser
.
add_argument
(
'
--shorten_sentences
'
,
...
...
This diff is collapsed.
Click to expand it.
sentence_s
ummarization
.py
→
sentence_s
hortening
.py
+
5
−
5
View file @
32ad8ed1
...
...
@@ -8,11 +8,11 @@ with open('data/in/sentence_summarization_vocab.txt', encoding='utf-8') as f:
vocab
=
[
line
.
strip
()
for
line
in
f
.
readlines
()
if
line
.
strip
()]
def
s
ummarizatio
n
(
sentence
,
num_tokens
,
do_
de
unk
=
True
):
def
s
horte
n
(
sentence
,
num_tokens
,
do_
resolve_
unk
s
=
True
):
try
:
summarized_sentence
=
summarized_sentences
[
sentence
.
lower
()][
num_tokens
]
if
do_
de
unk
:
summarized_sentence
=
de
unk
(
sentence
,
summarized_sentence
)
if
do_
resolve_
unk
s
:
summarized_sentence
=
resolve_
unk
s
(
sentence
,
summarized_sentence
)
return
summarized_sentence
except
KeyError
:
print
(
sentence
)
...
...
@@ -21,7 +21,7 @@ def summarization(sentence, num_tokens, do_deunk=True):
return
sentence
def
de
unk
(
sentence
,
summarized_sentence
):
def
resolve_
unk
s
(
sentence
,
summarized_sentence
):
sentence
=
sentence
.
split
()
summarized_sentence
=
summarized_sentence
.
split
()
...
...
@@ -54,4 +54,4 @@ def deunk(sentence, summarized_sentence):
if
__name__
==
'
__main__
'
:
print
(
s
ummarizatio
n
(
'
and this was on - going in egypt before january 25 .
'
,
10
))
print
(
s
horte
n
(
'
and this was on - going in egypt before january 25 .
'
,
10
))
This diff is collapsed.
Click to expand it.
timeline_generation.py
+
4
−
4
View file @
32ad8ed1
...
...
@@ -5,7 +5,7 @@ import date_selection
import
evaluation
import
sentence_selection
import
summarization
import
sentence_s
ummarization
import
sentence_s
hortening
import
util
...
...
@@ -44,8 +44,8 @@ def make_timeline(articles, gold_timeline, keywords, by_tokens, shorten_sentence
new_candidate_sentences
=
[]
for
i
in
range
(
len
(
candidate_sentences
)):
new_candidate_sentences
.
append
({
'
text
'
:
sentence_s
ummarization
.
summarizatio
n
(
candidate_sentences
[
i
][
'
text
'
],
shortening_length
,
resolve_unks
),
'
text
'
:
sentence_s
hortening
.
shorte
n
(
candidate_sentences
[
i
][
'
text
'
],
shortening_length
,
resolve_unks
),
'
mentioned_dates
'
:
candidate_sentences
[
i
][
'
mentioned_dates
'
]
})
candidate_sentences
=
new_candidate_sentences
...
...
@@ -58,7 +58,7 @@ def make_timeline(articles, gold_timeline, keywords, by_tokens, shorten_sentence
# shorten sentences if needed
if
shorten_sentences
==
'
after_summarization
'
:
summary_for_date
=
[
sentence_s
ummarization
.
summarization
(
sentence
,
8
,
resolve_unks
)
summary_for_date
=
[
sentence_s
hortening
.
shorten
(
sentence
,
shortening_length
,
resolve_unks
)
for
sentence
in
summary_for_date
]
timeline
[
date
]
=
summary_for_date
...
...
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