# -*- coding: utf-8 -*- """Tests for pyss3.""" from os import path from shutil import rmtree from pyss3.util import Dataset from pyss3 import \ SS3, STR_NORM_GV_XAI, STR_NORM_GV, STR_GV, \ STR_XAI, STR_VANILLA, STR_MOST_PROBABLE, \ STR_UNKNOWN, STR_UNKNOWN_CATEGORY, IDX_UNKNOWN_CATEGORY, \ PARA_DELTR, SENT_DELTR, WORD_DELTR, VERBOSITY import sys import pyss3 import pytest pyss3.set_verbosity(VERBOSITY.QUIET) DATASET_FOLDER = "dataset" dataset_path = path.join(path.abspath(path.dirname(__file__)), DATASET_FOLDER) x_train, y_train = Dataset.load_from_files(dataset_path, folder_label=False) x_test = [ "sports nfl nba superbowl soccer football team. learns jersey air bowl hockey.\n" "baseball helmet mccutchen jordan curry poker.", "travel pictures images moment glamour canvas photoshoot lens dslr portrait " "beautiful seasons lines colours snap usm af eos painter gallery museum " "flower kinkade.", "hairstyles boutique handbag dress trends womens menswear luxury claudiepierlot " "rustic wedding bride collection signed patrick ista streetstyle cocksox purse " "trending status brush cosmetic stretchy gucci leather cream trendy "
RECV_BUFFER = 1024 * 1024 # 1MB PYTHON3 = sys.version_info[0] >= 3 DATASET_FOLDER = "dataset" DATASET_FOLDER_MR = "dataset_mr" ADDRESS, PORT = "localhost", None LT = s.Live_Test dataset_path = path.join(path.abspath(path.dirname(__file__)), DATASET_FOLDER) dataset_path_mr = path.join(path.abspath(path.dirname(__file__)), DATASET_FOLDER_MR) x_train, y_train = None, None clf = None pyss3.set_verbosity(0) x_train, y_train = Dataset.load_from_files(dataset_path_mr) x_train, y_train = Dataset.load_from_files(dataset_path, folder_label=False) clf = SS3() clf.fit(x_train, y_train) LT.serve() # no model error LT.set_model(clf) LT.get_port() class MockCmdLineArgs: """Mocked command-line arguments."""