sign_language_translator.languages.sign.sign_language module
contains abstract class for sign languages which map spoken language text to signs using rules
- class sign_language_translator.languages.sign.sign_language.SignLanguage[source]
Bases:
ABCThis abstract class defines the structure and methods required for mapping spoken language text to signs in sign languages using rule-based approaches.
- Keys
Enumerates all keys that are used in a sign dict.
- Type:
enum.Enum
- tokens_to_sign_dicts()[source]
Converts tokens to signs based on rules and returns a list of sign dictionaries.
- restructure_sentence()[source]
Restructures a sentence by adjusting grammar, dropping meaningless words, and normalizing synonyms.
- _make_equal_weight_sign_dict()[source]
Creates a sign dictionary with equal weights for the provided signs.
- class SignDictKeys(value)[source]
Bases:
EnumEnumerates all keys that are used in a sign dict.
- SIGNS
key for the ‘signs’ field in the sign dict mapping to list of sequence of video names.
- Type:
str
- WEIGHTS
key for the ‘weights’ field in the sign dict mapping to the usage frequency of a video sequence.
- Type:
str
- SIGNS = 'signs'
- WEIGHTS = 'weights'
- abstract 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]]
- abstract 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]]]