<commit_before>from ..campaign.constants import (TYPE_CONGRESS, TYPE_STATE, TYPE_EXECUTIVE,
    TARGET_EXECUTIVE, TARGET_CHAMBER_BOTH, TARGET_CHAMBER_UPPER, TARGET_CHAMBER_LOWER,
    LOCATION_POSTAL, LOCATION_ADDRESS, LOCATION_DISTRICT, LOCATION_LATLON,
    ORDER_IN_ORDER, ORDER_SHUFFLE, ORDER_UPPER_FIRST, ORDER_LOWER_FIRST)

from ..extensions import cache
from countries.us import USData
from countries.us_state import USStateData
from geocode import Geocoder

# initialize data for all relevant countries
COUNTRY_DATA = {
    'US': USData(cache),
    'USState': USStateData(cache, api_cache='localmem')  # TODO, wrap sunlight cache for flask
}

GEOCODER = Geocoder()


def locate_targets(location, campaign):
    """ Locate targets for location for a given campaign.
    Returns list of target uids """
    if campaign.target_set:
        return [t.uid for t in campaign.target_set]

    if campaign.campaign_type == TYPE_CONGRESS:
        data = COUNTRY_DATA['US']
        if campaign.locate_by == LOCATION_DISTRICT:
            (state, district) = location.split("-")
            district = "0" if district is "AL" else district
<commit_msg>Compare strings by value, not identity<commit_after>from ..campaign.constants import (TYPE_CONGRESS, TYPE_STATE, TYPE_EXECUTIVE,
    TARGET_EXECUTIVE, TARGET_CHAMBER_BOTH, TARGET_CHAMBER_UPPER, TARGET_CHAMBER_LOWER,
    LOCATION_POSTAL, LOCATION_ADDRESS, LOCATION_DISTRICT, LOCATION_LATLON,
    ORDER_IN_ORDER, ORDER_SHUFFLE, ORDER_UPPER_FIRST, ORDER_LOWER_FIRST)

from ..extensions import cache
from countries.us import USData
from countries.us_state import USStateData
from geocode import Geocoder

# initialize data for all relevant countries
COUNTRY_DATA = {
    'US': USData(cache),
    'USState': USStateData(cache, api_cache='localmem')  # TODO, wrap sunlight cache for flask
}

GEOCODER = Geocoder()


def locate_targets(location, campaign):
    """ Locate targets for location for a given campaign.
    Returns list of target uids """
    if campaign.target_set:
        return [t.uid for t in campaign.target_set]

    if campaign.campaign_type == TYPE_CONGRESS:
        data = COUNTRY_DATA['US']
        if campaign.locate_by == LOCATION_DISTRICT:
            (state, district) = location.split("-")
            district = "0" if district == "AL" else district

{'fraction_non_alphanumeric': 0.08322552824493316, 'fraction_numerical': 0.0008624407072013799, 'mean_word_length': 4.296803652968037, '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': '1867350', 'n_tokens_mistral': 765, 'n_tokens_neox': 728, 'n_words': 198}