示例#1
0
def main():
    option = prompt_user(create_type)
    if option == CREATE_NEW_ENTITY_MSG:
        create_new_entity_in_folder('')

    else:
        # if custom directory is found
        if os.path.isdir("custom"):
            return create_new_project('custom/')
        # we are currently in an custom directory
        elif os.getcwd().endswith('custom'):
            return create_new_project('')

        custom_folder = prompt_user(create_custom_folder)
        if custom_folder == 'Yes, create a "custom" folder.':
            os.makedirs('custom')
            print(
                '\n*** Created new directory "custom" to use for Discovery mount directory. ***\n'
            )
            create_new_project('custom/')

        elif custom_folder == 'No, I want to name my mount volume something other than "custom."':
            name_of_mount_volume = get_name_of_custom_mount_volume()
            create_new_project(name_of_mount_volume)
        else:
            create_new_project('')
示例#2
0
def get_name_of_custom_mount_volume():
    response = prompt_user(name_of_mount_volume)
    if response.lower().strip() == 'ls':
        for dir in list(os.walk('.'))[0][1]:
            print(dir)
        return get_name_of_custom_mount_volume()
    if not os.path.isdir(response):
        os.makedirs(response)
        print(
            '\n***Created new directory "{}" to use for Discovery mount directory.***\n'
            .format(response))
    if not response.endswith('/'):
        response += '/'
    return response
示例#3
0
def _prompt_for_custom_tokens(entity_name):
    custom_tokens_prompt = _generate_custom_tokens_prompt(entity_name)
    help_message = (
        '\nA "token" is a way of classifying a type of word in a transcript. '
        'Discovery comes with some built in tokens for commonly used word types like numbers and letters. '
        'If you have a special type of word that you would like discovery to find, '
        'you should make a custom token for each category of word that you are looking for. '
        'If you make a custom token, you will first be prompted for a label for your token, '
        'and next you will be prompted for a list of the actual words that discovery should find.\n'
    )
    response = prompt_user(custom_tokens_prompt)
    if response == REQUEST_TOKEN_INFO_MSG:
        print(help_message)
        return _prompt_for_custom_tokens(entity_name)

    return response == 'Yes'
示例#4
0
def user_wants_a_new_entities_directory():
    return prompt_user(create_entities_folder)
示例#5
0
def _user_needs_another_token():
    return prompt_user(additional_custom_tokens)
示例#6
0
def _user_will_use_examples():
    return prompt_user(example_sentences)
示例#7
0
def _user_needs_another_intent():
    return prompt_user(additional_custom_intents)
示例#8
0
def _user_needs_another_example():
    return prompt_user(additional_examples)
示例#9
0
def _user_will_use_entities_list():
    return prompt_user(entities_list)
示例#10
0
def create_new_entity(file_location, entity_name_choice=None):
    if entity_name_choice is None:
        entity_name_choice = prompt_user(entity_name)
    custom_tokens = get_custom_tokens(entity_name_choice)
    _create_new_entity_file(entity_name_choice, custom_tokens, file_location)