Skip to content

Commit

Permalink
update docs to use load_decision_as_reading
Browse files Browse the repository at this point in the history
  • Loading branch information
mscarey committed Aug 10, 2021
1 parent 6c1bbf5 commit 118156e
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 102 deletions.
27 changes: 12 additions & 15 deletions docs/guides/create_holding_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,34 @@ mockups that supply only the testing data for these examples.
>>> USE_REAL_CASE_API = False
>>> USE_REAL_LEGISLICE_API = False

Next, we can download the judicial decisions we’re going to compare.
Next, we can download the judicial decisions we’re going to compare
and convert the JSON responses from the API
into :class:`authorityspoke.decisions.DecisionReading` objects.

>>> import os
>>> from dotenv import load_dotenv
>>> from authorityspoke.io.loaders import load_decision
>>> from authorityspoke import Decision, DecisionReading
>>> from authorityspoke.io.loaders import load_decision_as_reading
>>> from authorityspoke.io.downloads import CAPClient
>>> load_dotenv()
True
>>> if USE_REAL_CASE_API:
... CAP_API_KEY = os.getenv('CAP_API_KEY')
... client = CAPClient(api_token=CAP_API_KEY)
... oracle_download = client.read_cite(
... oracle_decision = client.read_cite(
... cite="750 F.3d 1339",
... full_case=True)
... lotus_download = client.read_cite(
... lotus_decision = client.read_cite(
... cite="49 F.3d 807",
... full_case=True)
... oracle = DecisionReading(oracle_decision)
... lotus = DecisionReading(lotus_decision)
... else:
... oracle_download = load_decision("oracle_h.json")
... lotus_download = load_decision("lotus_h.json")
... oracle = load_decision_as_reading("oracle_h.json")
... lotus = load_decision_as_reading("lotus_h.json")

Then we convert the JSON responses from the API
into :class:`authorityspoke.decisions.DecisionReading` objects.

>>> from authorityspoke import Decision, DecisionReading
>>> oracle_decision = Decision(**oracle_download)
>>> lotus_decision = Decision(**lotus_download)
>>> oracle = DecisionReading(decision=oracle_decision)
>>> lotus = DecisionReading(decision=lotus_decision)

And we need a :class:`~legislice.download.Client` for
And we need a download :class:`~legislice.download.Client` for
accessing legislative provisions.

>>> import json
Expand Down
44 changes: 23 additions & 21 deletions notebooks/introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@
"outputs": [],
"source": [
"from authorityspoke.io.loaders import load_decision\n",
"from authorityspoke.io.readers import read_decision\n",
"from authorityspoke import Decision\n",
"\n",
"if not USE_REAL_CASE_API:\n",
"\n",
" oracle_case = read_decision(load_decision(\"oracle_h.json\"))\n",
" lotus_case = read_decision(load_decision(\"lotus_h.json\"))"
" oracle_case = Decision(**load_decision(\"oracle_h.json\"))\n",
" lotus_case = Decision(**load_decision(\"lotus_h.json\"))"
]
},
{
Expand Down Expand Up @@ -389,31 +389,31 @@
{
"data": {
"text/plain": [
"{'outputs': [{'absent': False,\n",
" 'name': '',\n",
"{'despite': [],\n",
" 'inputs': [{'absent': False,\n",
" 'generic': False,\n",
" 'terms': [{'name': 'the Java API',\n",
" 'generic': True,\n",
" 'predicate': {'expression': None,\n",
" 'truth': False,\n",
" 'content': '${the_java_api} was an original work'},\n",
" 'name': '',\n",
" 'terms': [{'generic': True,\n",
" 'name': 'the Java API',\n",
" 'plural': False,\n",
" 'type': 'Entity'}],\n",
" 'predicate': {'content': '${the_java_api} was copyrightable',\n",
" 'expression': None,\n",
" 'truth': False},\n",
" 'standard_of_proof': None,\n",
" 'type': 'Fact'}],\n",
" 'inputs': [{'absent': False,\n",
" 'name': '',\n",
" 'outputs': [{'absent': False,\n",
" 'generic': False,\n",
" 'terms': [{'name': 'the Java API',\n",
" 'generic': True,\n",
" 'predicate': {'expression': None,\n",
" 'truth': False,\n",
" 'content': '${the_java_api} was copyrightable'},\n",
" 'name': '',\n",
" 'terms': [{'generic': True,\n",
" 'name': 'the Java API',\n",
" 'plural': False,\n",
" 'type': 'Entity'}],\n",
" 'predicate': {'content': '${the_java_api} was an original work',\n",
" 'expression': None,\n",
" 'truth': False},\n",
" 'standard_of_proof': None,\n",
" 'type': 'Fact'}],\n",
" 'despite': []}"
" 'type': 'Fact'}]}"
]
},
"execution_count": 14,
Expand Down Expand Up @@ -1174,13 +1174,15 @@
"metadata": {},
"outputs": [],
"source": [
"from authorityspoke.io.loaders import load_decision_as_reading\n",
"\n",
"if USE_REAL_CASE_API:\n",
" feist_case = case_client.read_cite('499 U.S. 340')\n",
" feist = DecisionReading(decision=feist_case)\n",
"\n",
"else:\n",
" feist_case = read_decision(load_decision(\"feist_h.json\"))\n",
" feist = load_decision_as_reading(\"feist_h.json\")\n",
"\n",
"feist = DecisionReading(decision=feist_case)\n",
"feist.posit(read_anchored_holdings_from_file(\"holding_feist.json\", client=legis_client))\n"
]
},
Expand Down
18 changes: 14 additions & 4 deletions notebooks/load_yaml_holdings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -700,7 +700,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now that we generated this `AnchoredHoldings` object containing the data from the YAML file, we can use the `posit` method to link those Holdings to the judicial Decision we created from the data we downloaded from the CAP API. Then we can verify that those two Holdings are now considered the two `holdings` of the Decision."
"## Linking Holdings to the Decision"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now that we generated this `AnchoredHoldings` object containing the data from the YAML file, we can link the Holdings to the Decision with a DecisionReading object. While a Decision is a record of what a court actually published, a DecisionReading represents the user's \"reading\" of the Decision. The DecisionReading indicates what Holdings are supported by the Decision, as well as what text passages support each Holding. We'll use the `DecisionReading.posit()` method to link the Holdings to the Decision. Then we can verify that those two Holdings are now considered the two `holdings` of the Decision."
]
},
{
Expand All @@ -720,8 +727,11 @@
}
],
"source": [
"licensing_case.posit(both_holdings_with_anchors)\n",
"len(licensing_case.holdings)"
"from authorityspoke import DecisionReading\n",
"\n",
"licensing_case_reading = DecisionReading(decision=licensing_case)\n",
"licensing_case_reading.posit(both_holdings_with_anchors)\n",
"len(licensing_case_reading.holdings)"
]
}
],
Expand Down
38 changes: 21 additions & 17 deletions notebooks/statute_rules.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,8 @@
" millimeter\n",
" the fact that <the suspected beard> existed in an uninterrupted line\n",
" from the front of one ear to the front of the other ear below the nose\n",
" GIVEN the ENACTMENTS:\n",
" \"In this Act, beard means any facial hair no shorter than 5 millimetres in length that:…exists in an uninterrupted line from the front of one ear to the front of the other ear below the nose.\" (/test/acts/47/4 1935-04-01)\n",
" \"exists in an uninterrupted line from the front of one ear to the front of the other ear below the nose.\" (/test/acts/47/4/b 1935-04-01)\n"
" GIVEN the ENACTMENT:\n",
" \"In this Act, beard means any facial hair no shorter than 5 millimetres in length that:…exists in an uninterrupted line from the front of one ear to the front of the other ear below the nose.\" (/test/acts/47/4 1935-04-01)\n"
]
}
],
Expand Down Expand Up @@ -256,9 +255,8 @@
" the fact that <the suspected beard> was facial hair\n",
" the fact that <the suspected beard> existed in an uninterrupted line\n",
" from the front of one ear to the front of the other ear below the nose\n",
" GIVEN the ENACTMENTS:\n",
" \"In this Act, beard means any facial hair no shorter than 5 millimetres in length that:…exists in an uninterrupted line from the front of one ear to the front of the other ear below the nose.\" (/test/acts/47/4 1935-04-01)\n",
" \"exists in an uninterrupted line from the front of one ear to the front of the other ear below the nose.\" (/test/acts/47/4/b 1935-04-01)\n"
" GIVEN the ENACTMENT:\n",
" \"In this Act, beard means any facial hair no shorter than 5 millimetres in length that:…exists in an uninterrupted line from the front of one ear to the front of the other ear below the nose.\" (/test/acts/47/4 1935-04-01)\n"
]
}
],
Expand Down Expand Up @@ -416,8 +414,8 @@
" the fact it was false that <the counterparty> was <the Department of\n",
" Beards>\n",
" GIVEN the ENACTMENTS:\n",
" \"It shall be no defense to a charge under section 7A that the purchase, sale, lease, gift, transfer or receipt was of counterfeit beardcoin rather than genuine beardcoin.\" (/test/acts/47/7B/2 1935-04-01)\n",
" \"It shall be an offence to buy, sell, lend, lease, gift, transfer or receive in any way a beardcoin from any person or body other than the Department of Beards, except as provided in Part 4.\" (/test/acts/47/7A 1935-04-01)\n"
" \"It shall be an offence to buy, sell, lend, lease, gift, transfer or receive in any way a beardcoin from any person or body other than the Department of Beards, except as provided in Part 4.\" (/test/acts/47/7A 1935-04-01)\n",
" \"It shall be no defense to a charge under section 7A that the purchase, sale, lease, gift, transfer or receipt was of counterfeit beardcoin rather than genuine beardcoin.\" (/test/acts/47/7B/2 1935-04-01)\n"
]
}
],
Expand Down Expand Up @@ -449,22 +447,28 @@
"text": [
"the Rule that the court MUST ALWAYS impose the\n",
" RESULT:\n",
" the fact that <the beardcoin transaction> was a transfer of beardcoin\n",
" between <the defendant> and <the counterparty>\n",
" the fact that <the defendant> committed the offense of improper\n",
" transfer of beardcoin\n",
" the fact that <the beardcoin transaction> was a transfer of beardcoin\n",
" between <the defendant> and <the counterparty>\n",
" GIVEN:\n",
" the fact it was false that <the counterparty> was <the Department of\n",
" Beards>\n",
" absence of the fact that <the beardcoin transaction> was a licensed\n",
" beardcoin repurchase\n",
" the fact that <the beardcoin transaction> was <the defendant>'s loan\n",
" of the token attributed to <the Department of Beards>, asserting the\n",
" fact that <the Department of Beards> granted an exemption from the\n",
" prohibition of wearing beards, to <the counterparty>\n",
" absence of the fact that <the beardcoin transaction> was a licensed\n",
" beardcoin repurchase\n",
" the fact it was false that <the counterparty> was <the Department of\n",
" Beards>\n",
" DESPITE:\n",
" the fact that the token attributed to <the Department of Beards>,\n",
" asserting the fact that <the Department of Beards> granted an\n",
" exemption from the prohibition of wearing beards, was counterfeit\n",
" GIVEN the ENACTMENTS:\n",
" \"It shall be an offence to buy, sell, lend, lease, gift, transfer or receive in any way a beardcoin from any person or body other than the Department of Beards, except as provided in Part 4.\" (/test/acts/47/7A 1935-04-01)\n",
" \"It shall be no defense to a charge under section 7A that the purchase, sale, lease, gift, transfer or receipt was of counterfeit beardcoin rather than genuine beardcoin.\" (/test/acts/47/7B/2 1935-04-01)\n",
" \"It shall be an offence to buy, sell, lend, lease, gift, transfer or receive in any way a beardcoin from any person or body other than the Department of Beards, except as provided in Part 4.\" (/test/acts/47/7A 1935-04-01)\n"
" DESPITE the ENACTMENT:\n",
" \"The Department of Beards may issue licenses to such barbers, hairdressers, or other male grooming professionals as they see fit to purchase a beardcoin from a customer whose beard they have removed, and to resell those beardcoins to the Department of Beards.\" (/test/acts/47/11 2013-07-18)\n"
]
}
],
Expand Down Expand Up @@ -548,9 +552,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.0"
"version": "3.9.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
}

0 comments on commit 118156e

Please sign in to comment.