<jupyter_start><jupyter_text>Text Generator<jupyter_code># Read the data
# process the text
#   - vectorize
#   - Before training, we need to map strings to a numerical representation. 
#   - Create two lookup tables: one mapping characters to numbers, and another for numbers to characters.
# Create training examples and targets
#   - Next divide the text into example sequences. Each input sequence will contain seq_length characters from the text.
#   - For each input sequence, the corresponding targets contain the same length of text, except shifted one character to the right.
#   - To do this first use the tf.data.Dataset.from_tensor_slices function to convert the text vector into a stream of character indices.
#   - The batch method lets us easily convert these individual characters to sequences of the desired size.
#   - For each sequence, duplicate and shift it to form the input and target text by using the map method to apply a simple function to each batch:
# Create training batches
#<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.04633204633204633, 'fraction_numerical': 0.0, 'mean_word_length': 4.2639593908629445, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '427036', 'license': 'MIT', 'n_tokens_mistral': 251, 'n_tokens_neox': 250, 'n_words': 143, 'path': 'sprint-prep.ipynb', 'repo_name': 'spentaur/DS-Unit-4-Sprint-3-Deep-Learning', 'size': '1036'}