How to use the underthesea.model_fetcher.UTSModel function in underthesea

To help you get started, we’ve selected a few underthesea examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github undertheseanlp / underthesea / underthesea / classification / vntc / __init__.py View on Github external
def classify(X):
    global classifier

    if not classifier:
        if os.path.exists(model_path):
            classifier = TextClassifier.load(model_path)
        else:
            logger.error(
                f"Could not load model at {model_path}.\n"
                f"Download model with \"underthesea download {UTSModel.tc_general.value}\".")
            sys.exit(1)

    sentence = Sentence(X)
    classifier.predict(sentence)
    labels = sentence.labels
    return labels
github undertheseanlp / underthesea / underthesea / sentiment / bank / __init__.py View on Github external
def sentiment(text):
    global classifier

    if not classifier:
        if os.path.exists(model_path):
            classifier = TextClassifier.load(model_path)
        else:
            logger.error(
                f"Could not load model at {model_path}.\n"
                f"Download model with \"underthesea download {UTSModel.sa_bank.value}\".")
            sys.exit(1)
    sentence = Sentence(text)
    classifier.predict(sentence)
    labels = sentence.labels
    return [label.value for label in labels]
github undertheseanlp / underthesea / underthesea / classification / bank / __init__.py View on Github external
def classify(X):
    global classifier

    if not classifier:
        if os.path.exists(model_path):
            classifier = TextClassifier.load(model_path)
        else:
            logger.error(
                f"Could not load model at {model_path}.\n"
                f"Download model with \"underthesea download {UTSModel.tc_bank.value}\".")
            sys.exit(1)
    sentence = Sentence(X)
    classifier.predict(sentence)
    labels = sentence.labels
    if not labels:
        return None
    return [label.value for label in labels]
github undertheseanlp / underthesea / underthesea / model_fetcher.py View on Github external
def get_model_path(model):
        if model == UTSModel.tc_bank:
            return Path(CACHE_ROOT) / "models" / "tc_bank"

        if model == UTSModel.tc_general:
            return Path(CACHE_ROOT) / "models" / "tc_general"

        if model == UTSModel.sa_general:
            return Path(CACHE_ROOT) / "models" / "sa_general"

        if model == UTSModel.sa_bank:
            return Path(CACHE_ROOT) / "models" / "sa_bank"
github undertheseanlp / underthesea / underthesea / model_fetcher.py View on Github external
def get_model_path(model):
        if model == UTSModel.tc_bank:
            return Path(CACHE_ROOT) / "models" / "tc_bank"

        if model == UTSModel.tc_general:
            return Path(CACHE_ROOT) / "models" / "tc_general"

        if model == UTSModel.sa_general:
            return Path(CACHE_ROOT) / "models" / "sa_general"

        if model == UTSModel.sa_bank:
            return Path(CACHE_ROOT) / "models" / "sa_bank"
github undertheseanlp / underthesea / underthesea / model_fetcher.py View on Github external
def get_model_path(model):
        if model == UTSModel.tc_bank:
            return Path(CACHE_ROOT) / "models" / "tc_bank"

        if model == UTSModel.tc_general:
            return Path(CACHE_ROOT) / "models" / "tc_general"

        if model == UTSModel.sa_general:
            return Path(CACHE_ROOT) / "models" / "sa_general"

        if model == UTSModel.sa_bank:
            return Path(CACHE_ROOT) / "models" / "sa_bank"
github undertheseanlp / underthesea / underthesea / model_fetcher.py View on Github external
def get_model_path(model):
        if model == UTSModel.tc_bank:
            return Path(CACHE_ROOT) / "models" / "tc_bank"

        if model == UTSModel.tc_general:
            return Path(CACHE_ROOT) / "models" / "tc_general"

        if model == UTSModel.sa_general:
            return Path(CACHE_ROOT) / "models" / "sa_general"

        if model == UTSModel.sa_bank:
            return Path(CACHE_ROOT) / "models" / "sa_bank"