sign_language_translator.languages.sign.pakistan_sign_language module

Defines a class for constructing Pakistan Sign Language from text using rules.

class sign_language_translator.languages.sign.pakistan_sign_language.PakistanSignLanguage[source]

Bases: SignLanguage

A class representing the Pakistan Sign Language.

It provides methods for converting tokens to sign dictionaries and restructuring sentences.

STOPWORDS

A set of stopwords in Pakistan Sign Language.

Type:

set

STOPWORDS = {'so', 'the'}
mapping_rules: List[MappingRule]
static name() str[source]

Returns the name of the sign language.

restructure_sentence(sentence: Iterable[str], tags: Iterable[Any] | None = None, contexts: Iterable[Any] | None = None) Tuple[Iterable[str], Iterable[Any], Iterable[Any]][source]

Restructures a sentence by changing the grammar, removing stopwords, spaces & punctuation, and modifying token contents.

Parameters:
  • sentence (Iterable[str]) – Input sentence to be restructured.

  • tags (Iterable[Any], optional) – Additional tags associated with the sentence. Defaults to None.

  • contexts (Iterable[Any], optional) – Additional contexts associated with the sentence. Defaults to None.

Returns:

The restructured sentence, associated tags, and contexts.

Return type:

Tuple[Iterable[str], Iterable[Any], Iterable[Any]]

tokens_to_sign_dicts(tokens: Iterable[str], tags: Iterable[Any] | None = None, contexts: Iterable[Any] | None = None) List[Dict[str, List[List[str]] | List[float]]][source]

Converts tokens to signs based on rules and returns a list of sign dictionaries.

Parameters:
  • tokens (Iterable[str]) – Input tokens to be converted to signs.

  • tags (Iterable[Any], optional) – Additional tags associated with the tokens. Defaults to None.

  • contexts (Iterable[Any], optional) – Additional contexts associated with the tokens. Defaults to None.

Returns:

A list of sign dictionaries, where each dictionary contains

the ‘signs’ field mapping to a list of sign sequences and the ‘weights’ field mapping to the usage frequency of each sign sequence. e.g. “word” -> [{“signs”: [[sign_1, sign_2], [alternate_1]], “weights”: [10, 5]}, …]

Return type:

List[Dict[str, List[List[str]] | List[float]]]