Datasets:
Tidy up code
Browse files- mc4-sampling.py +4 -5
mc4-sampling.py
CHANGED
@@ -340,9 +340,9 @@ class Mc4Sampling(datasets.GeneratorBasedBuilder):
|
|
340 |
probability = factor / quartile_range
|
341 |
return self.rng.uniform() < probability
|
342 |
|
343 |
-
def _should_keep_doc_gaussian(self, doc, factor=None,
|
344 |
-
width = kwargs.get("width", 9 / 2) # width (spread) of the exponential curve
|
345 |
perplexity = self.get_perplexity(doc)
|
|
|
346 |
factor = 0.78 if factor is None else factor
|
347 |
if boundaries is not None:
|
348 |
m = boundaries[1]
|
@@ -352,9 +352,8 @@ class Mc4Sampling(datasets.GeneratorBasedBuilder):
|
|
352 |
weighted_perplexity = factor * exponential
|
353 |
return self.rng.uniform() < weighted_perplexity
|
354 |
|
355 |
-
def _should_keep_doc_random(self, doc, factor=None,
|
356 |
-
if factor is None
|
357 |
-
factor = 0.5
|
358 |
return self.rng.uniform() <= factor
|
359 |
|
360 |
def _info(self):
|
|
|
340 |
probability = factor / quartile_range
|
341 |
return self.rng.uniform() < probability
|
342 |
|
343 |
+
def _should_keep_doc_gaussian(self, doc, factor=None, width=None, **kwargs):
|
|
|
344 |
perplexity = self.get_perplexity(doc)
|
345 |
+
width = (9 / 2) if width is None else width # width (spread) of the exponential curve
|
346 |
factor = 0.78 if factor is None else factor
|
347 |
if boundaries is not None:
|
348 |
m = boundaries[1]
|
|
|
352 |
weighted_perplexity = factor * exponential
|
353 |
return self.rng.uniform() < weighted_perplexity
|
354 |
|
355 |
+
def _should_keep_doc_random(self, doc, factor=None, **kwargs):
|
356 |
+
factor = 0.5 if factor is None else factor
|
|
|
357 |
return self.rng.uniform() <= factor
|
358 |
|
359 |
def _info(self):
|