<commit_before># Author: <NAME>
# Date created:2013-08-18

from datetime import datetime
from lxml import html

from juriscraper.OpinionSite import OpinionSite


class Site(OpinionSite):
    def __init__(self):
        super(Site, self).__init__()
        self.court_id = self.__module__
        self.url = 'http://www.state.il.us/court/Opinions/recent_appellate.asp'

    def _get_download_urls(self):
        path = '//table[@class="content"]//table//tr[not(name(..)="thead") and descendant::a]/td[5]//a/@href'
        return list(self.html.xpath(path))

    def _get_case_names(self):
        case_names = []
        for e in self.html.xpath('//table[@class="content"]//table//tr[not(name(..)="thead") and descendant::a]'
                                 '/td[5]//a[normalize-space(text())]'):
            s = html.tostring(e, method='text', encoding='unicode')
            case_names.append(s)
        return case_names

    def _get_case_dates(self):
        path = '//table[@class="content"]//table//tr[not(name(..)="thead") and descendant::a]/td[1]/div/text()'
        return [datetime.strptime(date_string, '%m/%d/%y').date()
                for date_string in self.html.xpath(path)]

    def _get_precedential_statuses(self):
        statuses = []
        for e in self.html.xpath('//table[@class="content"]//table//tr[not(name(..)="thead") and descendant::a]/td[3]//strong[normalize-space(text())]'):
            s = html.tostring(e, method='text', encoding='unicode')
            if 'Rel' in s:
                statuses.append('Unpublished')
            else:
                statuses.append('Published')
        return statuses

    def _get_docket_numbers(self):
        docket_numbers = []
        for e in self.html.xpath('//table[@class="content"]//table//tr[not(name(..)="thead") and descendant::a]/td[3]'):
            s = html.tostring(e, method='text', encoding='unicode')
            s = ' '.join(s.split())
            s = s.replace("Official Reports", "")
            s = s.replace("NRel", "")
            docket_numbers.append(s)
        return docket_numbers

    def _get_neutral_citations(self):
        neutral_citations = []
        for e in self.html.xpath('//table[@class="content"]//table//tr[not(name(..)="thead") and descendant::a]/td[4]'):
            s = html.tostring(e, method='text', encoding='unicode')
            neutral_citations.append(s)
        return neutral_citations

<commit_msg>When you make HTML by hand, you inevitably make crap HTML by hand.<commit_after># Author: <NAME>
# 2013-08-18: Created.
# 2014-07-17: Updated by mlr to remedy InsanityException.

from datetime import datetime
from lxml import html

from juriscraper.OpinionSite import OpinionSite


class Site(OpinionSite):
    def __init__(self):
        super(Site, self).__init__()
        self.court_id = self.__module__
        self.url = 'http://www.state.il.us/court/Opinions/recent_appellate.asp'
        self.base_path = '//table[@class="content"]//table//tr[not(name(..)="thead") and descendant::a][count(td) = 5]'

    def _get_download_urls(self):
        path = self.base_path + '/td[5]//a/@href'
        return list(self.html.xpath(path))

    def _get_case_names(self):
        case_names = []
        for e in self.html.xpath(self.base_path + '/td[5]//a[normalize-space(text())]'):
            s = html.tostring(e, method='text', encoding='unicode')
            case_names.append(s)
        return case_names

    def _get_case_dates(self):
        path = self.base_path + '/td[1]/div/text()'
        return [datetime.strptime(date_string, '%m/%d/%y').date()
                for date_string in self.html.xpath(path)]

    def _get_precedential_statuses(self):
        statuses = []
        for e in self.html.xpath(self.base_path + '/td[3]//strong[normalize-space(text())]'):
            s = html.tostring(e, method='text', encoding='unicode')
            if 'Rel' in s:
                statuses.append('Unpublished')
            else:
                statuses.append('Published')
        return statuses

    def _get_docket_numbers(self):
        docket_numbers = []
        for e in self.html.xpath(self.base_path + '/td[3]'):
            s = html.tostring(e, method='text', encoding='unicode')
            s = ' '.join(s.split())
            s = s.replace("Official Reports", "")
            s = s.replace("NRel", "")
            docket_numbers.append(s)
        return docket_numbers

    def _get_neutral_citations(self):
        neutral_citations = []
        for e in self.html.xpath(self.base_path + '/td[4]'):
            s = html.tostring(e, method='text', encoding='unicode')
            neutral_citations.append(s)
        return neutral_citations


{'fraction_non_alphanumeric': 0.1603411513859275, 'fraction_numerical': 0.00788912579957356, 'mean_word_length': 2.543051359516616, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 1, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '659961', 'n_tokens_mistral': 1579, 'n_tokens_neox': 1479, 'n_words': 269}