File size: 848 Bytes
f0c227a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from transformers import pipeline

## Downlaod the PreTrained Model from the Online Repository
model = pipeline(
    "text-classification",
    model="badmatr11x/roberta-base-emotions-detection-from-text"
)


def app():
    """This Function takes input from the user
        and clssify it into different range of emotions.

    Raises:
        IOError: Raise an IOError if user input can't convert into the string instance.
    """
    # Get user input
    try:
        user_input = str(input("Enter Text Here: "))
    except:
        raise IOError("There is some problem reading text from the console.")

    # Classify the text using the Huggingface model
    if user_input:
        result = model(user_input)
    else:
        print("No User Input is Provided.")

    print(result)


if __name__ == "__main__":
    ## Driver Function
    app()