Upload 3 files
Browse files
.gitattributes
CHANGED
@@ -111,3 +111,4 @@ Danbooru[[:space:]]Prompt[[:space:]]Selector/TEST2024/NAIA_0101_console_testv2.e
|
|
111 |
Danbooru[[:space:]]Prompt[[:space:]]Selector/TEST2024/NAIA_0102_testv2.exe filter=lfs diff=lfs merge=lfs -text
|
112 |
Danbooru[[:space:]]Prompt[[:space:]]Selector/TEST2024/NAIA_0103_testv2.exe filter=lfs diff=lfs merge=lfs -text
|
113 |
Danbooru[[:space:]]Prompt[[:space:]]Selector/TEST2024/NAIA_0105_testv2.exe filter=lfs diff=lfs merge=lfs -text
|
|
|
|
111 |
Danbooru[[:space:]]Prompt[[:space:]]Selector/TEST2024/NAIA_0102_testv2.exe filter=lfs diff=lfs merge=lfs -text
|
112 |
Danbooru[[:space:]]Prompt[[:space:]]Selector/TEST2024/NAIA_0103_testv2.exe filter=lfs diff=lfs merge=lfs -text
|
113 |
Danbooru[[:space:]]Prompt[[:space:]]Selector/TEST2024/NAIA_0105_testv2.exe filter=lfs diff=lfs merge=lfs -text
|
114 |
+
Danbooru[[:space:]]Prompt[[:space:]]Selector/TEST2024/NAIA_0107_testv3.exe filter=lfs diff=lfs merge=lfs -text
|
Danbooru Prompt Selector/TEST2024/NAIA_0107_testv3.exe
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9feca3cdd1196a20b982072bdc329aa28eb4cf5282199f8dc4fa59f8881c3521
|
3 |
+
size 837947086
|
Danbooru Prompt Selector/TEST2024/NAIA_0107_testv3.py
ADDED
The diff for this file is too large to render.
See raw diff
|
|
Danbooru Prompt Selector/TEST2024/NAIA_search.py
CHANGED
@@ -92,7 +92,22 @@ def process_perfect_negative_group(df, perfect_negative_group):
|
|
92 |
|
93 |
return df
|
94 |
|
95 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
if(E == 0):
|
97 |
df = df[~(df['rating'] == 'e')]
|
98 |
if(N == 0):
|
@@ -108,9 +123,8 @@ def search(df, search_request, exclude_request, E, N, S, G):
|
|
108 |
|
109 |
#search_request에 대한 처리
|
110 |
#처리순서 normal -> curly -> asterisk
|
111 |
-
|
112 |
-
|
113 |
-
curly_brace_group = [item for item in split_requests if item.startswith('{') and item.endswith('}')]
|
114 |
asterisk_group = [item for item in split_requests if item.startswith('*')]
|
115 |
normal_group = [item for item in split_requests if item not in curly_brace_group + asterisk_group]
|
116 |
#normal_group = [re.escape(item) if any(char in item for char in special_chars) else item for item in normal_group]
|
@@ -132,35 +146,54 @@ def search(df, search_request, exclude_request, E, N, S, G):
|
|
132 |
if(len(df) == 0):
|
133 |
return None
|
134 |
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
if any(char in keyword for char in special_chars):
|
145 |
-
keyword = re.escape(keyword)
|
146 |
-
request_regex = True
|
147 |
for column in ['copyright', 'character', 'artist', 'meta', 'general']:
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
break
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
df
|
162 |
-
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
#Exclude 처리
|
166 |
if negative_split_requests:
|
@@ -174,17 +207,3 @@ def search(df, search_request, exclude_request, E, N, S, G):
|
|
174 |
if(len(df) == 0):
|
175 |
return None
|
176 |
return df
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
|
|
92 |
|
93 |
return df
|
94 |
|
95 |
+
def extract_and_split(search_request):
|
96 |
+
curly_brace_group = []
|
97 |
+
while '{' in search_request:
|
98 |
+
start_index = search_request.find('{')
|
99 |
+
end_index = search_request.find('}')
|
100 |
+
if end_index != -1:
|
101 |
+
curly_brace_content = search_request[start_index:end_index + 1]
|
102 |
+
curly_brace_group.append(curly_brace_content)
|
103 |
+
search_request = search_request.replace(curly_brace_content, '', 1)
|
104 |
+
else:
|
105 |
+
break
|
106 |
+
|
107 |
+
split_requests = [item.strip() for item in search_request.split(',') if item.strip()]
|
108 |
+
return curly_brace_group, split_requests
|
109 |
+
|
110 |
+
def search(df, search_request, exclude_request, E=None, N=None, S=None, G=None):
|
111 |
if(E == 0):
|
112 |
df = df[~(df['rating'] == 'e')]
|
113 |
if(N == 0):
|
|
|
123 |
|
124 |
#search_request에 대한 처리
|
125 |
#처리순서 normal -> curly -> asterisk
|
126 |
+
#solo, 1girl, {hololive, animal ears|nijisanji, loli}
|
127 |
+
curly_brace_group, split_requests = extract_and_split(search_request)
|
|
|
128 |
asterisk_group = [item for item in split_requests if item.startswith('*')]
|
129 |
normal_group = [item for item in split_requests if item not in curly_brace_group + asterisk_group]
|
130 |
#normal_group = [re.escape(item) if any(char in item for char in special_chars) else item for item in normal_group]
|
|
|
146 |
if(len(df) == 0):
|
147 |
return None
|
148 |
|
149 |
+
#OR 처리
|
150 |
+
if curly_brace_group:
|
151 |
+
for keyword in curly_brace_group:
|
152 |
+
or_search_keyword = [item.strip() for item in keyword[1:-1].split('|')]
|
153 |
+
results = pd.DataFrame()
|
154 |
+
for keyword in or_search_keyword:
|
155 |
+
keywords = [item.strip() for item in keyword.split(',')]
|
156 |
+
matched_rows = None
|
157 |
+
for keyword in keywords:
|
|
|
|
|
|
|
158 |
for column in ['copyright', 'character', 'artist', 'meta', 'general']:
|
159 |
+
request_regex = False
|
160 |
+
if any(char in keyword for char in special_chars):
|
161 |
+
keyword = re.escape(keyword)
|
162 |
+
request_regex = True
|
163 |
+
if keyword == keywords[0]:
|
164 |
+
if request_regex: matched_rows = df[df[column].str.contains(keyword, na=False, regex=True)]
|
165 |
+
else: matched_rows = df[df[column].str.contains(keyword, na=False)]
|
166 |
+
else:
|
167 |
+
print(keyword, len(matched_rows))
|
168 |
+
if request_regex:
|
169 |
+
ndf = matched_rows[matched_rows[column].str.contains(keyword, na=False, regex=True)]
|
170 |
+
else:
|
171 |
+
ndf = matched_rows[matched_rows[column].str.contains(keyword, na=False)]
|
172 |
+
print(keyword, len(matched_rows), len(ndf))
|
173 |
+
if not ndf.empty:
|
174 |
+
matched_rows = ndf.copy()
|
175 |
+
if keyword == keywords[0] and not matched_rows.empty:
|
176 |
break
|
177 |
+
else:
|
178 |
+
if not matched_rows.empty and not ndf.empty:
|
179 |
+
ndf = None
|
180 |
+
break
|
181 |
+
|
182 |
+
if not matched_rows.empty:
|
183 |
+
results = pd.concat([results, matched_rows])
|
184 |
+
print(results)
|
185 |
+
del[[df]]
|
186 |
+
results = results.drop_duplicates()
|
187 |
+
df = results.copy()
|
188 |
+
del[[results]]
|
189 |
+
if(len(df) == 0):
|
190 |
+
return None
|
191 |
+
|
192 |
+
#Perfect Matching 처리
|
193 |
+
if asterisk_group:
|
194 |
+
df = process_asterisk_group(df,asterisk_group)
|
195 |
+
if(len(df) == 0):
|
196 |
+
return None
|
197 |
|
198 |
#Exclude 처리
|
199 |
if negative_split_requests:
|
|
|
207 |
if(len(df) == 0):
|
208 |
return None
|
209 |
return df
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|