#!/usr/bin/env python3

def test_collaboration_patterns():
    """Test collaboration pattern detection."""
    
    # Primary collaboration indicators
    primary_patterns = ['ft.', 'feat.', 'featuring']
    # Secondary patterns that might indicate collaboration but could also be band names
    secondary_patterns = ['with', '&', 'and', ',']
    
    test_cases = [
        "Shawn Mendes ft. Camila Cabello",
        "Rihanna ft. Drake",
        "Calvin Harris ft. Ellie Goulding",
        "G-Eazy & Halsey",
        "Pitbull ft. Ne-Yo, Afrojack & Nayer",
        "Cardi B ft. Bad Bunny, J Balvin",
        "Earth, Wind & Fire",
        "Simon & Garfunkel",
        "Hall & Oates",
        "Brooks & Dunn",
        "Ariana Grande ft. Big Sean",
        "Clean Bandit ft. Jess Glynne",
        "P!nk ft. Nate Ruess",
        "Maroon 5 ft. Cardi B",
        "The Weeknd ft. Daft Punk",
        "Wiz Khalifa ft. Charlie Puth",
        "Blink-182",  # Not a collaboration
        "U2",  # Not a collaboration
        "P!nk",  # Not a collaboration
    ]
    
    print("Testing collaboration pattern detection:")
    print("=" * 50)
    
    for artist_name in test_cases:
        clean_name = artist_name.strip()
        has_collaboration = False
        
        # First check for primary collaboration patterns
        for pattern in primary_patterns:
            if pattern in clean_name.lower():
                has_collaboration = True
                break
        
        # If no primary pattern found, check secondary patterns more carefully
        if not has_collaboration:
            for pattern in secondary_patterns:
                if pattern in clean_name.lower():
                    # For secondary patterns, we need to be more careful
                    # Skip if it looks like a band name (e.g., "Simon & Garfunkel")
                    if pattern == '&' and len(clean_name.split('&')) == 2:
                        # Check if both parts are single words (likely band name)
                        parts = clean_name.split('&')
                        if len(parts[0].strip().split()) <= 2 and len(parts[1].strip().split()) <= 2:
                            continue  # Likely a band name, not collaboration
                    
                    has_collaboration = True
                    break
        
        if has_collaboration:
            # Extract main artist
            main_artist = clean_name
            for pattern in primary_patterns + secondary_patterns:
                if pattern in clean_name.lower():
                    parts = clean_name.split(pattern)
                    if len(parts) > 1:
                        main_artist = parts[0].strip()
                        break
            
            print(f"✅ COLLABORATION: '{artist_name}' → Main artist: '{main_artist}'")
        else:
            print(f"❌ NOT COLLABORATION: '{artist_name}'")

if __name__ == "__main__":
    test_collaboration_patterns() 