Take a Lexicon and apply `.transform` to its keys and aliases. :returns: A new Lexicon.
(self, old: Lexicon)
| 493 | return "".join(replaced) |
| 494 | |
| 495 | def _transform_lexicon(self, old: Lexicon) -> Lexicon: |
| 496 | """ |
| 497 | Take a Lexicon and apply `.transform` to its keys and aliases. |
| 498 | |
| 499 | :returns: A new Lexicon. |
| 500 | """ |
| 501 | new = Lexicon() |
| 502 | # Lexicons exhibit only their real keys in most places, so this will |
| 503 | # only grab those, not aliases. |
| 504 | for key, value in old.items(): |
| 505 | # Deepcopy the value so we're not just copying a reference |
| 506 | new[self.transform(key)] = copy.deepcopy(value) |
| 507 | # Also copy all aliases, which are string-to-string key mappings |
| 508 | for key, value in old.aliases.items(): |
| 509 | new.alias(from_=self.transform(key), to=self.transform(value)) |
| 510 | return new |
| 511 | |
| 512 | @property |
| 513 | def task_names(self) -> Dict[str, List[str]]: |