danoan.perchance_tools.core.api module

danoan.perchance_tools.core.api.create_dict_from_markdown(markdown_stream: TextIO) WordDict[source]

Create a dictionary from markdown text.

Header titles are mapped to keys which values are dictionaries themselves created from theirs sub-headers.

The text level is stored in the key words within its closest header-level dictionary. The words key stores the lines of the text.

Parameters:

markdown_stream (TextIO)

Return type:

WordDict

danoan.perchance_tools.core.api.find_corrections(word_dict: WordDict, language) List[ReplaceInstructions][source]

Find typos and mispelled words in the dictionary.

Runs a prompt over a LLM to find mispelled words in the WordDict and return a list of ReplaceInstructions.

Parameters:

word_dict (WordDict)

Return type:

List[ReplaceInstructions]

danoan.perchance_tools.core.api.replace_words(word_dict: WordDict, correction_instructions: List[ReplaceInstructions])[source]

Executes a series of replace operations in a WordDict.

The ReplaceInstruction has a key and a list of replace pairs with old and new word.

Parameters:
danoan.perchance_tools.core.api.translate(word: str, from_language: str, to_language: str) List[str][source]

Translate a word from one language to another.

Runs a prompt over a LLM to get the translation.

Parameters:
  • word (str)

  • from_language (str)

  • to_language (str)

Return type:

List[str]