Lara Martin commited on
Commit
837edef
1 Parent(s): 6d824a6

working data processing

Browse files
Scifi_TV_Shows.py CHANGED
@@ -19,6 +19,8 @@ import json
19
 
20
  import datasets
21
 
 
 
22
  _CITATION = '''
23
  @inproceedings{Ammanabrolu2020AAAI,
24
  title={Story Realization: Expanding Plot Events into Sentences},
@@ -48,6 +50,7 @@ class Scifi_TV_Shows(datasets.GeneratorBasedBuilder):
48
  def _info(self):
49
  features = datasets.Features({
50
  'story_num': datasets.Value('int16'),
 
51
  'event': datasets.Sequence(datasets.Value('string')),
52
  'gen_event': datasets.Sequence(datasets.Value('string')),
53
  'sent': datasets.Value('string'),
@@ -72,12 +75,11 @@ class Scifi_TV_Shows(datasets.GeneratorBasedBuilder):
72
  def _split_generators(self, dl_manager):
73
  my_urls = _URLS[self.config.name]
74
  data_dir = dl_manager.download_and_extract(my_urls)
75
- train_filepath = os.path.join(data_dir, "Test-Train-Val/all-sci-fi-data-train.txt")
76
- test_filepath = os.path.join(data_dir, "Test-Train-Val/all-sci-fi-data-test.txt")
77
- val_filepath = os.path.join(data_dir, "Test-Train-Val/all-sci-fi-data-val.txt")
78
- all_filepath = os.path.join(data_dir, "all-sci-fi-data.txt")
79
  return[
80
- datasets.SplitGenerator(
81
  name=datasets.Split.TRAIN,
82
  gen_kwargs={
83
  'filepath': train_filepath,
@@ -94,41 +96,22 @@ class Scifi_TV_Shows(datasets.GeneratorBasedBuilder):
94
  gen_kwargs={
95
  'filepath': val_filepath,
96
  },
97
- ),
98
- datasets.SplitGenerator(
99
- name="all",
100
- gen_kwargs={
101
- 'filepath': all_filepath,
102
- },
103
- ),
104
  ]
105
 
106
- def _generate_examples(self, filepath, files):
107
- for path, f in files:
108
- if path == filepath:
109
- story_count = 0
110
- with open(filepath, encoding="utf-8") as f:
111
- story = []
112
- for id_, line in enumerate(f.readlines()):
113
- line = line.strip()
114
- if "%%%%%%" in line:
115
- for l in story:
116
- event, gen_event, sent, gen_sent = l.split("|||")
117
- line = line.replace("%%%%%%%%%%%%%%%%%", "")
118
- entities = line.replace("defaultdict(<type 'list'>, ", "")[:-1]
119
- yield id_, {
120
- 'story_num': story_count,
121
- 'event': eval(event),
122
- 'gen_event': eval(gen_event),
123
- 'sent': sent,
124
- 'gen_sent': gen_sent,
125
- 'entities': entities,
126
- }
127
- story = []
128
- story_count+=1
129
- elif "<EOS>" in line:
130
- continue
131
- else:
132
- story.append(line)
133
 
134
 
 
19
 
20
  import datasets
21
 
22
+ import os
23
+
24
  _CITATION = '''
25
  @inproceedings{Ammanabrolu2020AAAI,
26
  title={Story Realization: Expanding Plot Events into Sentences},
 
50
  def _info(self):
51
  features = datasets.Features({
52
  'story_num': datasets.Value('int16'),
53
+ 'story_line': datasets.Value('int16'),
54
  'event': datasets.Sequence(datasets.Value('string')),
55
  'gen_event': datasets.Sequence(datasets.Value('string')),
56
  'sent': datasets.Value('string'),
 
75
  def _split_generators(self, dl_manager):
76
  my_urls = _URLS[self.config.name]
77
  data_dir = dl_manager.download_and_extract(my_urls)
78
+ train_filepath = os.path.join(data_dir, "scifi-train.txt")
79
+ test_filepath = os.path.join(data_dir, "scifi-test.txt")
80
+ val_filepath = os.path.join(data_dir, "scifi-val.txt")
 
81
  return[
82
+ datasets.SplitGenerator(
83
  name=datasets.Split.TRAIN,
84
  gen_kwargs={
85
  'filepath': train_filepath,
 
96
  gen_kwargs={
97
  'filepath': val_filepath,
98
  },
99
+ ),
 
 
 
 
 
 
100
  ]
101
 
102
+ def _generate_examples(self, filepath):
103
+ with open(filepath, encoding="utf-8") as f:
104
+ for id_, line in enumerate(f.readlines()):
105
+ line = line.strip()
106
+ story_num, line_num, event, gen_event, sent, gen_sent, entities = line.split("|||")
107
+ yield id_, {
108
+ 'story_num': story_num,
109
+ 'story_line': line_num,
110
+ 'event': eval(event),
111
+ 'gen_event': eval(gen_event),
112
+ 'sent': sent,
113
+ 'gen_sent': gen_sent,
114
+ 'entities': entities,
115
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
116
 
117
 
dummy/Scifi_TV_Shows/1.1.0/dummy_data.zip DELETED
Binary file (356 kB)