def test_sp_true():
    happy_ns = HappyNextSentence()
    result = happy_ns.predict_next_sentence(
        "Hi nice to meet you. How old are you?",
        "I am 21 years old."
    )
    assert result > 0.5
def test_sp_false():
    happy_ns = HappyNextSentence()
    result = happy_ns.predict_next_sentence(
        "How old are you?",
        "The Eiffel Tower is in Paris."
    )
    assert result < 0.5
Exemple #3
0
def example_4_1():
    happy_ns = HappyNextSentence()
    result = happy_ns.predict_next_sentence(
        "How old are you?",
        "I am 21 years old."
    )
    print(type(result))  # <class 'float'>
    print(result)  # 0.9999918937683105
Exemple #4
0
def example_4_2():
    happy_ns = HappyNextSentence()
    result = happy_ns.predict_next_sentence(
        "How old are you?",
        "Queen's University is in Kingston Ontario Canada"
    )
    print(type(result))  # <class 'float'>
    print(result)  # 0.00018497584096621722
Exemple #5
0
def test_sp_save():
    happy = HappyNextSentence()
    happy.save("model/")
    result_before = happy.predict_next_sentence(
        "How old are you?", "The Eiffel Tower is in Paris.")

    happy = HappyNextSentence(load_path="model/")
    result_after = happy.predict_next_sentence(
        "How old are you?", "The Eiffel Tower is in Paris.")

    assert result_before == result_after
Exemple #6
0
def example_4_0():
    happy_ns = HappyNextSentence()  # default is "bert-base-uncased"
    happy_ns_large = HappyNextSentence("BERT", "bert-large-uncased")