<commit_before>from notifications_utils.countries import UK, Country, CountryNotFoundError
from notifications_utils.countries.data import Postage
from notifications_utils.formatters import (
    normalise_lines,
    remove_whitespace_before_punctuation,
)
from notifications_utils.recipients import (
    is_a_real_uk_postcode,
    first_column_headings,
    format_postcode_for_printing,
)


address_lines_1_to_6_and_postcode = [
    # The API only accepts snake_case placeholders
    line.replace(' ', '_') for line in first_column_headings['letter']
]
address_lines_1_to_6 = address_lines_1_to_6_and_postcode[:-1]
address_line_7 = 'address_line_7'


class PostalAddress():

    MIN_LINES = 3
    MAX_LINES = 7

    def __init__(self, raw_address):
        self.raw_address = raw_address

    def __bool__(self):
        return bool(self.normalised)

    def __repr__(self):
        return f'{self.__class__.__name__}({repr(self.raw_address)})'

    @classmethod
    def from_personalisation(cls, personalisation_dict):
        if address_line_7 in personalisation_dict:
            keys = address_lines_1_to_6 + [address_line_7]
        else:
            keys = address_lines_1_to_6_and_postcode
        return cls('\n'.join(
            personalisation_dict.get(key) or '' for key in keys
        ))

    @property
    def as_personalisation(self):
        lines = dict.fromkeys(address_lines_1_to_6, '')
        lines.update({
            f'address_line_{index}': value
            for index, value in enumerate(self.normalised_lines[:-1], start=1)
            if index < 7
        })
        lines['postcode'] = lines['address_line_7'] = self.normalised_lines[-1]
        return lines

    @property
    def country(self):
        try:
            return Country(self._lines[-1])
        except CountryNotFoundError:
            return Country(UK)

    @property
    def line_count(self):
        return len(self.normalised.splitlines())

    @property
    def has_enough_lines(self):
        return self.line_count >= self.MIN_LINES
<commit_msg>Rename variables for clarity<commit_after>from notifications_utils.countries import UK, Country, CountryNotFoundError
from notifications_utils.countries.data import Postage
from notifications_utils.formatters import (
    normalise_lines,
    remove_whitespace_before_punctuation,
)
from notifications_utils.recipients import (
    is_a_real_uk_postcode,
    first_column_headings,
    format_postcode_for_printing,
)


address_lines_1_to_6_and_postcode_keys = [
    # The API only accepts snake_case placeholders
    line.replace(' ', '_') for line in first_column_headings['letter']
]
address_lines_1_to_6_keys = address_lines_1_to_6_and_postcode_keys[:-1]
address_line_7_key = 'address_line_7'


class PostalAddress():

    MIN_LINES = 3
    MAX_LINES = 7

    def __init__(self, raw_address):
        self.raw_address = raw_address

    def __bool__(self):
        return bool(self.normalised)

    def __repr__(self):
        return f'{self.__class__.__name__}({repr(self.raw_address)})'

    @classmethod
    def from_personalisation(cls, personalisation_dict):
        if address_line_7_key in personalisation_dict:
            keys = address_lines_1_to_6_keys + [address_line_7_key]
        else:
            keys = address_lines_1_to_6_and_postcode_keys
        return cls('\n'.join(
            personalisation_dict.get(key) or '' for key in keys
        ))

    @property
    def as_personalisation(self):
        lines = dict.fromkeys(address_lines_1_to_6_keys, '')
        lines.update({
            f'address_line_{index}': value
            for index, value in enumerate(self.normalised_lines[:-1], start=1)
            if index < 7
        })
        lines['postcode'] = lines['address_line_7'] = self.normalised_lines[-1]
        return lines

    @property
    def country(self):
        try:
            return Country(self._lines[-1])
        except CountryNotFoundError:
            return Country(UK)

    @property
    def line_count(self):
        return len(self.normalised.splitlines())

    @property
    def has_enough_lines(self):
        return self.line_count >= self.MIN_LINES

{'fraction_non_alphanumeric': 0.08603701033405431, 'fraction_numerical': 0.01201634222542658, 'mean_word_length': 3.145418326693227, 'pattern_counts': {'":': 0, '<': 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': '1350981', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1274, 'n_words': 245}