Skip to content

Specific Types

Docket Report Citation

Bases: Docket, Report, abc.ABC

Note Report is defined in a separate library citation-report.

The DocketReportCitation abstract class makes sure that all of the fields of a Docket object alongside all of the fields of a Report object will be utilized. It also mandates the implementation of acls.search() method.

Source code in citation_utils/dockets/models/docket_citation.py
Python
class DocketReportCitation(Docket, Report, abc.ABC):
    """Note `Report` is defined in a separate library `citation-report`.

    The `DocketReportCitation` abstract class makes sure that all of the
    fields of a [Docket][docket-model] object alongside all of the fields of a `Report`
    object will be utilized. It also mandates the implementation of a`cls.search()`
    method.
    """

    @property
    def _docket(self):
        if self.first_id:
            return f"{self.category.name} No. {self.serial_text}, {self.formatted_date}"
        elif self.ids:
            return f"{self.category.name} No. {self.ids}, {self.formatted_date}"
        return None

    @property
    def _report(self):
        return self.volpubpage or None

    def __str__(self) -> str:
        if self._docket and self._report:
            return f"{self._docket}, {self._report}"
        elif self._docket:
            return self._docket
        elif self._report:
            return self._report
        return "No citation."

    def __repr__(self) -> str:
        if self._docket and self._report:
            return f"<DocketReport: {self._docket} | {self._report}>"
        elif self._docket:
            return f"<DocketReport: {self._docket}>"
        elif self._report:
            return f"<DocketReport: {self._report}>"
        return "<DocketReport: improper citation>"

    @classmethod
    @abc.abstractmethod
    def search(cls, raw: str) -> Iterator[Self]:
        raise NotImplementedError("Search method must produce Iterator of instance.")

General Register

Bases: DocketReportCitation

Source code in citation_utils/dockets/constructed_gr.py
Python
class CitationGR(DocketReportCitation):
    ...

    @classmethod
    def search(cls, text: str) -> Iterator[Self]:
        """Get all dockets matching the `GR` docket pattern, inclusive of their optional Report object.

        Examples:
            >>> text = "Bagong Alyansang Makabayan v. Zamora, G.R. Nos. 138570, 138572, 138587, 138680, 138698, October 10, 2000, 342 SCRA 449"
            >>> cite = next(CitationGR.search(text))
            >>> cite.model_dump(exclude_none=True)
            {'publisher': 'SCRA', 'volume': '342', 'page': '449', 'volpubpage': '342 SCRA 449', 'context': 'G.R. Nos. 138570, 138572, 138587, 138680, 138698', 'category': 'GR', 'ids': '138570, 138572, 138587, 138680, 138698', 'docket_date': datetime.date(2000, 10, 10)}

        Args:
            text (str): Text to look for citation objects

        Yields:
            Iterator[Self]: Combination of Docket and Report pydantic model.
        """  # noqa E501
        for result in constructed_gr.detect(text):
            yield cls(**result)

Functions

search(text) classmethod

Get all dockets matching the GR docket pattern, inclusive of their optional Report object.

Examples:

Python Console Session
>>> text = "Bagong Alyansang Makabayan v. Zamora, G.R. Nos. 138570, 138572, 138587, 138680, 138698, October 10, 2000, 342 SCRA 449"
>>> cite = next(CitationGR.search(text))
>>> cite.model_dump(exclude_none=True)
{'publisher': 'SCRA', 'volume': '342', 'page': '449', 'volpubpage': '342 SCRA 449', 'context': 'G.R. Nos. 138570, 138572, 138587, 138680, 138698', 'category': 'GR', 'ids': '138570, 138572, 138587, 138680, 138698', 'docket_date': datetime.date(2000, 10, 10)}

Parameters:

Name Type Description Default
text str

Text to look for citation objects

required

Yields:

Type Description
Self

Iterator[Self]: Combination of Docket and Report pydantic model.

