Overview
Overall strategy
Like citation-reports, there is a problem involving inconsistent use of values citations. We address it the same way by dissecting the component parts and generating a uniform citation.
The component parts of a Supreme Court decision citation:
flowchart TB
cite(citation)---docket
cite---report
docket---d1(docket category)
docket---d2(docket serial)
docket---d3(docket date)
report---r1(phil)
report---r2(scra)
report---r3(offg)
Sample citation, typically found in the body and the footnotes section of a decision:
Bagong Alyansang Makabayan v. Zamora, G.R. Nos. 138570, 138572, 138587, 138680, 138698, October 10, 2000, 342 SCRA 449
Dissecting the above yields
case title | docket category | docket serial | docket date | report phil | report scra | report offg |
---|---|---|---|---|---|---|
Bagong Alyansang... | gr |
138570 | 2000-10-10 | - | 342 SCRA 449 | - |
Citation
The Report
Model from citation-report is only one part of a Philippine Supreme Court citation. This library will handle the patterns involved with respect to the Docket, for the purpose of creating a Citation.
Bases: BaseModel
A Philippine Supreme Court Citation
consists of:
Docket
includes:- category,
- serial number, and
- date.
Report
- as defined in citation-report - includes:- volume number,
- identifying acronym of the reporter/publisher,
- page of the reported volume.
It is typical to see a Docket
combined with a Report
:
Bagong Alyansang Makabayan v. Zamora, G.R. Nos. 138570, 138572, 138587, 138680, 138698, October 10, 2000, 342 SCRA 449
Taken together (and using Bagong Alyansang Makabayan as an example) the text above can be extracted into fields:
Example | Field | Type | Description |
---|---|---|---|
GR | docket_category |
optional (ShortDocketCategory ) |
See shorthand |
138570 | docket_serial |
optional (str) | See serialized identifier |
datetime.date(2000, 10, 10) | docket_date |
optional (date) | When docket serial issued |
GR 138570, Oct. 10, 2000 | docket |
optional (str) | Combined docket_category docket_serial docket_date |
None | phil |
optional (str) | combined volume Phil. page |
342 SCRA 449 | scra |
optional (str) | combined volume SCRA page |
None | offg |
optional (str) | combined volume O.G. page |
Source code in src/citation_utils/citation.py
Python | |
---|---|
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
|
Attributes
display_date
cached
property
This is the same as Docket@formatted_date.
Functions
__eq__(other)
Helps seen
variable in CountedCitation
: either the docket bits match
or any of the report fields match.
Source code in src/citation_utils/citation.py
extract_citation(text)
classmethod
Thin wrapper over cls.extract_citations()
.
Examples:
>>> Citation.extract_citation('Hello World') is None
True
>>> next(Citation.extract_citations('12 Phil. 24'))
<Citation: 12 Phil. 24>
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
Text to evaluate |
required |
Returns:
Type | Description |
---|---|
Self | None
|
Self | None: First item found from |
Source code in src/citation_utils/citation.py
extract_citations(text)
classmethod
Find citations and parse resulting strings to determine whether they are:
Docket
+Report
objects (in which case,_set_docket_report()
will be used); orReport
objects (in which case_set_report()
will be used)
Then processing each object so that they can be structured in a uniform format.
Examples:
>>> text = "<em>Gatchalian Promotions Talent Pool, Inc. v. Atty. Naldoza</em>, 374 Phil. 1, 10-11 (1999), citing: <em>In re Almacen</em>, 31 SCRA 562, 600 (1970).; People v. Umayam, G.R. No. 147033, April 30, 2003; <i>Bagong Alyansang Makabayan v. Zamora,</i> G.R. Nos. 138570, 138572, 138587, 138680, 138698, October 10, 2000, 342 SCRA 449; Villegas <em>v.</em> Subido, G.R. No. 31711, Sept. 30, 1971, 41 SCRA 190;"
>>> len(list(Citation.extract_citations(text)))
5
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
Text to evaluate |
required |
Yields:
Type | Description |
---|---|
Self
|
Iterator[Self]: Itemized citations pre-processed via |
Source code in src/citation_utils/citation.py
get_docket_slug_from_text(v)
classmethod
Given a docket string, format the string into a slug that has the same signature as a database primary key.
Examples:
>>> text = "GR 138570, Oct. 10, 2000"
>>> Citation.get_docket_slug_from_text(text)
'gr-138570-2000-10-10'
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v |
str
|
The text to evaluate |
required |
Returns:
Type | Description |
---|---|
str | None
|
str | None: The slug to use, if possible. |
Source code in src/citation_utils/citation.py
get_report(raw=None)
classmethod
Get a lower cased volpubpage of publisher
from the data
. Assumes
that the publisher key is either phil
, scra
or offg
.
Examples:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
publisher |
str
|
description |
required |
data |
dict
|
description |
required |
Returns:
Type | Description |
---|---|
str | None
|
str | None: description |
Source code in src/citation_utils/citation.py
make_citation_string(cat, num, date, phil=None, scra=None, offg=None)
classmethod
Assume that because of citation-utils, the extracted values are inputted into a database.
When the values are pulled from the database, it becomes necessary to convert these database (lowercased) values to a unified properly-cased citation string with readable date (vs. isoformat db-counterpart).
Examples:
>>> Citation.make_citation_string(cat='gr', num='111', date='2000-01-01', phil='100 phil. 100', scra='122 scra 100-a')
'G.R. No. 111, Jan. 1, 2000, 100 Phil. 100, 122 SCRA 100-A'
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cat |
str
|
The shorthand code for docket category |
required |
num |
str
|
The serial identifier of the docket category |
required |
date |
str
|
The date of |
required |
phil |
str | None
|
Phil. Reports. Defaults to None. |
None
|
scra |
str | None
|
Supreme Court Reports Annotated. Defaults to None. |
None
|
offg |
str | None
|
Official Gazette. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
str | None
|
str | None: The combination of citation bits. |
Source code in src/citation_utils/citation.py
make_docket_row()
This presumes that a valid docket exists. Although a citation can be a non-docket, e.g. phil, scra, etc., for purposes of creating a a route-based row for a prospective decision object, the identifier will be based on a docket id.
Source code in src/citation_utils/citation.py
ser_model()
Generate a database row-friendly format of the model. Note the different
field names: cat
, num
, dt
, phil
, scra
, offg
map to either a usable
database value or None
. The docket values here have the option to be None
since some citations, especially the legacy variants, do not include their
docket equivalents in the source texts.
Examples:
>>> text = "OCA IPI No. 10-3450-P, Feb. 06, 2008"
>>> cite = Citation.extract_citation(text)
>>> cite.model_dump_json()
'{"cat":"oca","num":"10-3450-p","date":"2008-02-06","phil":null,"scra":null,"offg":null}'
Source code in src/citation_utils/citation.py
set_slug()
Create a unique identifier of a decision.
Examples:
>>> text = "GR 138570, Oct. 10, 2000"
>>> Citation.extract_citation(text).set_slug()
'gr-138570-2000-10-10'
Source code in src/citation_utils/citation.py
CountedCitation
Bases: Citation
Source code in src/citation_utils/citation.py
Python | |
---|---|
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 |
|
Functions
counted_docket_reports(text)
classmethod
Detect dockets with reports from source text
by first converting
raw citations into a Citation
object to take advantage of __eq__
in
a seen
list. Will populate unique records with missing values.
Source code in src/citation_utils/citation.py
counted_reports(text)
classmethod
Detect reports only from source text
by first converting
raw citations into a Citation
object to take advantage of __eq__
in
a seen
list. This will also populate the the unique records with missing
values.
Source code in src/citation_utils/citation.py
from_repr_format(repr_texts)
classmethod
Generate their pydantic counterparts from <cat> <id>: <mentions>
format.
Examples:
>>> repr_texts = ['BM No. 412, Jan 01, 2000, 1111 SCRA 1111: 3', 'GR No. 147033, Apr 30, 2003, 374 Phil. 1: 1']
>>> results = list(CountedCitation.from_repr_format(repr_texts))
>>> len(results)
2
>>> results[0].model_dump()
{'cat': 'bm', 'num': '412', 'date': '2000-01-01', 'phil': None, 'scra': '1111 scra 1111', 'offg': None, 'mentions': 3}
>>> results[1].model_dump()
{'cat': 'gr', 'num': '147033', 'date': '2003-04-30', 'phil': '374 phil. 1', 'scra': None, 'offg': None, 'mentions': 1}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
repr_texts |
str
|
list of texts having |
required |
Yields:
Type | Description |
---|---|
Self
|
Iterator[Self]: Instances of CountedCitation. |
Source code in src/citation_utils/citation.py
from_source(text)
classmethod
Computes mentions of counted_dockets()
vis-a-vis counted_reports()
and
count the number of unique items, taking into account the Citation
structure and the use of eq re: what is considered unique.
Examples:
>>> source = "374 Phil. 1, 10-11 (1999) 1111 SCRA 1111; G.R. No. 147033, April 30, 2003; G.R. No. 147033, April 30, 2003, 374 Phil. 1, 600; ABC v. XYZ, G.R. Nos. 138570, 138572, 138587, 138680, 138698, October 10, 2000, 342 SCRA 449; XXX, G.R. No. 31711, Sept. 30, 1971, 35 SCRA 190; Hello World, 1111 SCRA 1111; Y v. Z, 35 SCRA 190; 1 Off. Gaz. 41 Bar Matter No. 803, Jan. 1, 2000 Bar Matter No. 411, Feb. 1, 2000 Bar Matter No. 412, Jan. 1, 2000, 1111 SCRA 1111; 374 Phil. 1"
>>> len(CountedCitation.from_source(source))
5
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
Text to Evaluate. |
required |
Returns:
Type | Description |
---|---|
list[Self]
|
list[Self]: Unique citations with their counts. |