<commit_before>from lxml import etree
import requests

from regparser.notice.diff import parse_amdpar, find_section
from regparser.notice.address import fetch_addresses
from regparser.notice.sxs import find_section_by_section
from regparser.notice.sxs import build_section_by_section
from regparser.notice.util import spaces_then_remove, swap_emphasis_tags
from regparser.notice import changes
from regparser.tree.xml_parser import reg_text
from regparser.tree import struct


def build_notice(cfr_title, cfr_part, fr_notice, do_process_xml=True):
    """Given JSON from the federal register, create our notice structure"""
    notice = {'cfr_title': cfr_title, 'cfr_part': cfr_part}
    #   Copy over most fields
    for field in ['abstract', 'action', 'agency_names', 'comments_close_on',
                  'document_number', 'publication_date',
                  'regulation_id_numbers']:
        if fr_notice[field]:
            notice[field] = fr_notice[field]

    if fr_notice['effective_on']:
        notice['effective_on'] = fr_notice['effective_on']
        notice['initial_effective_on'] = fr_notice['effective_on']

    if fr_notice['html_url']:
        notice['fr_url'] = fr_notice['html_url']

    if fr_notice['citation']:
        notice['fr_citation'] = fr_notice['citation']

    notice['fr_volume'] = fr_notice['volume']
    notice['meta'] = {}
    for key in ('dates', 'end_page', 'start_page', 'type'):
        notice['meta'][key] = fr_notice[key]

    if fr_notice['full_text_xml_url'] and do_process_xml:
        notice_str = requests.get(fr_notice['full_text_xml_url']).content
        notice_xml = etree.fromstring(notice_str)
        process_xml(notice, notice_xml)

    return notice


def process_designate_subpart(al):
    _, p_list, destination = al
    if 'Subpart' in destination:
        reg_part, sub_part = destination.split('-')
        _, subpart_letter = destination.split(':')<commit_msg>Rename parameter to something more useful<commit_after>from lxml import etree
import requests

from regparser.notice.diff import parse_amdpar, find_section
from regparser.notice.address import fetch_addresses
from regparser.notice.sxs import find_section_by_section
from regparser.notice.sxs import build_section_by_section
from regparser.notice.util import spaces_then_remove, swap_emphasis_tags
from regparser.notice import changes
from regparser.tree.xml_parser import reg_text
from regparser.tree import struct


def build_notice(cfr_title, cfr_part, fr_notice, do_process_xml=True):
    """Given JSON from the federal register, create our notice structure"""
    notice = {'cfr_title': cfr_title, 'cfr_part': cfr_part}
    #   Copy over most fields
    for field in ['abstract', 'action', 'agency_names', 'comments_close_on',
                  'document_number', 'publication_date',
                  'regulation_id_numbers']:
        if fr_notice[field]:
            notice[field] = fr_notice[field]

    if fr_notice['effective_on']:
        notice['effective_on'] = fr_notice['effective_on']
        notice['initial_effective_on'] = fr_notice['effective_on']

    if fr_notice['html_url']:
        notice['fr_url'] = fr_notice['html_url']

    if fr_notice['citation']:
        notice['fr_citation'] = fr_notice['citation']

    notice['fr_volume'] = fr_notice['volume']
    notice['meta'] = {}
    for key in ('dates', 'end_page', 'start_page', 'type'):
        notice['meta'][key] = fr_notice[key]

    if fr_notice['full_text_xml_url'] and do_process_xml:
        notice_str = requests.get(fr_notice['full_text_xml_url']).content
        notice_xml = etree.fromstring(notice_str)
        process_xml(notice, notice_xml)

    return notice


def process_designate_subpart(subpart_designate):
    """ Process the designate amendment if it adds a subpart. """

    _, p_list, destination = subpart_designate
    if 'Subpart' in destination:
        reg_part, sub_part = destination.split('-')
        _, subpart_letter = destination.split(':')
{'fraction_non_alphanumeric': 0.10787025396027156, 'fraction_numerical': 0.0, 'mean_word_length': 4.186440677966102, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 18}, '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': '6507490', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1193, 'n_words': 273}