Source code in citation_utils/dockets/constructed_gr.py
Python
@classmethod
def search(cls, text: str) -> Iterator[Self]:
    """Get all dockets matching the `GR` docket pattern, inclusive of their optional Report object.

    Examples:
        >>> text = "Bagong Alyansang Makabayan v. Zamora, G.R. Nos. 138570, 138572, 138587, 138680, 138698, October 10, 2000, 342 SCRA 449"
        >>> cite = next(CitationGR.search(text))
        >>> cite.model_dump(exclude_none=True)
        {'publisher': 'SCRA', 'volume': '342', 'page': '449', 'volpubpage': '342 SCRA 449', 'context': 'G.R. Nos. 138570, 138572, 138587, 138680, 138698', 'category': 'GR', 'ids': '138570, 138572, 138587, 138680, 138698', 'docket_date': datetime.date(2000, 10, 10)}

    Args:
        text (str): Text to look for citation objects

    Yields:
        Iterator[Self]: Combination of Docket and Report pydantic model.
    """  # noqa E501
    for result in constructed_gr.detect(text):
        yield cls(**result)

Administrative Matter

Bases: DocketReportCitation

Source code in citation_utils/dockets/constructed_am.py
Python
class CitationAM(DocketReportCitation):
    ...

    @classmethod
    def search(cls, text: str) -> Iterator[Self]:
        """Get all dockets matching the `AM` docket pattern, inclusive of their optional Report object.

        Examples:
            >>> text = "A.M. No. P-88-198, February 25, 1992, 206 SCRA 491."
            >>> cite = next(CitationAM.search(text))
            >>> cite.model_dump(exclude_none=True)
            {'publisher': 'SCRA', 'volume': '206', 'page': '491', 'volpubpage': '206 SCRA 491', 'context': 'A.M. No. P-88-198', 'category': 'AM', 'ids': 'P-88-198', 'docket_date': datetime.date(1992, 2, 25)}

        Args:
            text (str): Text to look for citation objects

        Yields:
            Iterator[Self]: Combination of Docket and Report pydantic model.
        """  # noqa E501
        for result in constructed_am.detect(text):
            yield cls(**result)

Functions

search(text) classmethod

Get all dockets matching the AM docket pattern, inclusive of their optional Report object.

Examples:

Python Console Session
>>> text = "A.M. No. P-88-198, February 25, 1992, 206 SCRA 491."
>>> cite = next(CitationAM.search(text))
>>> cite.model_dump(exclude_none=True)
{'publisher': 'SCRA', 'volume': '206', 'page': '491', 'volpubpage': '206 SCRA 491', 'context': 'A.M. No. P-88-198', 'category': 'AM', 'ids': 'P-88-198', 'docket_date': datetime.date(1992, 2, 25)}

Parameters:

Name Type Description Default
text str

Text to look for citation objects

required

Yields:

Type Description
Self

Iterator[Self]: Combination of Docket and Report pydantic model.

Source code in citation_utils/dockets/constructed_am.py
Python
@classmethod
def search(cls, text: str) -> Iterator[Self]:
    """Get all dockets matching the `AM` docket pattern, inclusive of their optional Report object.

    Examples:
        >>> text = "A.M. No. P-88-198, February 25, 1992, 206 SCRA 491."
        >>> cite = next(CitationAM.search(text))
        >>> cite.model_dump(exclude_none=True)
        {'publisher': 'SCRA', 'volume': '206', 'page': '491', 'volpubpage': '206 SCRA 491', 'context': 'A.M. No. P-88-198', 'category': 'AM', 'ids': 'P-88-198', 'docket_date': datetime.date(1992, 2, 25)}

    Args:
        text (str): Text to look for citation objects

    Yields:
        Iterator[Self]: Combination of Docket and Report pydantic model.
    """  # noqa E501
    for result in constructed_am.detect(text):
        yield cls(**result)

Administrative Case

Bases: DocketReportCitation

Source code in citation_utils/dockets/constructed_ac.py
Python
class CitationAC(DocketReportCitation):
    ...

    @classmethod
    def search(cls, text: str) -> Iterator[Self]:
        """Get all dockets matching the `AC` docket pattern, inclusive of their optional Report object.

        Examples:
            >>> text = "A.C. No. P-88-198, February 25, 1992, 206 SCRA 491."
            >>> cite = next(CitationAC.search(text))
            >>> cite.model_dump(exclude_none=True)
            {'publisher': 'SCRA', 'volume': '206', 'page': '491', 'volpubpage': '206 SCRA 491', 'context': 'A.C. No. P-88-198', 'category': 'AC', 'ids': 'P-88-198', 'docket_date': datetime.date(1992, 2, 25)}

        Args:
            text (str): Text to look for citation objects

        Yields:
            Iterator[Self]: Combination of Docket and Report pydantic model.
        """  # noqa E501
        for result in constructed_ac.detect(text):
            yield cls(**result)

