def parse_regulatory_citations(regulatory_citation, case_id, entity_id): citations = [] if regulatory_citation: matches = list(REGULATION_REGEX.finditer(regulatory_citation)) for index, match in enumerate(matches): part = match.group('part') section = match.group('section') url = create_eregs_link(part, section) if index == len(matches) - 1: match_text = regulatory_citation[match.start():] else: match_text = regulatory_citation[match.start( ):matches[index + 1].start()] text = match_text.rstrip(' ,;') citations.append({ 'text': text, 'type': 'regulation', 'title': '11', 'url': url }) if not citations: logger.warn( "Cannot parse regulatory citation %s for Entity %s in case %s", regulatory_citation, entity_id, case_id) return citations
def get_citations(citation_texts): us_codes = [] regulations = [] for citation_text in citation_texts: us_code_match = re.match( "(?P<title>[0-9]+) U\.S\.C\. (?P<section>[0-9a-z-]+)(?P<paragraphs>.*)", citation_text) regulation_match = re.match( "(?P<title>[0-9]+) C\.F\.R\. (?P<part>[0-9]+)(?:\.(?P<section>[0-9]+))?", citation_text) if us_code_match: title, section = reclassify_statutory_citation.reclassify_archived_mur_statutory_citation( us_code_match.group('title'), us_code_match.group('section')) citation_text = '%s U.S.C. %s%s' % ( title, section, us_code_match.group('paragraphs')) url = 'http://api.fdsys.gov/link?' +\ urlencode([('collection', 'uscode'), ('link-type', 'html'), ('title', title), ('year', 'mostrecent'), ('section', section)]) us_codes.append({"text": citation_text, "url": url}) elif regulation_match: url = utils.create_eregs_link(regulation_match.group('part'), regulation_match.group('section')) regulations.append({"text": citation_text, "url": url}) else: print(citation_text) raise Exception("Could not parse citation") return {"us_code": us_codes, "regulations": regulations}
def get_citations_arch_mur(mur_id): us_codes = [] regulations = [] with db.engine.connect() as conn: rs = conn.execute(MUR_CITES, mur_id) for row in rs: if row["cite"]: us_code_match = re.match( "(?P<title>[0-9]+) U\.S\.C\. (?P<section>[0-9a-z-]+)(?P<paragraphs>.*)", row["cite"]) regulation_match = re.match( "(?P<title>[0-9]+) C\.F\.R\. (?P<part>[0-9]+)(?:\.(?P<section>[0-9]+))?", row["cite"]) if us_code_match: us_code_title, us_code_section = reclassify_statutory_citation( us_code_match.group("title"), us_code_match.group("section")) citation_text = "%s U.S.C. %s%s" % ( us_code_title, us_code_section, us_code_match.group("paragraphs")) url = "https://www.govinfo.gov/link/uscode/{0}/{1}".format( us_code_title, us_code_section) us_codes.append({"text": citation_text, "url": url}) elif regulation_match: url = utils.create_eregs_link( regulation_match.group("part"), regulation_match.group("section")) regulations.append({"text": row["cite"], "url": url}) else: raise Exception("Could not parse archived mur's citation.") return {"us_code": us_codes, "regulations": regulations}
def get_citations(citation_texts): us_codes = [] regulations = [] for citation_text in citation_texts: us_code_match = re.match("(?P<title>[0-9]+) U\.S\.C\. (?P<section>[0-9a-z-]+)(?P<paragraphs>.*)", citation_text) regulation_match = re.match( "(?P<title>[0-9]+) C\.F\.R\. (?P<part>[0-9]+)(?:\.(?P<section>[0-9]+))?", citation_text) if us_code_match: title, section = reclassify_statutory_citation.reclassify_archived_mur_statutory_citation( us_code_match.group('title'), us_code_match.group('section')) citation_text = '%s U.S.C. %s%s' % (title, section, us_code_match.group('paragraphs')) url = 'http://api.fdsys.gov/link?' +\ urlencode([('collection', 'uscode'), ('link-type', 'html'), ('title', title), ('year', 'mostrecent'), ('section', section)]) us_codes.append({"text": citation_text, "url": url}) elif regulation_match: url = utils.create_eregs_link(regulation_match.group('part'), regulation_match.group('section')) regulations.append({"text": citation_text, "url": url}) else: print(citation_text) raise Exception("Could not parse citation") return {"us_code": us_codes, "regulations": regulations}
def parse_regulatory_citations(regulatory_citation, case_id, entity_id): citations = [] if regulatory_citation: for match in REGULATION_REGEX.finditer(regulatory_citation): url = create_eregs_link(match.group('part'), match.group('section')) text = '11 C.F.R. %s' % match.group('part') if match.group('section'): text += '.%s' % match.group('section') citations.append({'text': text, 'url': url}) if not citations: logger.warn( "Cannot parse regulatory citation %s for Entity %s in case %s", regulatory_citation, entity_id, case_id) return citations
def get_citations(citation_texts): us_codes = [] regulations = [] for citation_text in citation_texts: us_code_match = re.match( r"(?P<title>[0-9]+) U\.S\.C\. (?P<section>[0-9a-z-]+)(?P<paragraphs>.*)", citation_text, ) regulation_match = re.match( r"(?P<title>[0-9]+) C\.F\.R\. (?P<part>[0-9]+)(?:\.(?P<section>[0-9]+))?", citation_text, ) if us_code_match: ( title, section, ) = reclassify_statutory_citation.reclassify_statutory_citation( us_code_match.group('title'), us_code_match.group('section') ) citation_text = '%s U.S.C. %s%s' % ( title, section, us_code_match.group('paragraphs'), ) url = 'https://www.govinfo.gov/link/uscode/{0}/{1}'.format(title, section) us_codes.append({"text": citation_text, "url": url}) elif regulation_match: url = utils.create_eregs_link( regulation_match.group('part'), regulation_match.group('section') ) regulations.append({"text": citation_text, "url": url}) else: print(citation_text) raise Exception("Could not parse citation") return {"us_code": us_codes, "regulations": regulations}