<jupyter_start><jupyter_text>Train Our Markov model<jupyter_code>def trainMarkovChain(text,k=4):
    
    T = generateTable(text,k)
    T = convertFreqIntoProb(T)
    
    return T
    
model = trainMarkovChain(data)
print(model)
import numpy as np
import random
def sample_next(ctx,T,k):
    ctx = ctx[-k:]
    if T.get(ctx) is None:
        return " "
    possible_Chars = list(T[ctx].keys())
    possible_values = list(T[ctx].values())
    
    #print(possible_Chars)
    #print(possible_values)
    
    return np.random.choice(possible_Chars,p=possible_values)
sample_next("The",model,6)
def generateText(starting_sent,k=4,maxLen=1000):
    
    sentence = starting_sent
    ctx = starting_sent[-k:]
    
    for ix in range(maxLen):
        next_prediction = sample_next(ctx,model,k)
        sentence += next_prediction
        ctx = sentence[-k:]
    return sentence<jupyter_output><empty_output><jupyter_text>Random Lyrics Generation<jupyter_code>text = generateText("The",k=4,maxLen=2000)
print(text)<jupyter_output>The club isn't mind my lead
I may be my baby, come on, be my baby, come on
Come on
Come overing okay
Leave and new
I'm in love with you were in love
You and the jukebox
And new
I'm in love with the sweet and put Van the driver and pull like you
Every day discovering brand new
I'm singing brand now, follow my lead
Come overing like my baby, come on, be my lead
Come on now, follow my baby, come on, be my baby, come on, be my heart is falling something something like me
Come, come on
I'm in my baby, come on
Come on, be my be my heart up a chance now, follow my waist and now, follow my lead
I may be my lead
I'm in a taxi, the shape of your body
Oh—I—oh—I—oh—I—oh—I—oh—I
I'm in love with your love with your love with your body
Every day discover make the shape of you
One week in love with you know I'm singing shots
Drinking okay
Leave and me
Say, boy, let's not talk too
I'm in the bar is where in love with you
Come on
I'm in love was handmade for something too
I'm singing too much
Grab on ou[...]
{'fraction_non_alphanumeric': 0.08226600985221674, 'fraction_numerical': 0.005911330049261084, 'mean_word_length': 3.870503597122302, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '464135', 'license': 'MIT', 'n_tokens_mistral': 688, 'n_tokens_neox': 654, 'n_words': 269, 'path': 'Automatic Shape of you Song Lyrics Generation.ipynb', 'repo_name': 'shubhamgoel90/Automatic-Lyrics-Generation', 'size': '2030'}