# Path: logparser/MoLFI/main/org/core/chromosome/chromosome.py
# class Chromosome:
#     """ A chromosome in this class is a dictionary
#         key: int
#         value: List[Templates]
#     """
# 
#     def __init__(self, p_templates: dict()):
#         """ The constructor with an attribute of type List of Template
#         :param p_templates: a dictionary of Template
#         """
#         self.templates = p_templates
#         self.coverage = 0
# 
#     def add_template(self, template: Template):
#         """ Adds a template to the chromosome
#         
#         :param template: an object of type Template
#         :return: the template will be added to the corresponding cluster
#         with key = len(template)
#         """
#         key = template.get_length()
#         if key in self.templates.keys():
#             self.templates[key].append(template)
#         else:
#             self.templates[key] = []
#             self.templates[key].append(template)
# 
#     def delete_template(self, template: Template):
#         """ Deletes the template from the given cluster id      
#         :param 
#             index: cluster id
#         :return  
#             the cluster without the template
#         :raises 
#             IndexError: An error occurs if a negative cluster id is provided
#             or if the cluster id doesn't exist
#         """
#         key = template.get_length()
#         if key not in self.templates:
#             raise IndexError("No cluster with the giving id!")
# 
#         self.templates[key].remove(template)
# 
#     def number_of_clusters(self):
#         """ Get the number of clusters inside the chromosome
#         :return: 
#             an integer: number of cluster 
#         """
#         return len(self.templates.keys())
# 
#     def cluster_size(self, cluster_id: int):
#         """ Get the number of templates inside a given cluster
#         :return: 
#             an integer: number of templates 
#         """
#         return len(self.templates[cluster_id])
# 
#     def all_templates(self):
#         """ Returns the total number of templates of a chromosome
#         """
#         number_templates = 0
#         for key in self.templates.keys():
#             number_templates = number_templates + self.cluster_size(key)
#         return number_templates
# 
#     def to_string(self):
#         """ Prints the content of a chromosome
#        :return: all templates as a string 
#         """
#         s = ""
#         for list_t in self.templates.values():
#             for t in list_t:
# 
#                 s = s + t.to_string() + "\n"
#         return s
# 
# Path: logparser/MoLFI/main/org/core/chromosome/template.py
# class Template:
#     """ An object representing the smallest element of a chromosome which is a template
#         Template is a list of strings
#     """
# 
#     def __init__(self, p_template: List[str]):
#         """ The constructor of the Class Template
#         initialize the object with a list of strings
#         and initialize the frequency and specificity with 0.0
#         and an empty list that will contain the line number matching the template
#         """
#         self.token = p_template
#         self.specificity = 0.0
#         self.matched_lines = []
#         self.changed = True
# 
#     def get_length(self):
#         """ Gets the number of strings in the list    
#         """
#         return len(self.token)
# 
#     def to_string(self):
#         """ Returns the template's token as one string
#         """
#         s = "[ "
#         for i in self.token:
#             s = s+i+' '
# 
#         s = s + ']'
#         return s
# 
#     def is_changed(self):
#         """ Returns the status of the template (changed or did not change)
#         """
#         return self.changed
# 
#     def set_changed(self, p_changed : bool):
#         """ Sets the status of a template to True if one of its tokens changes,
#         else the status is False (not changed)
#         """
#         self.changed = p_changed
# 
# Path: logparser/MoLFI/main/org/core/utility/message.py
# class Message:
#     """ This class represents a log message as a list of strings
#     """
# 
#     def __init__(self, p_message: List[str]):
#         """ Initialize the objet with an list of strings
#         :param p_message
#         """
#         self.words = p_message
# 
#     def get_length(self):
#         """ Get the number of strings in the list
#         """
#         return len(self.words)
# 
#     def to_string(self):
#         """ Convert the list of words to one string
#         """
#         string = ""
#         for index in range(0, len(self.words)):
#             if index < len(self.words) - 1:
#                 string = string + self.words[index] + " "
#             else:
#                 string = string + self.words[index]
#         return string


