<commit_before>"""
paswordstrength module can be used to get a password strength score of a string. It is based on various rules which are similar to those found in Wolfram Alpha.
"""

import string

class passwordstrength:
    def __init__(self, password):
        self.password = password
        #Calculating the score
        self.score = 0
        self.score += self.__lenght_score()
        self.score += self.__lower_upper_case_score()
        self.score += self.__digits_score()
        self.score += self.__special_score()
        self.score += self.__letters_only_score()
        self.score += self.__repeating_chars_score()
        self.score += self.__sequential_numbers_score()
        self.score += self.__dictionary_words_score()
    
    def __lenght_score(self):
        return len(self.password) * 4 #The way WA works.
    
    def __lower_upper_case_score(self):
        #This will return the number of upper and lower case characters if at least one of each is available.
        lower_score = 0
        for char in self.password:
            if char in string.lowercase:
                lower_score += 1
        
        upper_score = 0
        for char in self.password:
            if char in string.uppercase:
                upper_score += 1
        
        if lower_score and upper_score:
            return lower_score + upper_score
        else:
            return 0
    
    def __digits_score(self):
        score = 0
        for char in self.password:
            if char in string.digits:
                score += 1
        return score * 4 #The way WA works.
    
    def __special_score(self):
        score = 0
        for char in self.password:
            if char in string.punctuation:
                score += 1
        return score * 6 #The way WA works.
    
    def __letters_only_score(self):
        for char in self.password:
            if not str(char).lower() in string.lowercase:
                return 0 #If it contains something else than letters, don't affect the score.
        return -5 #If it only contains letters, decrease the score by 5.
    
    def __numbers_only_score(self):
        for char in self.password:
            if not char in string.digits:
                return 0 #If it contains something else than numbers, don't affect the score.
        return -5 #If it only contains numbers, decrease the score by 5.
    
    def __repeating_chars_score(self):<commit_msg>Configured __letters_only_score and __numbers_only_score to make scores more accurate.<commit_after>"""
paswordstrength module can be used to get a password strength score of a string. It is based on various rules which are similar to those found in Wolfram Alpha.
"""

import string

class passwordstrength:
    def __init__(self, password):
        self.password = password
        #Calculating the score
        self.score = 0
        self.score += self.__lenght_score()
        self.score += self.__lower_upper_case_score()
        self.score += self.__digits_score()
        self.score += self.__special_score()
        self.score += self.__letters_only_score()
        self.score += self.__repeating_chars_score()
        self.score += self.__sequential_numbers_score()
        self.score += self.__dictionary_words_score()
    
    def __lenght_score(self):
        return len(self.password) * 4 #The way WA works.
    
    def __lower_upper_case_score(self):
        #This will return the number of upper and lower case characters if at least one of each is available.
        lower_score = 0
        for char in self.password:
            if char in string.lowercase:
                lower_score += 1
        
        upper_score = 0
        for char in self.password:
            if char in string.uppercase:
                upper_score += 1
        
        if lower_score and upper_score:
            return lower_score + upper_score
        else:
            return 0
    
    def __digits_score(self):
        score = 0
        for char in self.password:
            if char in string.digits:
                score += 1
        return score * 4 #The way WA works.
    
    def __special_score(self):
        score = 0
        for char in self.password:
            if char in string.punctuation:
                score += 1
        return score * 6 #The way WA works.
    
    def __letters_only_score(self):
        for char in self.password:
            if not str(char).lower() in string.lowercase:
                return 0 #If it contains something else than letters, don't affect the score.
        return -len(self.password) #Return the negative form of the password length. The way WA works.
    
    def __numbers_only_score(self):
        for char in self.password:
            if not char in string.digits:
                return 0 #If it contains something else than numbers, don't affect the score.
        return -len(self.password) #Return the negative form of the password length. The way WA works.
    
    def __repeating_chars_score(self):
{'fraction_non_alphanumeric': 0.06690633113640902, 'fraction_numerical': 0.006790493309366886, 'mean_word_length': 2.0314769975786926, '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': '70342', 'n_tokens_mistral': 1384, 'n_tokens_neox': 1317, 'n_words': 491}