cdminix commited on
Commit
787665f
1 Parent(s): 7b1ef87

fix task window and stride

Browse files
Files changed (1) hide show
  1. iwslt2011.py +10 -18
iwslt2011.py CHANGED
@@ -63,13 +63,6 @@ class Task(Enum):
63
 
64
  class TaggingTask:
65
  """Treat punctuation prediction as a sequence tagging problem."""
66
-
67
- def __init__(
68
- self, window_size=120, window_stride=60
69
- ):
70
- self.window_size = window_size
71
- self.window_stride = window_stride
72
-
73
  def __eq__(self, other):
74
  return Task.TAGGING == other
75
 
@@ -78,12 +71,13 @@ class IWSLT11Config(datasets.BuilderConfig):
78
 
79
  def __init__(
80
  self,
 
81
  segmented: bool = False,
82
  asr_or_ref: str = "ref",
83
  tokenizer = None,
84
  label_subword = LabelSubword.IGNORE,
85
- window_size = None,
86
- window_stride = None,
87
  **kwargs
88
  ):
89
  """BuilderConfig for IWSLT2011.
@@ -92,11 +86,9 @@ class IWSLT11Config(datasets.BuilderConfig):
92
  segmented: if segmentation present in IWSLT2011 should be respected. removes segmenation by default.
93
  **kwargs: keyword arguments forwarded to super.
94
  """
95
- self.task = TaggingTask()
96
- if window_size is not None:
97
- self.task.window_size = window_size
98
- if window_stride is not None:
99
- self.task.window_stride = window_stride
100
  self.segmented = segmented
101
  self.asr_or_ref = asr_or_ref
102
  self.punctuation = [
@@ -241,8 +233,8 @@ class IWSLT11(datasets.GeneratorBasedBuilder):
241
  def apply_window(l):
242
  return window(
243
  l,
244
- self.config.task.window_size,
245
- self.config.task.window_stride
246
  )
247
  ids = apply_window(np.arange(len(tokens)))
248
  tokens = apply_window(tokens)
@@ -252,8 +244,8 @@ class IWSLT11(datasets.GeneratorBasedBuilder):
252
  return_offsets_mapping=True,
253
  padding=True,
254
  truncation=True,
255
- max_length=int(self.config.task.window_size*2),
256
- pad_to_multiple_of=int(self.config.task.window_size*2)
257
  )
258
  labels = apply_window(labels)
259
  for i, (ids, labels) in enumerate(zip(ids, labels)):
 
63
 
64
  class TaggingTask:
65
  """Treat punctuation prediction as a sequence tagging problem."""
 
 
 
 
 
 
 
66
  def __eq__(self, other):
67
  return Task.TAGGING == other
68
 
 
71
 
72
  def __init__(
73
  self,
74
+ task = TaggingTask(),
75
  segmented: bool = False,
76
  asr_or_ref: str = "ref",
77
  tokenizer = None,
78
  label_subword = LabelSubword.IGNORE,
79
+ window_size = 120,
80
+ window_stride = 60,
81
  **kwargs
82
  ):
83
  """BuilderConfig for IWSLT2011.
 
86
  segmented: if segmentation present in IWSLT2011 should be respected. removes segmenation by default.
87
  **kwargs: keyword arguments forwarded to super.
88
  """
89
+ self.task = task
90
+ self.window_size = window_size
91
+ self.window_stride = window_stride
 
 
92
  self.segmented = segmented
93
  self.asr_or_ref = asr_or_ref
94
  self.punctuation = [
 
233
  def apply_window(l):
234
  return window(
235
  l,
236
+ self.config.window_size,
237
+ self.config.window_stride
238
  )
239
  ids = apply_window(np.arange(len(tokens)))
240
  tokens = apply_window(tokens)
 
244
  return_offsets_mapping=True,
245
  padding=True,
246
  truncation=True,
247
+ max_length=int(self.config.window_size*2),
248
+ pad_to_multiple_of=int(self.config.window_size*2)
249
  )
250
  labels = apply_window(labels)
251
  for i, (ids, labels) in enumerate(zip(ids, labels)):