<commit_before>__author__ = 'Boot'

from collections import defaultdict

def gen_table(data):
    # calculate max size of each column
    columnSizes = defaultdict(int)
    for row in data:
        for column, cell in enumerate(row):
            columnSizes[column] = max(columnSizes[column], len(cell))

    # headers
    str = "|"
    for col, cell in enumerate(data[0]):
        FORMAT_STR = " {{:<{}}} |" .format(columnSizes[col])
        str += FORMAT_STR.format(cell)
    str += "\n"

    # headers separating line
    str += "|"
    for i in range(len(data[0])):
        str += "-" * columnSizes[i] + "--|" # add 2 dashes for spacing around text
    str += "\n"

    # rest of table
    for row in data[1:]:
        str += "|"
        for col, cell in enumerate(row):
            FORMAT_STR = " {{:<{}}} |" .format(columnSizes[col])
            str += FORMAT_STR.format(cell)
        str += "\n"


    return str


def gen_heading(headingText, depth = 1, alternative = False):
    if alternative and depth == 1:
        str = headingText + "\n"
        str += "=" * len(headingText)
        return str + "\n"
    if alternative and depth is 2:
        str = headingText + "\n"
        str += "-" * len(headingText)
        return str + "\n"
    else:
        str = "#" * depth
        str += " "
        str += headingText
        return str + "\n"


def gen_link(url, text="", alternativeText=""):
    if text is "" and alternativeText is "":
        return url + "\n"
    elif alternativeText is "":
        return '[{}]({})\n'.format(text, url)
    else:
        return '[{}]({} "{}")\n'.format(text, url, alternativeText)

def gen_reference(reference_id, reference_text, text="", references_list = []):
    if text is "":
        str = " [{}]\n".format(reference_id)
    else:
        str = "[{}][{}]\n".format(text, reference_id)
    ref = "[{}]: {}\n".format(reference_id, reference_text)
    references_list.append(ref)
    return str, references_list

def main():
    data = [
        ["abcdefghij", "aaa", "b"],
        ["b", "c", "b"],
        ["dddddddddd", "a", "c"]
    ]

    print gen_table(data)


if __name__ == "__main__":
    main()<commit_msg>Add functions for new line and paragraph<commit_after>__author__ = 'Boot'

from collections import defaultdict

def gen_table(data):
    # calculate max size of each column
    columnSizes = defaultdict(int)
    for row in data:
        for column, cell in enumerate(row):
            columnSizes[column] = max(columnSizes[column], len(cell))

    # headers
    str = "|"
    for col, cell in enumerate(data[0]):
        FORMAT_STR = " {{:<{}}} |" .format(columnSizes[col])
        str += FORMAT_STR.format(cell)
    str += "\n"

    # headers separating line
    str += "|"
    for i in range(len(data[0])):
        str += "-" * columnSizes[i] + "--|" # add 2 dashes for spacing around text
    str += "\n"

    # rest of table
    for row in data[1:]:
        str += "|"
        for col, cell in enumerate(row):
            FORMAT_STR = " {{:<{}}} |" .format(columnSizes[col])
            str += FORMAT_STR.format(cell)
        str += "\n"


    return str


def gen_heading(headingText, depth = 1, alternative = False):
    if alternative and depth == 1:
        str = headingText + "\n"
        str += "=" * len(headingText)
        return str + "\n"
    if alternative and depth is 2:
        str = headingText + "\n"
        str += "-" * len(headingText)
        return str + "\n"
    else:
        str = "#" * depth
        str += " "
        str += headingText
        return str + "\n"


def gen_link(url, text="", alternativeText=""):
    if text is "" and alternativeText is "":
        return url + "\n"
    elif alternativeText is "":
        return '[{}]({})\n'.format(text, url)
    else:
        return '[{}]({} "{}")\n'.format(text, url, alternativeText)

def gen_reference(reference_id, reference_text, text="", references_list = []):
    if text is "":
        str = " [{}]\n".format(reference_id)
    else:
        str = "[{}][{}]\n".format(text, reference_id)
    ref = "[{}]: {}\n".format(reference_id, reference_text)
    references_list.append(ref)
    return str, references_list
    
def gen_new_line():
	return "  \n"

def gen_section():
	return "\n\n"


def main():
    data = [
        ["abcdefghij", "aaa", "b"],
        ["b", "c", "b"],
        ["dddddddddd", "a", "c"]
    ]

    print gen_table(data)


if __name__ == "__main__":
    main()
{'fraction_non_alphanumeric': 0.16902993472878686, 'fraction_numerical': 0.0031510240828269186, 'mean_word_length': 2.3288389513108614, 'pattern_counts': {'":': 8, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '4980615', 'n_tokens_mistral': 1471, 'n_tokens_neox': 1437, 'n_words': 385}