def dump_classifier_loop(extractor):
    """
    Ask the user if he wants to save the classifier, and in that case where.
    If the file already exists keeps asking until it gets an answer
    """
    while True:
        answer = input(
            '\nDo you want to save the classifier generated? (y/n): ')
        if answer not in ['y', 'n', 'yes', 'no']:
            print('Invalid answer\n')
        else:
            break
    if answer in ['y', 'yes']:
        while True:
            output_filepath = input('\nChoose the filename of the output: ')
            try:
                extractor.save(output_filepath)
                break
            except ValueError:
                print('Error: file already exists, try another one.\n')
            except FileNotFoundError:
                print("Error: couldn't open the file, try another one.\n")
