コード例 #1
0
def download_from_resource_name(resource_name, pip_args, verbose=True):
    shortcuts = get_json(__about__.__shortcuts__, "Resource shortcuts")
    check_resources_alias(resource_name, shortcuts)
    compatibility = get_compatibility()
    resource_name = resource_name.lower()
    full_resource_name = shortcuts.get(resource_name, resource_name)
    _download_and_link(resource_name, full_resource_name, compatibility,
                       pip_args, verbose)
コード例 #2
0
def download_builtin_entity(entity_name, language, *pip_args):
    """Download compatible language or gazetteer entity resources"""
    download_from_resource_name(language, pip_args, verbose=False)

    shortcuts = get_json(__about__.__shortcuts__, "Resource shortcuts")
    check_resources_alias(entity_name, shortcuts)

    compatibility = get_compatibility()
    resource_name_lower = entity_name.lower()
    long_resource_name = shortcuts.get(resource_name_lower,
                                       resource_name_lower)

    _download_and_link_entity(long_resource_name, entity_name, language,
                              compatibility, pip_args)
コード例 #3
0
def download_language_builtin_entities(language, *pip_args):
    """Download all gazetteer entity resources for a given language as well as
    basic language resources for this language"""
    download_from_resource_name(language, pip_args, verbose=False)

    shortcuts = get_json(__about__.__shortcuts__, "Resource shortcuts")
    for entity_name in get_supported_gazetteer_entities(language):
        check_resources_alias(entity_name, shortcuts)

        compatibility = get_compatibility()
        resource_name_lower = entity_name.lower()
        long_resource_name = shortcuts.get(resource_name_lower,
                                           resource_name_lower)

        _download_and_link_entity(long_resource_name, entity_name, language,
                                  compatibility, pip_args)
コード例 #4
0
def download_language_builtin_entities(language, *pip_args):
    """Download all gazetteer entity resources for a given language as well as
    basic language resources for this language"""
    from builtins import str
    from snips_nlu_parsers import get_supported_gazetteer_entities
    from snips_nlu import __about__
    from snips_nlu.cli.download import download_from_resource_name
    from snips_nlu.cli.utils import (check_resources_alias, get_compatibility,
                                     get_json)

    download_from_resource_name(language, pip_args, verbose=False)

    shortcuts = get_json(__about__.__shortcuts__, "Resource shortcuts")
    for entity_name in get_supported_gazetteer_entities(str(language)):
        check_resources_alias(entity_name, shortcuts)

        compatibility = get_compatibility()
        resource_name_lower = entity_name.lower()
        long_resource_name = shortcuts.get(resource_name_lower,
                                           resource_name_lower)

        _download_and_link_entity(long_resource_name, entity_name, language,
                                  compatibility, pip_args)