duckduckgo/zeroclickinfo-fathead — pull request #83 by elebow (2014-06-15 22:32:16+00:00)
Title: Add USLaw module.

# Fathead Pull Request

**What does your instant answer do?**
Returns the heading and context of a section of the US Code. For example, the query ``20 USC 76d`` returns the following

Title 20— EDUCATION
CHAPTER 3— SMITHSONIAN INSTITUTION, NATIONAL MUSEUMS AND ART GALLERIES
SUBCHAPTER IV— SMITHSONIAN GALLERY OF ART
§ 76d. Donations of works of art from Government agencies
link to full text

The full text of the law is not included in the answer, as it can vary greatly in length.

**What problem does your instant answer solve (Why is it better than organic links)?**
This IA provides information about legal citations. Since many citations to the USC include only title and section, it can be immensely helpful to know the heading of the section and chapter. Organic links rarely provide the full context at a glance—the user has to navigate to the link to find this basic information.

**What is the data source for your instant answer? (Provide a link if possible)**
http://uscode.house.gov/download/download.shtml

**Why did you choose this data source?**
The House of Representatives is the custodian of the document.

**Are there any other alternative (better) data sources?**
There are alternatives, but they are not likely to be better than the original source. All of the alternatives I examined appear to be generated from this source, anyway.

**What are some example queries that trigger this instant answer?**
``20 USC 76d``, ``20 US Code § 76d``, ``us code title 20 section 76d``

**Which communities will this instant answer be especially useful for? (gamers, book lovers, etc)**
Legal practitioners and scholars

**Is this instant answer connected to a DuckDuckHack [instant answer idea](https://duck.co/ideas)?**
https://duck.co/ideas/idea/355/law-lookup-by-code-citation
https://duck.co/ideas/idea/617/federal-statute-lookup

**Which existing instant answers will this one supercede/overlap with?**
None known.

**Are you having any problems? Do you need our help with anything?**
I am not entirely sure what to do about some of the fields in ``/lib/DDG/Fathead/USlaw.pm``. Is there a list somewhere of all available topics and categories, or is entirely freeform?

The output file contains some duplicate information. For example, every section in a given chapter contains the heading of the chapter. I figured it was worth the loss of 2 or 3 megabytes for the convenience of this denormalized structure.

Some of the section numbers are ranges (eg Title 15, Section "79 to 79z–6"). All of the sections in the range have the same content. This can be handled by generating the interior of the range, or simply using string > or < during lookup.

The output contains generated links to www.law.cornell.edu. I chose that site because it is more user-friendly than the gpo.gov one, and it has a much more convenient URL interface: The text of any section can be reached by navigating to www.law.cornell.edu/uscode/text/$title/$section. The government site uses a more cumbersome scheme.