Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/harvard-lil/cap-examples

Examples for getting started using https://case.law
https://github.com/harvard-lil/cap-examples

api bulk caselaw court python

Last synced: 20 days ago
JSON representation

Examples for getting started using https://case.law

Awesome Lists containing this project

README

        

# CAP examples

[![CircleCI](https://circleci.com/gh/harvard-lil/cap-examples.svg?style=svg)](https://circleci.com/gh/harvard-lil/cap-examples)

A repository of examples of what can be done with Caselaw Access Project data.
- [CAP Github repo](https://github.com/harvard-lil/capstone)
- [CAP homepage](https://case.law/)

## Table of Contents
- [Introduction](#start-here!)
- [Examples](#more-examples)
- [Contributing instructions](#interested-in-contributing-your-own-examples)
- [Using the API](#using-the-api)
- [Download bulk data](#downloading-bulk-data)
- [Installation Instructions](#install) - install this repo to run examples on your own machine

## Start here!
- [Introduction](introduction/introduction.ipynb)

## More examples
- [Bulk Case Extract](bulk_extract/extract_cases.ipynb) - Get cases from our api's /bulk endpoint. Extract cases into a dataframe.
- [Full Text Search](full_text_search/full_text_search.ipynb) - Get all cases that include a keyword.
- [Full Text Search with Context](api_text_search/api_text_search.py) - Like full text search, only this time using your API key to get the context around the word.
- [Ngrams](ngrams/ngrams.ipynb) – Use the open Arkansas bulk cases to explore interesting words.
- [Bulk Exploration: ngrams and Justice Cartwright](bulk_exploration/cartwright.ipynb) – Use the open Illinois bulk cases to explore interesting words, and look at a Judge's opinion publishing history.
- [Map Courts](map_courts/map_courts.ipynb) - Map all the courts on a U.S. map.
- [Python Wrapper](python_wrapper/cap.py) - Python wrapper for searching cases, downloading to CSV, etc.
- [Get Judges](get_judges/get_judges.ipynb) - Get judges and return [CourtListener Person urls](https://www.courtlistener.com/api/rest/v3/people/?name_last=Pregerson&name_first=Harry)
- [API to CSV](api_to_csv/api_to_csv.py) - Command line Python3 script with no external dependencies, fetching search results from the cases endpoint and writing to a CSV.
- [Labelling case parties and summarizing cases](labelling_summarizing/labelling_summarizing.ipynb) - Using some basic machine learning to label who the parties in each case were, and then summarizing the case text.

## Interested in contributing your own examples?
1. Fork this repository
2. [Install dependencies](#install)
3. Add your work
4. Make sure to add any requirements your project needs to [requirements.in](requirements.in)
5. Run ```pip-compile --output-file requirements.txt requirements.in```
6. Add a link in the [Examples section](#examples)
7. Create a [pull request](https://github.com/harvard-lil/cap-examples/compare)
8. Receive gratitude (thank you so much!!)

## Using the API
[Read our API documentation.](https://case.law/api/)

In order to download [non-whitelisted](https://case.law/api/#limits) cases, you must [register for an API key](https://case.law/user/register/).

Once you have your API key, copy and paste it into your secret keys file [settings.py](config/settings.py).

## Downloading bulk data

#### Helper methods to download whitelisted bulk data
These example require the existence of an API key in settings.py.
Follow the instructions above in the [Using the API](#using-the-api) section to obtain one.

Download the Illinois dataset
```
(capexamples) $ fab get_cases_from_bulk:Illinois
```

Or, download the Arkansas dataset
```
(capexamples) $ fab get_cases_from_bulk:Arkansas
```

Download a dataset with casebody format as xml
```
(capexamples) $ fab get_cases_from_bulk:Illinois,data_format=xml
```

## Install
These examples assume some python knowledge. We will be using `python3`.
This code has been tested using Python `3.9.10`.
We will also be installing all our dependencies and working in a [virtual environment](https://docs.python.org/3/library/venv.html).

```
$ python3 -mvenv venv
$ source venv/bin/activate
$ (venv) pip install -r requirements.txt
```

Set up!
```
(venv) $ pip install -r requirements.txt
(venv) $ fab setup
```

To run jupyter notebook examples (i.e. any file ending in .ipynb):
```
(venv) $ jupyter notebook
```