Datasets:
Card: add "Using it from an agent"
Browse filesA five-step pattern for agents (find, read the whole section, check the
version in force, follow references both ways, cite precisely) with
runnable helpers: read_section, versions, in_force and references.
Data files are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- README.md +69 -0
- export_manifest.json +2 -2
README.md
CHANGED
|
@@ -217,6 +217,75 @@ separate, it resolves to the first.
|
|
| 217 |
| `subdivision` | The cited subsection, such as `(a)(3)`, when there is one |
|
| 218 |
| `block_label` | The subsection of the source chunk where the citation appears |
|
| 219 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
## Source and method
|
| 221 |
|
| 222 |
The text was converted from the free public-access Tennessee Code that
|
|
|
|
| 217 |
| `subdivision` | The cited subsection, such as `(a)(3)`, when there is one |
|
| 218 |
| `block_label` | The subsection of the source chunk where the citation appears |
|
| 219 |
|
| 220 |
+
## Using it from an agent
|
| 221 |
+
|
| 222 |
+
The dataset is laid out for an agent that answers questions about Tennessee law
|
| 223 |
+
and has to cite what it used. The pattern:
|
| 224 |
+
|
| 225 |
+
1. **Find candidates.** Index `text` with your embedding model or BM25; the
|
| 226 |
+
chunks are already sized for retrieval. Keep each chunk's `id` with it.
|
| 227 |
+
2. **Read the whole section.** A chunk is part of a section. Before relying on
|
| 228 |
+
one, read every chunk with the same `section_id`, in `chunk_index` order.
|
| 229 |
+
3. **Check which version is the law.** A cite can have several documents. List
|
| 230 |
+
them and use the qualifier to pick the one in force on the date that
|
| 231 |
+
matters. A contingency has no date, so say that instead of choosing.
|
| 232 |
+
4. **Follow the references.** Outbound edges lead to the sections this one relies
|
| 233 |
+
on, such as its definitions; inbound edges show what depends on it. An
|
| 234 |
+
unresolved edge points outside this dataset: report it as not covered, never
|
| 235 |
+
as not existing.
|
| 236 |
+
5. **Cite precisely.** Give `meta.document_title`, the `section_id`, the currency
|
| 237 |
+
line and `source_url`.
|
| 238 |
+
|
| 239 |
+
```python
|
| 240 |
+
import datetime as dt
|
| 241 |
+
from datasets import load_dataset
|
| 242 |
+
|
| 243 |
+
chunks = load_dataset("ChrisScr770/tennessee-code", "chunks", split="train").to_pandas()
|
| 244 |
+
edges = load_dataset("ChrisScr770/tennessee-code", "crossrefs", split="train").to_pandas()
|
| 245 |
+
firsts = chunks[chunks.chunk_index == 1] # one row per document
|
| 246 |
+
|
| 247 |
+
def read_section(section_id):
|
| 248 |
+
"""Every chunk of one document, in order."""
|
| 249 |
+
rows = chunks[chunks.section_id == section_id].sort_values("chunk_index")
|
| 250 |
+
return "\n\n".join(rows.text)
|
| 251 |
+
|
| 252 |
+
def versions(cite):
|
| 253 |
+
"""Each document published under a cite, with what tells them apart."""
|
| 254 |
+
rows = firsts[firsts.cite == cite]
|
| 255 |
+
return [(r.section_id, r.meta["version_qualifier"], r.meta["effective_note"])
|
| 256 |
+
for r in rows.itertuples()]
|
| 257 |
+
|
| 258 |
+
def in_force(section_id, on=None):
|
| 259 |
+
"""True or False where the qualifier decides; None where a person has to."""
|
| 260 |
+
row = firsts[firsts.section_id == section_id].iloc[0]
|
| 261 |
+
qualifier = row.meta["version_qualifier"]
|
| 262 |
+
day = (on or dt.date.today()).isoformat()
|
| 263 |
+
if qualifier.startswith("until-"):
|
| 264 |
+
return day < qualifier.removeprefix("until-")
|
| 265 |
+
if qualifier.startswith("on-"):
|
| 266 |
+
return day >= qualifier.removeprefix("on-")
|
| 267 |
+
if qualifier in ("reserved", "repealed"):
|
| 268 |
+
return False
|
| 269 |
+
if qualifier: # a contingency: the text takes effect on an event, not a date
|
| 270 |
+
return None
|
| 271 |
+
undated = [v for v in versions(row.cite) if not v[1]]
|
| 272 |
+
return True if len(undated) == 1 else None # .vN twins: read both
|
| 273 |
+
|
| 274 |
+
def references(section_id):
|
| 275 |
+
"""Outbound: what this section cites. Inbound: what cites it."""
|
| 276 |
+
ids = chunks.id[chunks.section_id == section_id]
|
| 277 |
+
cite = firsts.cite[firsts.section_id == section_id].iloc[0]
|
| 278 |
+
outbound = edges[edges.source_chunk_id.isin(ids)]
|
| 279 |
+
inbound = edges[(edges.target_cite == cite) & ~edges.source_chunk_id.isin(ids)]
|
| 280 |
+
return outbound, inbound
|
| 281 |
+
|
| 282 |
+
for section_id, qualifier, note in versions("37-3-803"):
|
| 283 |
+
print(section_id, in_force(section_id))
|
| 284 |
+
```
|
| 285 |
+
|
| 286 |
+
The dataset's author serves this same pattern to agents as MCP tools (search,
|
| 287 |
+
read a section, follow its references); the server itself is not published.
|
| 288 |
+
|
| 289 |
## Source and method
|
| 290 |
|
| 291 |
The text was converted from the free public-access Tennessee Code that
|
export_manifest.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
| 2 |
"dataset": "Tennessee Code Unannotated (Titles 29, 34, 36, 37, 39, 40 and 41)",
|
| 3 |
"repo_id": "ChrisScr770/tennessee-code",
|
| 4 |
"license": "cc0-1.0",
|
| 5 |
-
"exported_at": "2026-10-
|
| 6 |
-
"source_commit": "
|
| 7 |
"source_dirty": false,
|
| 8 |
"currency": "Current through the 2026 Regular Session and the 2026 2nd Extraordinary Session.",
|
| 9 |
"code_datestamp": "2026-09-30T15:52:38.000244-00:00",
|
|
|
|
| 2 |
"dataset": "Tennessee Code Unannotated (Titles 29, 34, 36, 37, 39, 40 and 41)",
|
| 3 |
"repo_id": "ChrisScr770/tennessee-code",
|
| 4 |
"license": "cc0-1.0",
|
| 5 |
+
"exported_at": "2026-10-08T06:13:08+00:00",
|
| 6 |
+
"source_commit": "f6076a9578e38add9a002073c0a06c38027859a7",
|
| 7 |
"source_dirty": false,
|
| 8 |
"currency": "Current through the 2026 Regular Session and the 2026 2nd Extraordinary Session.",
|
| 9 |
"code_datestamp": "2026-09-30T15:52:38.000244-00:00",
|