<commit_before>#!/usr/bin/python
# coding: utf-8

"""Hebrew character parsing functions.

This module provides basic functions for classifying Hebrew characters
(or sequences of characters) according to their grammatical function.

NOTE
    This is a "best-effort" parser and while attempts are made at correctness,
    some characters may be underspecified (e.g., specified as "sheva" rather
    than "sheva-na" or "sheva-nah") or incorrectly specified.

PROCESS STEPS
    1. Unicode character names are found for each symbol.
    2. Characters are grouped into (letter + points) groups.
    3. Each character is resolved into a grammatical HebPhonics character.
"""

import re

import metadata
import codes
import names

U, N = codes, names  # alias
globals().update(metadata.metadata())  # add package metadata


def ishataf(name):
    """Return true if the character name is a Hataf- vowel.

    Args:
        name (str): name of character

    Returns:
        bool. True if the character name is a Hataf- vowel; False otherwise.

    Variant spellings are normalized before checking:
    >>> ishataf('HATAF-SEGOL')
    True
    >>> ishataf('hataf-kamats')
    True

    Known characters that are not Hataf- vowels return False:
    >>> ishataf('segol')
    False
    >>> ishataf('alef')
    False

    Unknown character names return False:
    >>> ishataf('hataf-madeup')
    False
    >>> ishataf('invalid-name')
    False
    """
    check = names.normalize(name)
    return check in [N.HATAF_SEGOL, N.HATAF_PATAH, N.HATAF_QAMATS]<commit_msg>added: utility function for getting unicode names<commit_after>#!/usr/bin/python
# coding: utf-8

"""Hebrew character parsing functions.

This module provides basic functions for classifying Hebrew characters
(or sequences of characters) according to their grammatical function.

NOTE
    This is a "best-effort" parser and while attempts are made at correctness,
    some characters may be underspecified (e.g., specified as "sheva" rather
    than "sheva-na" or "sheva-nah") or incorrectly specified.

PROCESS STEPS
    1. Unicode character names are found for each symbol.
    2. Characters are grouped into (letter + points) groups.
    3. Each character is resolved into a grammatical HebPhonics character.
"""

import re

import metadata
import codes as U
import names as N

globals().update(metadata.metadata())  # add package metadata


def ishataf(name):
    """Return true if the character name is a Hataf- vowel.

    Args:
        name (str): name of character

    Returns:
        bool. True if the character name is a Hataf- vowel; False otherwise.

    Variant spellings are normalized before checking:
    >>> ishataf('HATAF-SEGOL')
    True
    >>> ishataf('hataf-kamats')
    True

    Known characters that are not Hataf- vowels return False:
    >>> ishataf('segol')
    False
    >>> ishataf('alef')
    False

    Unknown character names return False:
    >>> ishataf('hataf-madeup')
    False
    >>> ishataf('invalid-name')
    False
    """
    return N.normalize(name) in [N.HATAF_SEGOL, N.HATAF_PATAH, N.HATAF_QAMATS]


def names(uni):
    """Return truncated Unicode names for each character in a string.

    Args:
        uni (unicode): a unicode string

    Returns:
        list. Names of the Unicode characters in the string.

    See:
        hebphonics.codes.names()

    Examples:
    >>> names(U.LETTER_ALEF + U.LETTER_BET)
    ['LETTER_ALEF', 'LETTER_BET']
    """
    return U.names(uni, ignore=True, type='const')
{'fraction_non_alphanumeric': 0.09332191780821918, 'fraction_numerical': 0.00228310502283105, 'mean_word_length': 3.2228915662650603, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2716721', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1057, 'n_words': 385}