Tihsrah-CD commited on
Commit
82c141f
1 Parent(s): 46af2a8

maybe last

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -10,6 +10,19 @@ from pyphonetics import RefinedSoundex
10
  from bs4 import BeautifulSoup
11
  import re
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  def closest_match(word, vocabulary):
14
  best_match = None
15
  best_distance = float('inf')
@@ -191,5 +204,9 @@ def main():
191
  st.write("Hinglish -> Hindi Transliterated String:", conversion_list)
192
  st.write("Hindi -> English Translated String:", translated)
193
 
 
 
 
 
194
  if __name__ == '__main__':
195
  main()
 
10
  from bs4 import BeautifulSoup
11
  import re
12
 
13
+
14
+ # Load sentiment analysis model and tokenizer
15
+ tokenizer = AutoTokenizer.from_pretrained("Seethal/sentiment_analysis_generic_dataset")
16
+ model = AutoModelForSequenceClassification.from_pretrained("Seethal/sentiment_analysis_generic_dataset")
17
+
18
+ # Define a function to get the sentiment from the model
19
+ def get_sentiment(text):
20
+ inputs = tokenizer(text, return_tensors='pt', truncation=True, padding=True)
21
+ outputs = model(**inputs)
22
+ sentiment = torch.argmax(outputs.logits, dim=1).item()
23
+ return 'Positive' if sentiment == 1 else 'Negative'
24
+
25
+
26
  def closest_match(word, vocabulary):
27
  best_match = None
28
  best_distance = float('inf')
 
204
  st.write("Hinglish -> Hindi Transliterated String:", conversion_list)
205
  st.write("Hindi -> English Translated String:", translated)
206
 
207
+ # Get the sentiment of the translated text
208
+ sentiment = get_sentiment(translated[0])
209
+ st.write("Sentiment of Translated Text:", sentiment)
210
+
211
  if __name__ == '__main__':
212
  main()