<commit_before>#!/usr/bin/env/python3
"""
LAB: Trigrams
October 20, 2016
"""

def trigram_fun():
    with open('sherlock_small.txt','r') as file_in:
        my_book = file_in.read()
    file_in.close()

    my_book = my_book.replace('\n', ' ')

    l_book = []
    l_book = my_book.split(' ')

    bigram_list = []
    for i in range(len(l_book)-1):
        bigram_list.append((l_book[i],l_book[i+1]))

    trigram_list = []
    for i in range(len(l_book)-2):
        trigram_list.append((l_book[i],l_book[i+1],l_book[i+2]))

    dict_list = {}
    for i in range(len(trigram_list)):
        tri_key = trigram_list[i][0] + ' ' + trigram_list[i][1]
        tri_value = trigram_list[i][2]
        dict_list[tri_key] = tri_value
    
    
    find_key = bigram_list[0][0] + ' ' + bigram_list[0][1]
    find_value = dict_list[find_key]

    print(find_key,find_value)

    #print(my_trigram)


# print(tri_key,tri_value)
# print(dict_list)
# print(trigram_list[0][1])
# print(bigram_list)
# print()
# print(trigram_list)

trigram_fun()<commit_msg>Lab: Trigram - think I am on the right path now<commit_after>#!/usr/bin/env/python3
"""
LAB: Trigrams
October 20, 2016
"""

def trigram_fun():
    with open('sherlock.txt','r') as file_in:
        my_book = file_in.read()
    file_in.close()

    my_book = my_book.replace('\n', ' ')

    l_book = []
    l_book = my_book.split(' ')

    trigram_list = list(zip(l_book,l_book[1:],l_book[2:]))

    dict_list = {}
    for i in range(len(trigram_list)):
        tri_key = trigram_list[i][0] + ' ' + trigram_list[i][1]
        tri_value = trigram_list[i][2]
        if tri_key in dict_list:
            dict_list[tri_key].append(tri_value)
        else:
            dict_list[tri_key] = [tri_value]

    
    for k, v in dict_list.items():
        print('Keys:',k,'\n','Values:',v)


    # print(dict_list.keys())
    # print()
    # print(dict_list.values())

 
    # print(dict_list)


    # print(l_book)
    # print()
    # print(trigram_list)

    # bigram_list = []
    # for i in range(len(l_book)-1):
    #     bigram_list.append((l_book[i],l_book[i+1]))

    # trigram_list = []
    # for i in range(len(l_book)-2):
    #     trigram_list.append((l_book[i],l_book[i+1],l_book[i+2]))

    # print(trigram_list)

    # dict_list = {}
    # for i in range(len(trigram_list)):
    #     tri_key = trigram_list[i][0] + ' ' + trigram_list[i][1]
    #     tri_value = trigram_list[i][2]
    #     dict_list[tri_key] = tri_value
    
    
    # find_key = bigram_list[0][0] + ' ' + bigram_list[0][1]
    # find_value = dict_list[find_key]

    # print(find_key,find_value)

    #print(my_trigram)


    # print(tri_key,tri_value)
    # print(dict_list)
    # print(trigram_list[0][1])
    # print(bigram_list)
    # print()
    # print(trigram_list)

trigram_fun()
{'fraction_non_alphanumeric': 0.16648841354723706, 'fraction_numerical': 0.01675579322638146, 'mean_word_length': 2.9801418439716314, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5514414', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1131, 'n_words': 158}