Ejemplo n.º 1
0
def test_tc_save():
    happy = HappyTextClassification()
    happy.save("model/")
    result_before = happy.classify_text("What a great movie")

    happy = HappyTextClassification(load_path="model/")
    result_after = happy.classify_text("What a great movie")

    assert result_before.label == result_after.label
Ejemplo n.º 2
0
def test_classify_text():
    happy_tc = HappyTextClassification(
        model_type="DISTILBERT",
        model_name="distilbert-base-uncased-finetuned-sst-2-english")
    result = happy_tc.classify_text("What a great movie")
    assert result.label == 'POSITIVE'
    assert result.score > 0.9
Ejemplo n.º 3
0
def example_2_1():
    happy_tc = HappyTextClassification(
        model_type="DISTILBERT",
        model_name="distilbert-base-uncased-finetuned-sst-2-english")
    result = happy_tc.classify_text("Great movie! 5/5")
    print(
        type(result)
    )  # <class 'happytransformer.happy_text_classification.TextClassificationResult'>
    print(
        result
    )  # TextClassificationResult(label='LABEL_1', score=0.9998761415481567)
    print(result.label)  # LABEL_1