<commit_before>"""
Functions to check postcode variable in Pandas dataframe
========================================================

These functions take a dataframe containing postcode information and attempts
to correct errors and extract outward (first half), inward (second half) and
postcode area (first letters) components of the postcode.

"""

# Import required packages
# ========================


import re
import math

import pkg_resources


try:
    pkg_resources.get_distribution('numpy')
except pkg_resources.DistributionNotFound:
    numpyPresent = False
    print("Error: Numpy package not available.")
else:
    numpyPresent = True
    import numpy as np


try:
    pkg_resources.get_distribution('pandas')
except pkg_resources.DistributionNotFound:
    pandasPresent = False
    print("Error: Pandas package not available.")
else:
    pandasPresent = True
    import pandas as pd

    
try:
    pkg_resources.get_distribution('epydemiology')
except pkg_resources.DistrbutionNotFound:
    epydemiologyPresent = False
    print("Error: Epydemiology package not available.")
else:
    epydemiologyPresent = True
    import epydemiology as epy

    
try:
    pkg_resources.get_distribution('pyxdameraulevenshtein')
except pkg_resources.DistrbutionNotFound:
    pyxdameraulevenshteinPresent = False
    print("Error: pyxdameraulevenshtein package not available.")
else:
    pyxdameraulevenshteinPresent = True
    import pyxdameraulevenshtein as pyxdl


<commit_msg>Update phjCleanUKPostcodes.py<commit_after>"""
Functions to check postcode variable in Pandas dataframe
========================================================

These functions take a dataframe containing postcode information and attempts
to correct errors and extract outward (first half), inward (second half) and
postcode area (first letters) components of the postcode.

"""

# Import required packages
# ========================


import re
import math

import pkg_resources


try:
    pkg_resources.get_distribution('numpy')
except pkg_resources.DistributionNotFound:
    numpyPresent = False
    print("Error: Numpy package not available.")
else:
    numpyPresent = True
    import numpy as np


try:
    pkg_resources.get_distribution('pandas')
except pkg_resources.DistributionNotFound:
    pandasPresent = False
    print("Error: Pandas package not available.")
else:
    pandasPresent = True
    import pandas as pd

    
try:
    pkg_resources.get_distribution('epydemiology')
except pkg_resources.DistrbutionNotFound:
    epydemiologyPresent = False
    print("Error: Epydemiology package not available.")
else:
    epydemiologyPresent = True
    import epydemiology as epy

    
# Checking that pyxdameraulevenshtein package is installed does not work using the
# above method because attribute .DistributionNotFound is not present.
try:
    import pyxdameraulevenshtein'
except ImportError:
    print("Error: pyxdameraulevenshtein package not installed. Some features may not be available.")



{'fraction_non_alphanumeric': 0.11099966566365764, 'fraction_numerical': 0.0, 'mean_word_length': 4.87819253438114, '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': '505536', 'n_tokens_mistral': 848, 'n_tokens_neox': 781, 'n_words': 258}