<commit_before>import re
from sys import argv
import math

def main(program):
    


if __name__=='__main__':
    # confirm that program is supplied with a file to analyze
    if (len(argv) != 2):
        print('No root directory supplied! Please supply a directory path!')
    else:
        program = argv[1]
        main(program)
<commit_msg>Add reg ex portion<commit_after>from re import subn
from sys import argv
import math


def allLines(program):
    fstr = open(filename)                  
    lines = 0
    buf_size = 1024 * 1024
    read_f = f.read # loop optimization
    buf = read_f(buf_size)
    while buf:
        lines += buf.count('\n')
        buf = read_f(buf_size)
    return lines

def allComments(program):
    fstr = open(path).read()
    return re.subn('(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/)|(//.*)',"",fstr)[1]
    
def percentage(part,whole):
    return 100 * float(part)/float(whole)
    
def main(program):
    total = allLines(program)
    comments = allComments
    print(percentage(comments,total))

if __name__=='__main__':
    # confirm that program is supplied with a file to analyze
    if (len(argv) != 2):
        print('No root directory supplied! Please supply a directory path!')
    else:
        program = argv[1]
        main(program)

{'fraction_non_alphanumeric': 0.13551401869158877, 'fraction_numerical': 0.0132398753894081, 'mean_word_length': 2.7905604719764012, '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': '7157607', 'n_tokens_mistral': 430, 'n_tokens_neox': 403, 'n_words': 120}