legal-segmenter
About
What is it? legal-segmenter is a simple library for segmenting legal texts.
How does it work? A bunch of heuristic rules and a manually assembled list of common BlueBook abbreviations. (Yes it's that dumb.)
Can I add to it? Absolutely! If you notice a place where the code can be improved--perhaps by addressing an edge case or adding another common abbreviation--please create a PR in the repository.
Installation
> pip3 install legal-segmenter
Use
from legal_segmenter.segmenter import Segmenter
# Input data
text = """Rule 23 does not set forth a mere pleading standard. A party seeking class certification must affirmatively demonstrate his compliance with the Rule—that is, he must be prepared to prove that there are in fact sufficiently numerous parties, common questions of law or fact, etc. We recognized in Falcon that “sometimes it may be necessary for the court to probe behind the pleadings before coming to rest on the certification question,” 457 U. S., at 160, and that certification is proper only if “the trial court is satisfied, after a rigorous analysis, that the prerequisites of Rule 23(a) have been satisfied,” id., at 161; see id., at 160 (“[A]ctual, not presumed, conformance with Rule 23(a) remains … indispensable”). Frequently that “rigorous analysis” will entail some overlap with the merits of the plaintiff ’s underlying claim. That cannot be helped. “ ‘[T]he class determination generally involves considerations that are enmeshed in the factual and legal issues comprising the plaintiff ’s cause of action.’ ” Falcon, supra, at 160 (quoting Coopers & Lybrand v. Livesay, 437 U. S. 463, 469 (1978); some internal quotation marks omitted). Nor is there anything unusual about that consequence: The necessity of touching aspects of the merits in order to resolve preliminary matters, e.g., jurisdiction and venue, is a familiar feature of litigation. See Szabo v. Bridgeport Machines, Inc., 249 F. 3d 672, 676–677 (CA7 2001) (Easterbrook, J.)."""
# Print out each sentence extracted
seg = Segmenter()
paragraphs = seg.segment(text)
for paragraph in paragraphs:
for sentence in paragraph:
print(sentence.strip())
print()
The output of the above code is:
Rule 23 does not set forth a mere pleading standard.
A party seeking class certification must affirmatively demonstrate his compliance with the Rule—that is, he must be prepared to prove that there are in fact sufficiently numerous parties, common questions of law or fact, etc.
We recognized in Falcon that “sometimes it may be necessary for the court to probe behind the pleadings before coming to rest on the certification question,” 457 U. S., at 160, and that certification is proper only if “the trial court is satisfied, after a rigorous analysis, that the prerequisites of Rule 23(a) have been satisfied,” id., at 161; see id., at 160 (“[A]ctual, not presumed, conformance with Rule 23(a) remains … indispensable”).
Frequently that “rigorous analysis” will entail some overlap with the merits of the plaintiff ’s underlying claim.
That cannot be helped.
“ ‘[T]he class determination generally involves considerations that are enmeshed in the factual and legal issues comprising the plaintiff ’s cause of action.’ ” Falcon, supra, at 160 (quoting Coopers & Lybrand v. Livesay, 437 U. S. 463, 469 (1978); some internal quotation marks omitted).
Nor is there anything unusual about that consequence: The necessity of touching aspects of the merits in order to resolve preliminary matters, e.g., jurisdiction and venue, is a familiar feature of litigation.
See Szabo v. Bridgeport Machines, Inc., 249 F. 3d 672, 676–677 (CA7 2001) (Easterbrook, J.).
which is not terrible!
Contact
If you have a question or any other issue, please reach out to Neel Guha (nguha@cs.stanford.edu).
Metadata
Release files for legal-segmenter 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| legal-segmenter-0.1.2.tar.gz | 8.9 kB | Without provenance | Details for legal-segmenter-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| legal_segmenter-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for legal_segmenter-0.1.2-py3-none-any.whl |
Total release size: 18.4 kB
Release files / legal-segmenter-0.1.2.tar.gz
| Download URL | legal-segmenter-0.1.2.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dffc8eb6d7194c72955c343b28245cc80102bece175a58f2388b956f34eb26d1
|
|
BLAKE2b-256 checksum How to use checksums |
e239c4b0c9b635bf16477b4c903489e7e58bb4d4676c098e0a09551e53b9490c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.9.5 Darwin/19.6.0
|
Release files / legal_segmenter-0.1.2-py3-none-any.whl
| Download URL | legal_segmenter-0.1.2-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c92368b4fe7ffe1c11a312bb3c4dab099d875444a0e0c19b5a0ea7e65fbfb343
|
|
BLAKE2b-256 checksum How to use checksums |
fb79b57e431ddf7134e3be45fcb2326625172e1b05628e11d69956ba2a5eb660
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.9.5 Darwin/19.6.0
|
Security for legal-segmenter 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.