Skip to content

Text Strategies

Class TextEncodingStrategies

A class for all available text-encoding strategies.

Source code in genespeak/text_strategies.py
@dataclass
class TextEncodingStrategies:
    """A class for all available text-encoding strategies."""

    ascii = ASCIITextEncodingStrategy()
    utf8 = UTF8TextEncodingStrategy()

Function set_strategy

Returns a text-encoding strategy by name.

Parameters:

Name Type Description Default
strategy_name Optional[str]

name of the text-encoding strategy (options: ascii, utf-8)

None
Source code in genespeak/text_strategies.py
def set_strategy(strategy_name: Optional[str] = None):
    """Returns a text-encoding strategy by name.

    Arguments:
        strategy_name: name of the text-encoding strategy
                       (options: ``ascii``, ``utf-8``)
    """
    if strategy_name:
        strategy_name = strategy_name.replace("-", "")
    if (strategy_name is None) or (strategy_name not in AVAILABLE_STRATEGY_NAMES):
        strategy_name = DEFAULT_STRATEGY_NAME
    # The strategy objects don't have any hiphens ("utf-8" is written as "utf8")
    return getattr(TextEncodingStrategies, strategy_name)

Last update: 2022-11-20
Back to top