AliasSpace¶
- class aliases.space.AliasSpace(data, processor=None, name=None)¶
The alias space stores information on existing aliases
- Parameters:
data (
dict[str,list[str]]) – A dictionary where the keys are the preferred forms of strings and the values are lists of aliasesprocessor (
Optional[StringProcessor]) – A string processor that can be used to make certain variants of your aliases also count as aliases. When a processed string equals the processed form of one of the registered aliases, it is also considered to be an aliasname (
Optional[str]) – Optional name of this alias space
- add_alias(alias, representative)¶
Add an alias to the space
- create_mapper()¶
Creates a dictionary where the processed form of a registered alias maps to its representative
- dict(data=None, **kwargs)¶
Create an AliasAwareDict
- get_representative(string, missing=<object object>, raise_missing=False)¶
Get the representative of a given string
- Parameters:
string (
str) – The raw input stringmissing (
Any) – Value to return when the string is not a registered alias. When this argument is not given, the raw input string will be returned back.raise_missing (
bool) – Whether an error must be raised when the input string is not a registered alias
- Return type:
Any
- map(strings, missing=<object object>, raise_missing=False, return_list=False)¶
Map an iterable of string to their representatives
- Parameters:
strings (
Iterable[str]) – Iterable of stringsmissing (
Any) – Value to return when the string is not a registered alias. When this argument is not given, the raw input string will be returned back.raise_missing (
bool) – Whether an error must be raised when the input string is not a registered aliasreturn_list (
bool) – Whether to cast the output map to a list object
- Return type:
map|list
- str(data)¶
Create an AliasAwareString
- Parameters:
data (
Any) – input string- Return type:
AliasAwareString