cdminix commited on
Commit
7b1ef87
·
1 Parent(s): 08b423e

fix window stride and size

Browse files
Files changed (1) hide show
  1. iwslt2011.py +10 -26
iwslt2011.py CHANGED
@@ -65,44 +65,25 @@ class TaggingTask:
65
  """Treat punctuation prediction as a sequence tagging problem."""
66
 
67
  def __init__(
68
- self, window_size=120, window_stride_in_percent=0.5, include_reference=False
69
  ):
70
  self.window_size = window_size
71
- self.window_stride_in_percent = window_stride_in_percent
72
- self.include_reference = include_reference
73
 
74
  def __eq__(self, other):
75
  return Task.TAGGING == other
76
 
77
- class DecodingStrategy:
78
- """Strategy used to decode results."""
79
-
80
- def __init__(
81
- self, task: Union[TaggingTask]
82
- ):
83
- self.task = task
84
-
85
- @abstractmethod
86
- def decode():
87
- pass
88
-
89
- class AverageDecodingStrategy:
90
- """Averages predictions together."""
91
-
92
- def decode():
93
- pass
94
-
95
  class IWSLT11Config(datasets.BuilderConfig):
96
  """The IWSLT11 Dataset."""
97
 
98
  def __init__(
99
  self,
100
- task: Union[TaggingTask] = TaggingTask(),
101
  segmented: bool = False,
102
  asr_or_ref: str = "ref",
103
- decoder: DecodingStrategy = AverageDecodingStrategy(),
104
  tokenizer = None,
105
  label_subword = LabelSubword.IGNORE,
 
 
106
  **kwargs
107
  ):
108
  """BuilderConfig for IWSLT2011.
@@ -111,10 +92,13 @@ class IWSLT11Config(datasets.BuilderConfig):
111
  segmented: if segmentation present in IWSLT2011 should be respected. removes segmenation by default.
112
  **kwargs: keyword arguments forwarded to super.
113
  """
114
- self.task = task
 
 
 
 
115
  self.segmented = segmented
116
  self.asr_or_ref = asr_or_ref
117
- self.decoder = decoder
118
  self.punctuation = [
119
  Punctuation.NONE,
120
  Punctuation.PERIOD,
@@ -258,7 +242,7 @@ class IWSLT11(datasets.GeneratorBasedBuilder):
258
  return window(
259
  l,
260
  self.config.task.window_size,
261
- int(self.config.task.window_size*self.config.task.window_stride_in_percent)
262
  )
263
  ids = apply_window(np.arange(len(tokens)))
264
  tokens = apply_window(tokens)
 
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  class IWSLT11Config(datasets.BuilderConfig):
77
  """The IWSLT11 Dataset."""
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
  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 = [
103
  Punctuation.NONE,
104
  Punctuation.PERIOD,
 
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)