예제 #1
0
def query_factory(text_preparation_pipeline):
    """For creating queries"""
    return QueryFactory(
        text_preparation_pipeline=text_preparation_pipeline,
        system_entity_recognizer=None,
        duckling=True,
    )
예제 #2
0
def query_factory(tokenizer, preprocessor, stemmer, duckling):
    """For creating queries"""
    return QueryFactory(
        tokenizer=tokenizer,
        preprocessor=preprocessor,
        stemmer=stemmer,
        system_entity_recognizer=duckling,
    )
예제 #3
0
def english_paraphraser_retain_entities(kwik_e_mart_app_path, request):
    config = get_augmentation_config(app_path=kwik_e_mart_app_path)
    language = "en"
    config['augmentor_class'] = "EnglishParaphraser"
    config['retain_entities'] = True
    query_factory = QueryFactory.create_query_factory(
        app_path=kwik_e_mart_app_path, duckling=True)
    resource_loader = ResourceLoader.create_resource_loader(
        app_path=kwik_e_mart_app_path, query_factory=query_factory)
    request.cls.query_factory = query_factory
    request.cls.augmentor = AugmentorFactory(
        config=config,
        language=language,
        resource_loader=resource_loader,
    ).create_augmentor()
    yield None
    request.cls.augmentor = None
    request.cls.query_factor = None
예제 #4
0
def test_nlp_for_stemmed_queries(kwik_e_mart_nlp, query, stemmed_query):
    """Tests queries that are NOT in the training data but have their stemmed
    versions in the training data"""
    query_factory = QueryFactory.create_query_factory()
    stemmed_tokens = query_factory.create_query(text=query).stemmed_tokens
    assert stemmed_query == stemmed_tokens[0]
예제 #5
0
def query_factory(tokenizer, preprocessor):
    """For creating queries"""
    return QueryFactory(tokenizer=tokenizer, preprocessor=preprocessor)
예제 #6
0
def query_factory(tokenizer):
    """For creating queries"""
    return QueryFactory(tokenizer)
예제 #7
0
import os
import shutil

import pytest

from mindmeld import markup
from mindmeld.models import ENTITY_EXAMPLE_TYPE, ENTITIES_LABEL_TYPE, ModelFactory, ModelConfig
from mindmeld.models.nn_utils.helpers import get_num_weights_of_model
from mindmeld.query_factory import QueryFactory
from mindmeld.resource_loader import ResourceLoader, ProcessedQueryList

APP_NAME = "kwik_e_mart"
APP_PATH = os.path.join(
    os.path.dirname(os.path.dirname(os.path.abspath(__file__))), APP_NAME)
GENERATED_TMP_FOLDER = os.path.join(APP_PATH, ".generated/pytorch_module")
QUERY_FACTORY = QueryFactory.create_query_factory(app_path=None, duckling=True)


@pytest.fixture
def resource_loader():
    """A resource loader"""
    return ResourceLoader(app_path=None, query_factory=QUERY_FACTORY)


def model_predictions_assertions(model):
    """Conducts assertions on model predictions; common checks across multiple unittests"""
    predictions = model.predict([
        markup.load_query("Medium Beers pizza from oz pizza",
                          query_factory=QUERY_FACTORY).query
    ])[0]
    assert len(predictions) <= 6