<commit_before>import random

from mongoframes.factory.makers import Maker

__all__ = [
    'OneOf',
    'SomeOf'
    ]


class OneOf(Maker):
    """
    Pick one item from a list of makers or values.
    """

    def __init__(self, items, weights=None):

        # The list of makers/values to select from
        self._items = items

        # The weighting to apply when selecting a maker/value
        self._weights = weights

    def _assemble(self):
        # Select an item
        item_index = 0
        if self._weights:
            item_index = self.weighted(self._weights)<commit_msg>Added `Cycle` maker.<commit_after>import random

from mongoframes.factory.makers import Maker

__all__ = [
    'OneOf',
    'SomeOf'
    ]


class Cycle(Maker):
    """
    Pick the next item from a list of makers or values cycling through the list
    and repeating when we reach the end.
    """

    def __init__(self, items, weights=None):

        # The list of makers/values to select from
        self._items = items

        # The index of the item that will be returned next
        self._item_index = 0

    def reset(self):
        """Reset the item index"""
        self._item_index = 0

    def _assemble(self):
        # Select the next item
        item_index = self._item_index
        item = self._items[item_index]

        # Move the index on 1 (and wrap it if we are at the end of the list)
        self._item_index += 1
        if self._item_index >= len(self._items):
            self._item_index = 0

        # Return the index and it's assembled value
        if isinstance(item, Maker):
            return [item_index, item._assemble()]
        return [item_index, None]

    def _finish(self, value):
        item = self._items[value[0]]
        if isinstance(item, Maker):
            return item._finish(value[1])
        return item


class OneOf(Maker):
    """
    Pick one item from a list of makers or values.
    """

    def __init__(self, items, weights=None):

        # The list of makers/values to select from
        self._items = items

        # The weighting to apply when selecting a maker/value
        self._weights = weights

    def _assemble(self):
        # Select an item
        item_index = 0
        if self._weights:
            item_index = self.weighted(self._weights)
{'fraction_non_alphanumeric': 0.08362068965517241, 'fraction_numerical': 0.003879310344827586, 'mean_word_length': 2.123822341857335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7473969', 'n_tokens_mistral': 689, 'n_tokens_neox': 644, 'n_words': 230}