GithubHelp home page GithubHelp logo

web5design / citation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unitedstates/citation

0.0 3.0 0.0 630 KB

Legal citation extractor, via command line, JavaScript, or HTTP.

License: The Unlicense

citation's Introduction

Citation

A fast, stand-alone legal citation extractor.

Currently supports the US Code, and slip laws. TODO: CFR, US bills, state codes, state bills.

Install

Install Node.js and NPM, then install Citation globally (may require sudo):

npm install -g citation

Or install it locally to a node_modules directory with npm install citation.

Use

Citation can handle blocks of text, large or small, through the command line, HTTP, or directly in JavaScript.

Via the command line:

cite "pursuant to 5 U.S.C. 552(a)(1)(E) and"

Calling from JavaScript directly:

Citation.find("pursuant to 5 U.S.C. 552(a)(1)(E) and")

Or through the included HTTP API:

cite-server
curl "http://localhost:3000/citation/find.json?text=pursuant+to+5+U.S.C.+552%28a%29%281%29%28E%29+and"

All of which yield:

[{
  "match": "5 U.S.C. 552(a)(1)(E)",
  "type": "usc",
  "index": "0",
  "usc": {
    "title": "5",
    "section": "552",
    "subsections": ["a", "1", "E"],
    "id": "5_usc_552_a_1_E",
    "section_id": "5_usc_552"
  }
}]

(The HTTP API actually returns a JavaScript object with a key of results whose value is the above array.)

Excerpts

Passing an excerpt option will include an excerpt in the response, with up to that number of characters on either side of each detected citation.

Citation.find("that term in section 5362(5) of title 31, United States Code.", {excerpt: 10})

Yields:

[{
  "match": "section 5362(5) of title 31",
  "excerpt": "t term in section 5362(5) of title 31, United S",
  ...
}]

Command line

The shell command can accept a string to parse as an argument, through STDIN, or from a file. It can output results to STDOUT, or to a file.

cite "section 5362(5) of title 31"

echo "section 5362(5) of title 31" | cite

cite --input=in-file.txt --output=out-file.json

Options

  • --input: Filename to read text from
  • --output: Filename to output text to
  • --pretty: Prettify (indent) output
  • --types: Limit citation types to a comma-separated list (e.g. "usc,law")

HTTP API

Start the API on a given port (defaults to 3000):

cite-server [port]

GET or POST to /citation/find.json with a text parameter:

curl http://localhost:3000/citation/find.json?text=5+U.S.C.+552%28a%29%281%29%28E%29

curl -XPOST "http://localhost:3000/citation/find.json" -d "text=5 U.S.C. 552(a)(1)(E)"

Will return the results of running Citation.find() on the block of text, under a results key:

{
  "results": [
    {
      "match": "5 U.S.C. 552(a)(1)(E)",
      "type": "usc",
      "index": "0",
      "usc": {
        "title": "5",
        "section": "552",
        "subsections": ["a", "1", "E"],
        "id": "5_usc_552_a_1_E",
        "section_id": "5_usc_552"
      }
    }
  ]
}

Options

  • text: required, text to extract citations from.
  • callback: a function name to use as a JSONP callback.
  • pretty: prettify (indent) output.
  • options[excerpt]: include excerpts with up to this many characters around it.
  • options[types]: limit citation types to a comma-separated list (e.g. "usc,law")

About

Originally written by Eric Mill, at the Sunlight Foundation.

citation's People

Contributors

konklone avatar

Watchers

JT5D avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.