diff --git a/SentimentAnalysis.py b/SentimentAnalysis.py new file mode 100644 index 00000000..37bad917 --- /dev/null +++ b/SentimentAnalysis.py @@ -0,0 +1,23 @@ +# File: SentimentAnalysis.py +# Project: Sentiment Analysis using Pretrained Models + + +from transformers import pipeline + +def sentiment_analysis(text): + # Load pretrained model and tokenizer (DistilBERT) + sentiment_model = pipeline("sentiment-analysis") + + # Get prediction + result = sentiment_model(text)[0] + + # Print and return result + print(f"\n🧠 Input Text: {text}") + print(f"šŸ“Š Sentiment: {result['label']} (Confidence: {result['score']:.2f})") + + return result + +if __name__ == "__main__": + print("=== Sentiment Analysis using Pretrained Models ===") + user_input = input("Enter a sentence or paragraph: ") + sentiment_analysis(user_input) diff --git a/typeconversion.py b/typeconversion.py new file mode 100644 index 00000000..2c6a96a3 --- /dev/null +++ b/typeconversion.py @@ -0,0 +1,18 @@ +# Sno 3 : "Type Conversion and validation examples: Implement a Python program to type conversion and validation examples" + +#conversion of tuple to list +tuple=(1,2,3,4,5) +list1=list(tuple) +print("conversion of tuple to list",list1) +#conversion of int to float +a=22 +print("conversion of int to float",float(a)) +#conversion of float to int +b=33.0 +print("conversion of float to int",int(b)) +#int to string conversion +c=7888 +print("int to string conversion",str(c)) +#string len to float +s="swe" +print("string to float",float(len(s))) \ No newline at end of file