PauldeLav commited on
Commit
d79fa36
·
verified ·
1 Parent(s): 2c3a719

Create split_text_lines.py

Browse files
Files changed (1) hide show
  1. split_text_lines.py +21 -0
split_text_lines.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class SplitTextLines:
2
+ @classmethod
3
+ def INPUT_TYPES(cls):
4
+ return {
5
+ "required": {
6
+ "text": ("STRING", {"default": "Ingrese su texto aquí."}),
7
+ "words_per_line": ("INT", {"default": 5, "min": 1}),
8
+ }
9
+ }
10
+
11
+ RETURN_TYPES = ("STRING",)
12
+ FUNCTION = "split_text"
13
+ CATEGORY = "Text"
14
+
15
+ def split_text(self, text, words_per_line):
16
+ words = text.split()
17
+ lines = [" ".join(words[i:i+words_per_line]) for i in range(0, len(words), words_per_line)]
18
+ return ("\n".join(lines),)
19
+
20
+ NODE_CLASS_MAPPINGS = {"SplitTextLines": SplitTextLines}
21
+ NODE_DISPLAY_NAME_MAPPINGS = {"SplitTextLines": "Dividir texto en líneas"}