<commit_before>from enum import IntEnum
import sqlite3
import matplotlib.pyplot as plt
import numpy as np
from findType import getType

DB = 'db/development.sqlite3'
Style = IntEnum('Style', 'Contributor, Collaborator, Communicator, Challenger', start=0)

def getStylesData():
    """Returns number of students per style"""

    # Get all scores
    conn = sqlite3.connect(DB)
    c = conn.cursor()
    scores = c.execute('SELECT * FROM styles').fetchall()
    conn.commit()
    conn.close()

    # Get types from scores
    # If multiple types, all counted
    data = [0.0] * len(Style)

    # Loop through each student, and get the types of each student
    for i in range(len(scores)):
        studentScores = scores[i][2:6]
        types = getType(studentScores)
        length = len(types)
        for j in range(len(types)):
            data[types[j]] += 1.0/length
    
    return data

def main():
    """Gives the graph of the overall distribution of types"""
    labels = [Style(x).name for x in range(len(Style))]
    yPos = np.arange(len(labels))
    data = getStylesData()

    plt.bar(yPos, data, align = 'center', alpha = 0.5)
    plt.xticks(yPos, labels)
    plt.ylabel("Number of Students")
    plt.title("Overall Distribution of Types")

    plt.savefig('app/assets/images/overall.png', bbox_inches='tight')

if __name__ == "__main__":
    main()

    
<commit_msg>Update overallBar.py<commit_after>from enum import IntEnum
import sqlite3
import matplotlib.pyplot as plt
import numpy as np
from findType import getType

DB = 'db/development.sqlite3'
Style = IntEnum('Style', 'Contributor, Collaborator, Communicator, Challenger', start=0)

def getStylesData():
    """Returns number of students per style"""

    # Get all scores
    conn = sqlite3.connect(DB)
    c = conn.cursor()
    scores = c.execute('SELECT * FROM styles').fetchall()
    conn.commit()
    conn.close()

    # Get types from scores
    # If multiple types, all counted
    data = [0.0] * len(Style)

    # Loop through each student, and get the types of each student
    for i in range(len(scores)):
        studentScores = scores[i][2:6]
        types = getType(studentScores)
        length = len(types)
        for j in range(len(types)):
            data[types[j]] += 1.0/length
    
    return data

def main():
    """Gives the graph of the overall distribution of types"""
    labels = [Style(x).name for x in range(len(Style))]
    yPos = np.arange(len(labels))
    data = getStylesData()

    plt.bar(yPos, data, align = 'center', alpha = 0.5)
    plt.xticks(yPos, labels)
    plt.ylabel("Number of Students")
    plt.title("Overall Distribution of Types")

    plt.savefig('app/assets/images/overall.png', bbox_inches='tight')

if __name__ == "__main__":
    main()

{'fraction_non_alphanumeric': 0.12396096855800506, 'fraction_numerical': 0.008673653776653415, 'mean_word_length': 3.1749622926093513, 'pattern_counts': {'":': 2, '<': 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': '1183735', 'n_tokens_mistral': 896, 'n_tokens_neox': 868, 'n_words': 263}