Datasets:
further fixed bugs
Browse files- randumbizer.py +31 -15
randumbizer.py
CHANGED
@@ -60,13 +60,16 @@ class ContentGenerator:
|
|
60 |
counts = {"girl": 0, "boy": 0, "other": 0}
|
61 |
characters = []
|
62 |
sources = []
|
63 |
-
seen_sources = set()
|
64 |
|
65 |
for line in lines:
|
66 |
splits = line.split(", ")
|
|
|
|
|
67 |
if "no humans" in splits:
|
68 |
splits.remove("no humans")
|
69 |
|
|
|
70 |
char_type = splits[0] if splits[0] in ["1girl", "1boy", "1other"] else "other"
|
71 |
if char_type == "1girl":
|
72 |
counts["girl"] += 1
|
@@ -78,18 +81,35 @@ class ContentGenerator:
|
|
78 |
counts["other"] += 1
|
79 |
char_type = "other"
|
80 |
|
81 |
-
|
82 |
-
if
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
count_str = ", ".join(
|
92 |
-
f"{count}{key}{'s' if count > 1 else ''}"
|
93 |
for key, count in counts.items() if count > 0
|
94 |
) + (", " + ", ".join(sources) if sources else "")
|
95 |
result = f"{count_str}, {artists} | " + " | ".join(characters)
|
@@ -109,7 +129,6 @@ class ContentGenerator:
|
|
109 |
|
110 |
def main():
|
111 |
generator = ContentGenerator()
|
112 |
-
# Immediate random output on start
|
113 |
generator.process_default()
|
114 |
|
115 |
while True:
|
@@ -120,18 +139,15 @@ def main():
|
|
120 |
elif user_input == "c":
|
121 |
generator.get_anime_screenshot()
|
122 |
elif user_input and user_input[0].isdigit():
|
123 |
-
# Check if input is just a number from 1-6
|
124 |
if user_input in ["1", "2", "3", "4", "5", "6"]:
|
125 |
num = int(user_input)
|
126 |
generator.process_character_lines(num)
|
127 |
-
# Check if there's a space after the number for tags
|
128 |
elif " " in user_input:
|
129 |
parts = user_input.split(maxsplit=1)
|
130 |
num = min(int(parts[0]), 6)
|
131 |
tags = [tag.strip() for tag in parts[1].split(',')]
|
132 |
generator.process_character_lines(num, tags)
|
133 |
else:
|
134 |
-
# Treat entire input as search term if no space and not just 1-6
|
135 |
generator.process_default(user_input)
|
136 |
else:
|
137 |
generator.process_default(user_input if user_input else None)
|
|
|
60 |
counts = {"girl": 0, "boy": 0, "other": 0}
|
61 |
characters = []
|
62 |
sources = []
|
63 |
+
seen_sources = set()
|
64 |
|
65 |
for line in lines:
|
66 |
splits = line.split(", ")
|
67 |
+
|
68 |
+
# Remove "no humans" first if present
|
69 |
if "no humans" in splits:
|
70 |
splits.remove("no humans")
|
71 |
|
72 |
+
# Determine character type early
|
73 |
char_type = splits[0] if splits[0] in ["1girl", "1boy", "1other"] else "other"
|
74 |
if char_type == "1girl":
|
75 |
counts["girl"] += 1
|
|
|
81 |
counts["other"] += 1
|
82 |
char_type = "other"
|
83 |
|
84 |
+
# Handle source and character name based on type
|
85 |
+
if char_type in ["girl", "boy"]: # Standard format: 1girl/boy, name, source
|
86 |
+
if len(splits) > 2:
|
87 |
+
source = splits[2]
|
88 |
+
char_name = splits[1]
|
89 |
+
tags = splits[3:]
|
90 |
+
else:
|
91 |
+
source = ""
|
92 |
+
char_name = splits[1] if len(splits) > 1 else ""
|
93 |
+
tags = []
|
94 |
+
else: # Other format: name, source
|
95 |
+
char_name = splits[0] # Keep the original name
|
96 |
+
source = splits[1] if len(splits) > 1 else ""
|
97 |
+
tags = splits[2:] if len(splits) > 2 else []
|
98 |
+
|
99 |
+
# Add source to sources list
|
100 |
+
if source and source not in seen_sources:
|
101 |
+
sources.append(source)
|
102 |
+
seen_sources.add(source)
|
103 |
+
|
104 |
+
# Construct character entry
|
105 |
+
character_entry = [char_type]
|
106 |
+
if char_name:
|
107 |
+
character_entry.append(char_name)
|
108 |
+
character_entry.extend(tags)
|
109 |
+
characters.append(", ".join(character_entry))
|
110 |
|
111 |
count_str = ", ".join(
|
112 |
+
f"{count}{key}{'s' if count > 1 else ''}"
|
113 |
for key, count in counts.items() if count > 0
|
114 |
) + (", " + ", ".join(sources) if sources else "")
|
115 |
result = f"{count_str}, {artists} | " + " | ".join(characters)
|
|
|
129 |
|
130 |
def main():
|
131 |
generator = ContentGenerator()
|
|
|
132 |
generator.process_default()
|
133 |
|
134 |
while True:
|
|
|
139 |
elif user_input == "c":
|
140 |
generator.get_anime_screenshot()
|
141 |
elif user_input and user_input[0].isdigit():
|
|
|
142 |
if user_input in ["1", "2", "3", "4", "5", "6"]:
|
143 |
num = int(user_input)
|
144 |
generator.process_character_lines(num)
|
|
|
145 |
elif " " in user_input:
|
146 |
parts = user_input.split(maxsplit=1)
|
147 |
num = min(int(parts[0]), 6)
|
148 |
tags = [tag.strip() for tag in parts[1].split(',')]
|
149 |
generator.process_character_lines(num, tags)
|
150 |
else:
|
|
|
151 |
generator.process_default(user_input)
|
152 |
else:
|
153 |
generator.process_default(user_input if user_input else None)
|