Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NN Projekt SS22
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
kreuzer
NN Projekt SS22
Commits
97c971d6
Commit
97c971d6
authored
2 years ago
by
kreuzer
Browse files
Options
Downloads
Patches
Plain Diff
Aktualisieren structures.py
parent
3b956c5d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
structures.py
+17
-19
17 additions, 19 deletions
structures.py
with
17 additions
and
19 deletions
structures.py
+
17
−
19
View file @
97c971d6
# DataSet
# assembles all datapoints, representing cnn_dailymail
class
DataSetPreprocessed
:
def
__init__
(
self
,
dataset
):
# DataPoint
# DataPoint
# preprocessed Repr of a Document for model (training, testing)
# preprocessed Repr of a Document for model (training, testing)
import
torch
import
torch
import
numpy
as
np
import
numpy
as
np
# m = 3 sentences in summaries
# m = 3 sentences in summaries
# p = 20 top scoring sentences
# p = 20 top scoring sentences
# k = 5 top scoring summaries
# k = 5 top scoring summaries
...
@@ -22,8 +14,6 @@ class DataPoint:
...
@@ -22,8 +14,6 @@ class DataPoint:
def
__init__
(
self
,
doc_str
,
sum_str
,
model_gensim
,
nlp
):
def
__init__
(
self
,
doc_str
,
sum_str
,
model_gensim
,
nlp
):
def
preprocess
(
string
):
def
preprocess
(
string
):
doc_preprocessed
=
nlp
(
string
)
doc_preprocessed
=
nlp
(
string
)
...
@@ -55,7 +45,6 @@ class DataPoint:
...
@@ -55,7 +45,6 @@ class DataPoint:
self
.
raw_document
,
self
.
document
=
preprocess
(
doc_str
)
self
.
raw_document
,
self
.
document
=
preprocess
(
doc_str
)
self
.
raw_summary
,
self
.
summary
=
preprocess
(
sum_str
)
self
.
raw_summary
,
self
.
summary
=
preprocess
(
sum_str
)
# output of sentence encoder (not padded)
# output of sentence encoder (not padded)
self
.
sent_vecs
=
None
self
.
sent_vecs
=
None
...
@@ -74,18 +63,27 @@ class DataPoint:
...
@@ -74,18 +63,27 @@ class DataPoint:
pass
pass
def
preproces
(
doc_str
):
def
compute_sent_vecs
(
mdoel
):
# takes a document, split in sentences, and returns tokens in list of list
#model.sentence_encoder
pass
def
get_word_embeddings
(
model_gensim
):
# takes string repr of document, after preprocessing returns word-embeddings => tensor repr for doc, summary
# DataSet
# assembles all datapoints, representing cnn_dailymail
class
DataSetPreprocessed
:
def
__init__
(
self
,
dataset
,
model_gensim
,
nlp
):
def
read_data
(
part
):
l
=
[]
for
y
in
dataset
[
part
]:
article
,
highlights
=
y
[
'
article
'
],
y
[
'
highlights
'
]
# for every document
l
.
append
(
DataPoint
(
article
,
highlights
,
model_gensim
,
nlp
))
return
l
def
compute_sent_vecs
(
mdoel
):
#model.sentence_encoder
self
.
train
=
read_data
(
'
train
'
)
self
.
test
=
read_data
(
'
test
'
)
self
.
validation
=
read_data
(
'
validation
'
)
import
stanza
import
stanza
...
...
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