ComfyUI  >  Nodes  >  WAS Node Suite >  Text Find and Replace by Dictionary

ComfyUI Node: Text Find and Replace by Dictionary

Class Name

Text Find and Replace by Dictionary

Category
WAS Suite/Text/Search
Author
WASasquatch (Account age: 4688 days)
Extension
WAS Node Suite
Latest Updated
8/25/2024
Github Stars
1.1K

How to Install WAS Node Suite

Install this extension via the ComfyUI Manager by searching for  WAS Node Suite
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter WAS Node Suite in the search bar
After installation, click the  Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • High-speed GPU machines
  • 200+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 50+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Text Find and Replace by Dictionary Description

Streamline text manipulation by replacing terms with a predefined dictionary for dynamic content generation and customization.

Text Find and Replace by Dictionary:

The Text Find and Replace by Dictionary node is designed to streamline the process of text manipulation by allowing you to replace specific terms within a text using a predefined dictionary. This node is particularly useful for tasks that require dynamic text generation or modification, such as creating varied prompts or scripts. By leveraging a dictionary of terms and their possible replacements, this node can introduce variability and customization into your text, making it a powerful tool for AI artists looking to enhance their creative outputs. The node ensures that each term in the text is replaced with a randomly selected alternative from the dictionary, providing a unique and tailored result each time it is executed.

Text Find and Replace by Dictionary Input Parameters:

text

This parameter represents the input text that you want to process. It is the main body of text where the search and replace operations will be performed. The text should be of type STRING, and it is a required input for the node to function.

dictionary

The dictionary parameter is a collection of terms and their corresponding replacement options. It is of type DICT and is essential for the node to know which terms to look for and what their possible replacements are. Each key in the dictionary represents a term to be replaced, and the value is a list of possible replacements.

replacement_key

This parameter specifies the delimiter used to identify the terms in the text that need to be replaced. The default value is __, meaning that terms in the text should be enclosed within double underscores (e.g., __term__). This helps the node to accurately locate the terms that need to be replaced.

seed

The seed parameter is an integer that initializes the random number generator used to select replacements from the dictionary. It ensures reproducibility of results. The default value is 0, and it can range from 0 to 0xffffffffffffffff. If the seed is set to a non-zero value, it will increment with each replacement to ensure variability.

Text Find and Replace by Dictionary Output Parameters:

text

The output text is the modified version of the input text, where all specified terms have been replaced according to the dictionary. This output maintains the same structure as the input text but with the specified terms substituted by their randomly chosen replacements.

Text Find and Replace by Dictionary Usage Tips:

  • Ensure that the terms in your input text are correctly enclosed within the specified replacement_key delimiters to avoid any missed replacements.
  • Use a diverse dictionary with multiple replacement options for each term to maximize the variability and creativity of the output text.
  • Set a specific seed value if you need reproducible results, especially useful for debugging or iterative creative processes.

Text Find and Replace by Dictionary Common Errors and Solutions:

"KeyError: 'term'"

  • Explanation: This error occurs when a term enclosed within the replacement_key delimiters in the input text does not exist in the dictionary.
  • Solution: Ensure that all terms in the input text are present in the dictionary and correctly spelled.

"TypeError: 'NoneType' object is not iterable"

  • Explanation: This error happens if the dictionary is not properly defined or is empty.
  • Solution: Verify that the dictionary is correctly formatted and contains at least one key-value pair.

"ValueError: invalid literal for int() with base 10"

  • Explanation: This error can occur if the seed value is not an integer.
  • Solution: Make sure the seed parameter is set to a valid integer within the specified range.

Text Find and Replace by Dictionary Related Nodes

Go back to the extension to check out more related nodes.
WAS Node Suite
RunComfy

© Copyright 2024 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals.