<commit_before>#! /usr/bin/env Python3

import math


def Entropy(l):  # l is the list included times of each variable
    sumNum = sum(l)
    result = 0
    for i in l:
        if i == 0:
            result += 0
        else:
            result += - (i / sumNum) * math.log2(i / sumNum)

    return result


class Leaf():
    leaf = {}

    def __init__(self, **kwargs):
        self.leaf = kwargs


class Node():

    def __init__(self, tag):
        self.this = tag
        self.childList = []
        self.childNode = {}
        self.leaves = {}

    def addNode(self, chileWay, childNode):  # might be changed futrue
        self.childNode[chileWay] = childNode
        self.childList.append(chileWay)

    def addLeaf(self, chileWay, leaf):
        self.leaves[chileWay] = leaf
        self.childList.append(chileWay)

    def search(self, *attributions):
        pass


def main():

    a = Node("outlook?")
    b1 = Node("humidity?")
    b2 = Leaf("play"=4, "noPlay"=0)
    b3 = Node("windy?")

    c1 = Leaf("play"=2, "noPlay"=0)
    c2 = Leaf("play"=0, "noPlay"=3)
    c3 = Leaf("play"=0, "noPlay"=2)
    c4 = Leaf("play"=3, "noPlay"=0)

    a.addNode("sunny", b1)
    a.addNode("rain", b3)
    a.addLeaf("overcast", b2)

    b1.addLeaf("<=70", c1)
    b1.addLeaf(">70", c2)

    b3.addLeaf("true", c3)
    b3.addLeaf("false", c4)

    print(c1[play])


if __name__ == "__main__":<commit_msg>a bit, change the design in leaf<commit_after>#! /usr/bin/env Python3

import math


def Entropy(l):  # l is the list included times of each variable
    sumNum = sum(l)
    result = 0
    for i in l:
        if i == 0:
            result += 0
        else:
            result += - (i / sumNum) * math.log2(i / sumNum)

    return result


class Leaf():
    leaf = {}

    def __init__(self, dic):
        for key in dic:
            self.leaf[key] = dic[key]


class Node():

    def __init__(self, tag):
        self.this = tag
        self.childList = []
        self.childNode = {}
        self.leaves = {}

    def addNode(self, chileWay, childNode):  # might be changed futrue
        self.childNode[chileWay] = childNode
        self.childList.append(chileWay)

    def addLeaf(self, chileWay, leaf):
        self.leaves[chileWay] = leaf
        self.childList.append(chileWay)

    def search(self, *attributions):
        pass


def main():

    a = Node("outlook?")
    b1 = Node("humidity?")
    b2 = Leaf({"play": 4, "noPlay": 0})
    b3 = Node("windy?")

    c1 = Leaf({"play": 2, "noPlay": 0})
    c2 = Leaf({"play": 0, "noPlay": 3})
    c3 = Leaf({"play": 0, "noPlay": 2})
    c4 = Leaf({"play": 3, "noPlay": 0})

    a.addNode("sunny", b1)
    a.addNode("rain", b3)
    a.addLeaf("overcast", b2)

    b1.addLeaf("<=70", c1)
    b1.addLeaf(">70", c2)

    b3.addLeaf("true", c3)
    b3.addLeaf("false", c4)

    print(c1.leaf)


if __name__ == "__main__":
{'fraction_non_alphanumeric': 0.16190807799442897, 'fraction_numerical': 0.026462395543175487, 'mean_word_length': 2.264772727272727, 'pattern_counts': {'":': 12, '<': 5, '<?xml version=': 0, '>': 5, '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': '1831491', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1079, 'n_words': 255}