Functions

search(text) classmethod

Get all dockets matching the AC docket pattern, inclusive of their optional Report object.

Examples:

Python Console Session
>>> text = "A.C. No. P-88-198, February 25, 1992, 206 SCRA 491."
>>> cite = next(CitationAC.search(text))
>>> cite.model_dump(exclude_none=True)
{'publisher': 'SCRA', 'volume': '206', 'page': '491', 'volpubpage': '206 SCRA 491', 'context': 'A.C. No. P-88-198', 'category': 'AC', 'ids': 'P-88-198', 'docket_date': datetime.date(1992, 2, 25)}

Parameters:

Name Type Description Default
text str

Text to look for citation objects

required

Yields:

Type Description
Self

Iterator[Self]: Combination of Docket and Report pydantic model.

Source code in citation_utils/dockets/constructed_ac.py
Python
@classmethod
def search(cls, text: str) -> Iterator[Self]:
    """Get all dockets matching the `AC` docket pattern, inclusive of their optional Report object.

    Examples:
        >>> text = "A.C. No. P-88-198, February 25, 1992, 206 SCRA 491."
        >>> cite = next(CitationAC.search(text))
        >>> cite.model_dump(exclude_none=True)
        {'publisher': 'SCRA', 'volume': '206', 'page': '491', 'volpubpage': '206 SCRA 491', 'context': 'A.C. No. P-88-198', 'category': 'AC', 'ids': 'P-88-198', 'docket_date': datetime.date(1992, 2, 25)}

    Args:
        text (str): Text to look for citation objects

    Yields:
        Iterator[Self]: Combination of Docket and Report pydantic model.
    """  # noqa E501
    for result in constructed_ac.detect(text):
        yield cls(**result)

Bar Matter

Bases: DocketReportCitation

Source code in citation_utils/dockets/constructed_bm.py
Python
class CitationBM(DocketReportCitation):
    ...

    @classmethod
    def search(cls, text: str) -> Iterator[Self]:
        """Get all dockets matching the `BM` docket pattern, inclusive of their optional Report object.

        Examples:
            >>> text = "B.M. No. 1678, December 17, 2007"
            >>> cite = next(CitationBM.search(text))
            >>> cite.model_dump(exclude_none=True)
            {'context': 'B.M. No. 1678', 'category': 'BM', 'ids': '1678', 'docket_date': datetime.date(2007, 12, 17)}

        Args:
            text (str): Text to look for citation objects

        Yields:
            Iterator[Self]: Combination of Docket and Report pydantic model.
        """  # noqa E501
        for result in constructed_bm.detect(text):
            yield cls(**result)

Functions

search(text) classmethod

Get all dockets matching the BM docket pattern, inclusive of their optional Report object.

Examples:

Python Console Session
>>> text = "B.M. No. 1678, December 17, 2007"
>>> cite = next(CitationBM.search(text))
>>> cite.model_dump(exclude_none=True)
{'context': 'B.M. No. 1678', 'category': 'BM', 'ids': '1678', 'docket_date': datetime.date(2007, 12, 17)}

Parameters:

Name Type Description Default
text str

Text to look for citation objects

required

Yields:

Type Description
Self

Iterator[Self]: Combination of Docket and Report pydantic model.

Source code in citation_utils/dockets/constructed_bm.py
Python
@classmethod
def search(cls, text: str) -> Iterator[Self]:
    """Get all dockets matching the `BM` docket pattern, inclusive of their optional Report object.

    Examples:
        >>> text = "B.M. No. 1678, December 17, 2007"
        >>> cite = next(CitationBM.search(text))
        >>> cite.model_dump(exclude_none=True)
        {'context': 'B.M. No. 1678', 'category': 'BM', 'ids': '1678', 'docket_date': datetime.date(2007, 12, 17)}

    Args:
        text (str): Text to look for citation objects

    Yields:
        Iterator[Self]: Combination of Docket and Report pydantic model.
    """  # noqa E501
    for result in constructed_bm.detect(text):
        yield cls(**result)