Skip to content

Add pythainlp.util.analyze_thai_text - #1149

Merged
wannaphong merged 9 commits into
devfrom
add-analyze_thai_text
Sep 29, 2025
Merged

Add pythainlp.util.analyze_thai_text#1149
wannaphong merged 9 commits into
devfrom
add-analyze_thai_text

Conversation

@wannaphong

@wannaphong wannaphong commented Sep 28, 2025

Copy link
Copy Markdown
Member
    Analyzes a string of Thai text and returns a dictionaries,
    where each values represents a single classified character from the text.

    The function processes the text character by character and maps each Thai
    character to its descriptive name or itself (for consonants and digits).

    :param str text: The Thai text string to be analyzed.
    :rtype: list[dict]
    :return: A dictionaries, with each item containing
                    a single character and a count of 1.

    Examples:
        >>> analyze_thai_text("คนดี")
        {'ค': 1, 'น': 1, 'ด': 1, 'สระ อี': 1}

        >>> analyze_thai_text("เล่น")
        {'สระ เอ': 1, 'ล': 1, 'ไม้เอก': 1, 'น': 1}

Your checklist for this pull request

  • Passed code styles and structures
  • Passed code linting checks and unit test

Added a comprehensive mapping of Thai characters to their descriptive names, including consonants, vowels, tone marks, punctuation, and digits. Implemented the analyze_thai_text function to analyze Thai text and return a list of classified characters.
Added documentation for analyze_thai_text function.
Added unit tests for analyze_thai_text function.
Updated the analyze_thai_text function to return a single dictionary instead of a list of dictionaries, reflecting changes in the return type and documentation.
Corrected the description in the analyze_thai_text function.
@sonarqubecloud

Copy link
Copy Markdown

@wannaphong
wannaphong merged commit c94002a into dev Sep 29, 2025
12 of 42 checks passed
@wannaphong
wannaphong deleted the add-analyze_thai_text branch September 29, 2025 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant