Id Regulation Utils
Utility functions for Indonesian regulation document processing.
is_known_regulation_structure(regulation_structure)
Return whether a structure tag marks document content rather than page furniture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
regulation_structure
|
Any
|
An element's structure metadata value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True unless the tag is |
is_meaningful_title(text)
Return whether a section-title string carries real content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Candidate title text. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the text contains at least one alphanumeric character. |
match_article_structural_trailing_re(text)
Match a merged section/article header, rejecting prose-like titles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Stripped element text. |
required |
Returns:
| Type | Description |
|---|---|
Match[str] | None
|
re.Match[str] | None: The match, or None when the title body reads as prose. |
match_ordinal_header_re(pattern, group_name, text)
Match an ordinal header, requiring all-caps for unspaced colon glue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
Pattern[str]
|
The ordinal-header pattern to match. |
required |
group_name
|
str
|
The captured ordinal group name. |
required |
text
|
str
|
Stripped element text. |
required |
Returns:
| Type | Description |
|---|---|
Match[str] | None
|
re.Match[str] | None: The match, or None when the glue is invalid. |
parse_indonesian_part_number(text)
Convert an Indonesian ordinal number-word phrase into an integer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The ordinal number-word phrase to parse. |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
int | None: The parsed integer value, or None if no number word is recognised. |
parse_roman_numeral(text)
Convert a Roman numeral into its integer value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The Roman numeral to parse. |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
int | None: The parsed value, or None if the text is invalid. |
resolve_inline_title(inline)
Return a stripped inline title when it is meaningful.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inline
|
str | None
|
Candidate inline title. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The stripped title, or None for absent or meaningless input. |