Skip to main content

Add justice, decision, citation, voting, and opinion tables to pre-existing corpus-pax database.

Project description

Corpus-Base

flowchart LR

subgraph main
  local(local machine)--setup corpus-base tables--->db[(db from corpus-pax)]
end
subgraph github/corpus
  folder1(justices)--data via api---local
  folder2(decisions/sc)--data via local copy---local
  folder3(decisions/legacy)--data via local copy---local
end

With the database used in corpus-pax, create additional tables related to decisions of the Philippine Supreme Court.

>>> from corpus_base import build_sc_tables
>>> build_sc_tables(c)

This creates additional tables associated with:

  1. Justices
  2. Decisions
    • Citations
    • Votelines
    • Titletags
    • Opinions
>>> from corpus_base import init_sc_cases
>>> init_sc_cases(c, test_only=10)

Parse through a locally downloaded repository to populate tables. Since there are thousands of cases, can limit the number of downloads via the test_only function attribute. The path location of the downloaded repository is hard-coded since this package is intended to be run locally. Instructions for downloading and updating the repository are discussed elsewhere.

Full steps

from corpus_pax import init_persons, init_person_tables
from corpus_base import build_sc_tables, setup_case, init_sc_cases
from sqlpyd import Connection

c = Connection(DatabasePath="test.db")  # type: ignore
init_persons(c)  # for authors
build_sc_tables(c)
init_sc_cases(c, test_only=10)

Related features

Insert records

Can add all pydantic validated records from the local copy of justices to the database.

>>> from corpus_base import Justice
>>> Justice.init_justices_tbl(c) # c = instantiated Connection
<Table justices_tbl (first_name, last_name, suffix, full_name, gender, id, alias, start_term, end_term, chief_date, birth_date, retire_date, inactive_date)>

Clean raw ponente string

Each ponente name stored in decisions_tbl of the database has been made uniform, e.g.:

>>> from corpus_base import RawPonente
>>> RawPonente.clean("REYES , J.B.L, Acting C.J.") # sample name 1
"reyes, j.b.l."
>>> RawPonente.clean("REYES, J, B. L. J.") # sample name 2
"reyes, j.b.l."

We can see most common names in the ponente field and the covered dates, e.g. from 1954 to 1972 (dates found in the decisions), there have been 1053 decisions marked with jbl (as cleaned):

>>> from corpus_base.helpers import most_popular
>>> [i for i in most_popular(c, db)] # excluding per curiams and unidentified cases
[
    ('1994-07-04', '2017-08-09', 'mendoza', 1297), # note multiple personalities named mendoza, hence long range from 1994-2017
    ('1921-10-22', '1992-07-03', 'paras', 1287), # note multiple personalities named paras, hence long range from 1921-1992
    ('2009-03-17', '2021-03-24', 'peralta', 1243),
    ('1998-06-18', '2009-10-30', 'quisumbing', 1187),
    ('1999-06-28', '2011-06-02', 'ynares-santiago', 1184),
    ('1956-04-28', '2008-04-04', 'panganiban', 1102),
    ('1936-11-19', '2009-11-05', 'concepcion', 1058), # note multiple personalities named concepcion, hence long range from 1936-2009
    ('1954-07-30', '1972-08-18', 'reyes, j.b.l.', 1053),
    ('1903-11-21', '1932-03-31', 'johnson', 1043),
    ('1950-11-16', '1999-05-23', 'bautista angelo', 1028), # this looks like bad data
    ('2001-11-20', '2019-10-15', 'carpio', 1011),
    ...
]

Isolate active justices on date

When selecting a ponente or voting members, create a candidate list of justices based on date:

>>> from corpus_base import Justice
>>> Justice.get_active_on_date(c, 'Dec. 1, 1995') # target date
[
    {
        'id': 137,
        'surname': 'panganiban',
        'alias': None,
        'start_term': '1995-10-05', # since start date is greater than target date, record is included
        'inactive_date': '2006-12-06',
        'chief_date': '2005-12-20'
    },
    {
        'id': 136,
        'surname': 'hermosisima',
        'alias': 'hermosisima jr.',
        'start_term': '1995-01-10',
        'inactive_date': '1997-10-18',
        'chief_date': None
    },
]

Designation as chief or associate

Since we already have candidates, we can cleaning desired option to get the id and designation:

>>> from corpus_base import RawPonente
>>> RawPonente.clean('Panganiban, Acting Cj')
'panganiban'
>>> Justice.get_justice_on_date(c, '2005-09-08', 'panganiban')
{
    'id': 137,
    'surname': 'Panganiban',
    'start_term': '1995-10-05',
    'inactive_date': '2006-12-06',
    'chief_date': '2005-12-20',
    'designation': 'J.' # note variance
}

Note that the raw information above contains 'Acting Cj' and thus the designation is only 'J.'

At present we only track 'C.J.' and 'J.' titles.

With a different date, we can get the 'C.J.' designation.:

>>> Justice.get_justice_on_date('2006-03-30', 'panganiban')
{
    'id': 137,
    'surname': 'Panganiban',
    'start_term': '1995-10-05',
    'inactive_date': '2006-12-06',
    'chief_date': '2005-12-20',
    'designation': 'C.J.' # corrected
}

View chief justice dates

>>> from corpus_base import Justice
>>> Justice.view_chiefs(c)
[
    {
        'id': 178,
        'last_name': 'Gesmundo',
        'chief_date': '2021-04-05',
        'max_end_chief_date': None,
        'actual_inactive_as_chief': None,
        'years_as_chief': None
    },
    {
        'id': 162,
        'last_name': 'Peralta',
        'chief_date': '2019-10-23',
        'max_end_chief_date': '2021-04-04',
        'actual_inactive_as_chief': '2021-03-27',
        'years_as_chief': 2
    },
    {
        'id': 163,
        'last_name': 'Bersamin',
        'chief_date': '2018-11-26',
        'max_end_chief_date': '2019-10-22',
        'actual_inactive_as_chief': '2019-10-18',
        'years_as_chief': 1
    },
    {
        'id': 160,
        'last_name': 'Leonardo-De Castro',
        'chief_date': '2018-08-28',
        'max_end_chief_date': '2018-11-25',
        'actual_inactive_as_chief': '2018-10-08',
        'years_as_chief': 0
    }...
]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

corpus_base-0.1.1.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

corpus_base-0.1.1-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file corpus_base-0.1.1.tar.gz.

File metadata

  • Download URL: corpus_base-0.1.1.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.6 Darwin/22.2.0

File hashes

Hashes for corpus_base-0.1.1.tar.gz
Algorithm Hash digest
SHA256 07d476106e818c1af0fa52ec7b935f27d43e40df8a215d8608363234455ebc7b
MD5 c93e51baebfc35c249a761e93ec5ba40
BLAKE2b-256 658f99a8eabf6621ab8373ead140417cb6f2a9d1994f08a8d615da8689acbe71

See more details on using hashes here.

File details

Details for the file corpus_base-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: corpus_base-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.6 Darwin/22.2.0

File hashes

Hashes for corpus_base-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 84b83908704e51e638d28a54acb735e11a9e3e62a96981c22185c69d7b4ae73c
MD5 a15732754e8f45703a288c50973274ad
BLAKE2b-256 c7a014b4d4706e2d1e6e86eab1145bf6fc6dbe610bf3a5044816822f3808f868

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page