<commit_before>from findSentence import sentenceGrab
from phoneticWords import findPhonetics
from phoneticIndex import findPhoneticIndex
from random import randint
from math import floor
import sys


def main():
    subject = sys.argv[1]
    library = sys.argv[2]

    phonetics = findPhonetics(subject, "/usr/share/dict/web2") 
    nearPhoneticNum = phonetics[0][1]
    phonetics = [i for i in phonetics if i[1] == nearPhoneticNum]

    sentences = []
    tries = 10
    index = 0
    while len(sentences) == 0 and index <= tries:
        index += 1
        punWord = phonetics[randint(0, floor(len(phonetics)/2))][0]
        print(punWord)
        sentences = sentenceGrab(punWord, library, True)
        if len(sentences) == 0:
            phonetics = [i for i in phonetics if i[0] != punWord]
            print("Could not find sentence... Trying again")

    if len(sentences) == 0:
        print("Reached maximum tries. Ending")
        return

    punSentence = sentences[randint(0, floor(len(sentences)/2))]

    sentenceIndex = punSentence.find(punWord)
    punIndex = findPhoneticIndex(subject, punWord)
    punSentence = punSentence[0:sentenceIndex + punIndex] + subject + punSentence[sentenceIndex + punIndex + len(subject):len(punSentence)]
    
    print(punSentence)

if __name__ == "__main__":
    main()<commit_msg>Fixed some array out of bounds errors. Changed dictionary location.<commit_after>from findSentence import sentenceGrab
from phoneticWords import findPhonetics
from phoneticIndex import findPhoneticIndex
from random import randint
from math import floor
import sys


def main():
    subject = sys.argv[1]
    library = sys.argv[2]

    phonetics = findPhonetics(subject, "/usr/share/dict/words")
    nearPhoneticNum = floor((phonetics[0][1] + phonetics[len(phonetics)-1][1]) / 2)
    phonetics = [i for i in phonetics if i[1] <= nearPhoneticNum]

    sentences = []
    tries = 10
    index = 0
    while len(sentences) == 0 and index <= tries:
        if len(phonetics) == 0:
            print("Reached maximum tries. Ending")
            return
        index += 1
        punWord = phonetics[randint(0, floor((len(phonetics)-1)/2))][0]
        print(punWord)
        sentences = sentenceGrab(punWord, library, True)
        if len(sentences) == 0:
            phonetics = [i for i in phonetics if i[0] != punWord]
            print("Could not find sentence... Trying again")


    punSentence = sentences[randint(0, floor((len(sentences)-1)/2))]

    sentenceIndex = punSentence.find(punWord)
    punIndex = findPhoneticIndex(subject, punWord)
    punSentence = punSentence[0:sentenceIndex + punIndex] + subject + punSentence[sentenceIndex + punIndex + len(subject):len(punSentence)]
    
    print(punSentence)

if __name__ == "__main__":
    main()
{'fraction_non_alphanumeric': 0.11035226455787203, 'fraction_numerical': 0.015815959741193385, 'mean_word_length': 3.3013910355486864, 'pattern_counts': {'":': 2, '<': 6, '<?xml version=': 0, '>': 3, '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': '5126016', 'n_tokens_mistral': 918, 'n_tokens_neox': 856, 'n_words': 228}