<commit_before>import re
import csv
import unicodecsv

from openelex.base.load import BaseLoader
from openelex.models import RawResult
from openelex.lib.text import ocd_type_id, slugify
from .datasource import Datasource

"""
West Virginia elections have CSV results files for elections after 2006. These files contain precinct-level data for each of the state's
counties, and includes all contests in that county. Prior to 2008, county-level results are contained in office-specific PDF files. The CSV versions of those are contained in the
https://github.com/openelections/openelections-data-wv repository.
"""

class LoadResults(object):
    """Entry point for data loading.

    Determines appropriate loader for file and triggers load process.

    """

    def run(self, mapping):
        election_id = mapping['election']
        if any(s in election_id for s in ['2008', '2010', '2011', '2012', '2014']):
            loader = WVLoader()
        else:
            loader = WVLoaderPre2008()
        loader.run(mapping)


class WVBaseLoader(BaseLoader):
    datasource = Datasource()

    target_offices = set([
        'U.S. President',<commit_msg>better election year conditional<commit_after>import re
import csv
import unicodecsv

from openelex.base.load import BaseLoader
from openelex.models import RawResult
from openelex.lib.text import ocd_type_id, slugify
from .datasource import Datasource

"""
West Virginia elections have CSV results files for elections after 2006. These files contain precinct-level data for each of the state's
counties, and includes all contests in that county. Prior to 2008, county-level results are contained in office-specific PDF files. The CSV versions of those are contained in the
https://github.com/openelections/openelections-data-wv repository.
"""

class LoadResults(object):
    """Entry point for data loading.

    Determines appropriate loader for file and triggers load process.

    """

    def run(self, mapping):
        election_id = mapping['election']
        if any(s in election_id for s in ['2000', '2002', '2004', '2006']):
            loader = WVLoaderPre2008()
        else:
            loader = WVLoader()
        loader.run(mapping)


class WVBaseLoader(BaseLoader):
    datasource = Datasource()

    target_offices = set([
        'U.S. President',
{'fraction_non_alphanumeric': 0.08229211546747092, 'fraction_numerical': 0.025850926324859975, 'mean_word_length': 3.6163021868787277, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1840144', 'n_tokens_mistral': 700, 'n_tokens_neox': 616, 'n_words': 243}