from typing import List, Set
from ..chromosome.chromosome import Chromosome
from ..chromosome.template import Template
from ..utility.message import Message

    :return: True if two list are equal
             False if two lists are different
    """
    if len(message.words) != template.get_length():
        return False
    for index in range(0, template.get_length()):
        if template.token[index] == "*" or template.token[index] == "#spec#":
            continue
        if template.token[index] != message.words[index]:
            return False
    return True


def template_match(template1: Template, template2: Template):
    """ Compare two lists of strings
    :param template1: first template
    :param template2: second template
    :return: True if template1 is a "sub-set" of template2
             False if two lists are different
    """
    if template1.get_length() != template2.get_length():
        return False
    for index in range(0, template1.get_length()):
        if template2.token[index] == "*":
            continue
        if template1.token[index] != template2.token[index]:
            return False
    return True



# Path: logparser/MoLFI/main/org/core/chromosome/chromosome.py
# class Chromosome:
#     """ A chromosome in this class is a dictionary
#         key: int
#         value: List[Templates]
#     """
# 
#     def __init__(self, p_templates: dict()):
#         """ The constructor with an attribute of type List of Template
#         :param p_templates: a dictionary of Template
#         """
#         self.templates = p_templates
#         self.coverage = 0
# 
#     def add_template(self, template: Template):
#         """ Adds a template to the chromosome
#         
#         :param template: an object of type Template
#         :return: the template will be added to the corresponding cluster
#         with key = len(template)
#         """
#         key = template.get_length()
#         if key in self.templates.keys():
#             self.templates[key].append(template)
#         else:
#             self.templates[key] = []
#             self.templates[key].append(template)
# 
#     def delete_template(self, template: Template):
#         """ Deletes the template from the given cluster id      
#         :param 
#             index: cluster id
#         :return  
#             the cluster without the template
#         :raises 
#             IndexError: An error occurs if a negative cluster id is provided
#             or if the cluster id doesn't exist
#         """
#         key = template.get_length()
#         if key not in self.templates:
#             raise IndexError("No cluster with the giving id!")
# 
#         self.templates[key].remove(template)
# 
#     def number_of_clusters(self):
#         """ Get the number of clusters inside the chromosome
#         :return: 
#             an integer: number of cluster 
#         """
#         return len(self.templates.keys())
# 
#     def cluster_size(self, cluster_id: int):
#         """ Get the number of templates inside a given cluster
#         :return: 
#             an integer: number of templates 
#         """
#         return len(self.templates[cluster_id])
# 
#     def all_templates(self):
#         """ Returns the total number of templates of a chromosome
#         """
#         number_templates = 0
#         for key in self.templates.keys():
#             number_templates = number_templates + self.cluster_size(key)
#         return number_templates
# 
#     def to_string(self):
#         """ Prints the content of a chromosome
#        :return: all templates as a string 
#         """
#         s = ""
#         for list_t in self.templates.values():
#             for t in list_t:
# 
#                 s = s + t.to_string() + "\n"
#         return s
# 
# Path: logparser/MoLFI/main/org/core/chromosome/template.py
# class Template:
#     """ An object representing the smallest element of a chromosome which is a template
#         Template is a list of strings
#     """
# 
#     def __init__(self, p_template: List[str]):
#         """ The constructor of the Class Template
#         initialize the object with a list of strings
#         and initialize the frequency and specificity with 0.0
#         and an empty list that will contain the line number matching the template
#         """
#         self.token = p_template
#         self.specificity = 0.0
#         self.matched_lines = []
#         self.changed = True
# 
#     def get_length(self):
#         """ Gets the number of strings in the list    
#         """
#         return len(self.token)
# 
#     def to_string(self):
#         """ Returns the template's token as one string
#         """
#         s = "[ "
#         for i in self.token:
#             s = s+i+' '
# 
#         s = s + ']'
#         return s
# 
#     def is_changed(self):
#         """ Returns the status of the template (changed or did not change)
#         """
#         return self.changed
# 
#     def set_changed(self, p_changed : bool):
#         """ Sets the status of a template to True if one of its tokens changes,
#         else the status is False (not changed)
#         """
#         self.changed = p_changed
# 
# Path: logparser/MoLFI/main/org/core/utility/message.py
# class Message:
#     """ This class represents a log message as a list of strings
#     """
# 
#     def __init__(self, p_message: List[str]):
#         """ Initialize the objet with an list of strings
#         :param p_message
#         """
#         self.words = p_message
# 
#     def get_length(self):
#         """ Get the number of strings in the list
#         """
#         return len(self.words)
# 
#     def to_string(self):
#         """ Convert the list of words to one string
#         """
#         string = ""
#         for index in range(0, len(self.words)):
#             if index < len(self.words) - 1:
#                 string = string + self.words[index] + " "
#             else:
#                 string = string + self.words[index]
#         return string


# Path: logparser/MoLFI/main/org/core/utility/match_utility.py
from typing import List, Set
from ..chromosome.chromosome import Chromosome
from ..chromosome.template import Template
from ..utility.message import Message

    :return: True if two list are equal
             False if two lists are different
    """
    if len(message.words) != template.get_length():
        return False
    for index in range(0, template.get_length()):
        if template.token[index] == "*" or template.token[index] == "#spec#":
            continue
        if template.token[index] != message.words[index]:
            return False
    return True


def template_match(template1: Template, template2: Template):
    """ Compare two lists of strings
    :param template1: first template
    :param template2: second template
    :return: True if template1 is a "sub-set" of template2
             False if two lists are different
    """
    if template1.get_length() != template2.get_length():
        return False
    for index in range(0, template1.get_length()):
        if template2.token[index] == "*":
            continue
        if template1.token[index] != template2.token[index]:
            return False
    return True



def remove_sub_templates(chromosome: Chromosome, cluster_id: int):
