# Documentation - Class name: WAS_Text_Random_Line - Category: WAS Suite/Text - Output node: False - Repo Ref: https://github.com/WASasquatch/was-node-suite-comfyui 方法 'text_random_line' 旨在从给定的文本输入中选择一个随机行。它作为工具,适用于需要随机抽样文本行的应用,如在数据预处理或内容生成任务中。 # Input types ## Required - text - 参数 'text' 是将要从中选择随机行的输入文本。它在确定随机选择的内容池中起着关键作用。 - Comfy dtype: STRING - Python dtype: str ## Optional - seed - 参数 'seed' 用于初始化随机数生成器,确保随机行选择过程的可复现性。 - Comfy dtype: INT - Python dtype: int # Output types - random_line - 输出 'random_line' 代表从输入文本中随机选择的行,这是节点操作的主要结果。 - Comfy dtype: STRING - Python dtype: str # Usage tips - Infra type: CPU # Source code ``` class WAS_Text_Random_Line: def __init__(self): pass @classmethod def INPUT_TYPES(cls): return {'required': {'text': (TEXT_TYPE, {'forceInput': True if TEXT_TYPE == 'STRING' else False}), 'seed': ('INT', {'default': 0, 'min': 0, 'max': 18446744073709551615})}} RETURN_TYPES = (TEXT_TYPE,) FUNCTION = 'text_random_line' CATEGORY = 'WAS Suite/Text' def text_random_line(self, text, seed): lines = text.split('\n') random.seed(seed) choice = random.choice(lines) return (choice,) @classmethod def IS_CHANGED(cls, **kwargs): return float('NaN') ```