def feed(self, character: str) -> None: if character.isalpha(): self._buffer = "".join([self._buffer, character]) if is_accentuated(character): self._buffer_accent_count += 1 return if not self._buffer: return if (character.isspace() or is_punctuation(character) or is_separator(character)) and self._buffer: self._word_count += 1 buffer_length = len(self._buffer) # type: int self._character_count += buffer_length if buffer_length >= 4 and self._buffer_accent_count / buffer_length >= 0.3: self._is_current_word_bad = True if self._is_current_word_bad: self._bad_word_count += 1 self._bad_character_count += len(self._buffer) self._is_current_word_bad = False self._buffer = "" self._buffer_accent_count = 0 elif character not in { "<", ">", "-", "=" } and character.isdigit() is False and is_symbol(character): self._is_current_word_bad = True self._buffer += character
def feed(self, character: str) -> None: if is_separator(character): if self._character_count_since_last_sep < 24: self._successive_upper_lower_count_final += self._successive_upper_lower_count self._successive_upper_lower_count = 0 self._character_count_since_last_sep = 0 if self._last_alpha_seen is not None: if (character.isupper() and self._last_alpha_seen.islower()) or (character.islower() and self._last_alpha_seen.isupper()): if self._buf is True: self._successive_upper_lower_count += 1 else: self._buf = True else: self._buf = False self._character_count += 1 self._last_alpha_seen = character