import json

processed = [
    "Baugewerbe", "Dachdecker", "Elektro", "Sanitär", "Stahl", "Tischler", "Maler", "Kraftfahrzeug", "Friseur", "Fleischer",
    "Zimmerer", "Glaser", "Rollladen", "Gebäudereiniger", "Augenoptiker", "Bäcker", "Konditoren", "Schornsteinfeger", "Steinmetz", "Straßenbauer",
    "Stukkateur", "Boots", "Gold", "Informationstechnik", "Kachel", "Karosserie", "Schneider", "Instrumenten", "Orthopädie", "Parkett", "Sattler", "Werbe", "Zahn"
]

def check_processed(name):
    for p in processed:
        if p in name:
            # Check if it was definitely done. "Sanitär" matches "Sanitär-Heizung...".
            # "Gold" matches "Gold- und Silberschmiede".
            return True
    return False

def get_duesseldorf_targets():
    with open('cologne_duesseldorf_data/duesseldorf_targets.json', 'r', encoding='utf-8') as f:
        targets = json.load(f)
        
    duesseldorf_targets = []
    for t in targets:
        if "Düsseldorf" in t['innung']:
            # Check if likely processed
            # This is a loose check, but good enough to find NEW ones.
            # actually, let's just list them and I will visually pick or blindly take them.
            # I want to avoid duplicates.
            # The processed list above is manually typed and might miss some matches or be too broad.
            # e.g. "Baugewerbe-Innung Düsseldorf" matches "Baugewerbe".
            
            # Let's just output ALL Düsseldorf guilds and I will see which ones are new.
            duesseldorf_targets.append(t)
            
    print(f"Found {len(duesseldorf_targets)} Düsseldorf guilds total.")
    
    # Filter out obvious ones
    new_targets = []
    for t in duesseldorf_targets:
        is_done = False
        for p in processed:
            if p in t['innung'] and "Düsseldorf" in t['innung']:
               # This logic is flawed because "Baugewerbe-Innung Düsseldorf" contains "Baugewerbe".
               # So it will be marked as done.
               # But I WANT to exclude done ones.
               is_done = True
               break
        if not is_done:
            new_targets.append(t)
            
    print(f"Found {len(new_targets)} potentially new Düsseldorf guilds.")
    for t in new_targets[:30]:
        print(f"NEW: {t['innung']}")

if __name__ == "__main__":
    get_duesseldorf_targets()
