Spaces:
Sleeping
Sleeping
Update app.py
Browse files41 unmodified lines4243444546474849505152535455565758596061626364656667686941 unmodified linesif 'how many' in original_question.lower():# Look for numbers in the responsealbum_patterns = [r'(\d+)\s+album',r'(\d+)\s+studio\s+album',r'is\s+(\d+)',r'are\s+(\d+)']for pattern in album_patterns:match = re.search(pattern, cleaned, re.IGNORECASE)if match:return match.group(1)# If no specific album pattern found, look for any number that makes sense as a countnumbers = re.findall(r'\d+', cleaned)for num in numbers:# Album counts are typically small numbersif int(num) < 20:return num# Last resort: return the first number foundif numbers:return numbers[0]# If it's asking for a year, try to extract just the yearif re.search(r'\b(19|20)\d{2}\b', original_question):41 unmodified lines424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878841 unmodified linesif 'how many' in original_question.lower():# Look for numbers in the responseif 'album' in original_question.lower():# Look for patterns specifically related to album countsalbum_patterns = [r'(\d+)\s+studio albums?',r'(\d+)\s+albums?',r'is\s+(\d+)\s+studio albums?',r'are\s+(\d+)\s+studio albums?',r'count\s+is\s+(\d+)',r'total\s+of\s+(\d+)\s+studio albums?',r'released\s+(\d+)\s+studio albums?',]for pattern in album_patterns:match = re.search(pattern, cleaned, re.IGNORECASE)if match:return match.group(1)# General "how many" patternsgeneral_patterns = [r'(?:is|are)\s*(\d+)',r'^\s*(\d+)',]for pattern in general_patterns:numbers = re.findall(pattern, cleaned)if numbers:# For album counts, we expect a small number (typically less than 20)for num in numbers:if int(num) < 20:return num# Last resort: look for any small number in the responseall_numbers = re.findall(r'\d+', cleaned)for num in all_numbers:# Album counts are typically small numbersif int(num) < 20:return num# Final fallback: return the first number foundif all_numbers:return all_numbers[0]# If it's asking for a year, try to extract just the yearif re.search(r'\b(19|20)\d{2}\b', original_question):
app.py+34-15