siddhantuniyal commited on
Commit
233accc
1 Parent(s): 33e6676

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -0
app.py CHANGED
@@ -3,6 +3,8 @@ import gradio as gr
3
  from nltk.sentiment.vader import SentimentIntensityAnalyzer
4
  import nltk
5
  nltk.download('vader_lexicon')
 
 
6
 
7
  zero_shot_classifier = pipeline("zero-shot-classification" , model='roberta-large-mnli')
8
 
@@ -13,6 +15,11 @@ issues = ["Misconduct" , "Negligence" , "Discrimination" , "Corruption" , "Viola
13
 
14
  apprecn = ["Tech-Savvy Staff" , "Co-operative Staff" , "Well-Maintained Premises" , "Responsive Staff"]
15
 
 
 
 
 
 
16
  def spam_detection(input_text):
17
 
18
  return spam_detector(input_text)[0]['label'] == 'clean'
@@ -43,6 +50,8 @@ def negative_zero_shot(input_text):
43
  return zero_shot_classifier(input_text , candidate_labels = issues , multi_label = False)['labels'][0]
44
 
45
  def pipeline(input_text):
 
 
46
 
47
  if spam_detection(input_text):
48
 
 
3
  from nltk.sentiment.vader import SentimentIntensityAnalyzer
4
  import nltk
5
  nltk.download('vader_lexicon')
6
+ from deep_translator import (GoogleTranslator)
7
+ from langdetect import detect
8
 
9
  zero_shot_classifier = pipeline("zero-shot-classification" , model='roberta-large-mnli')
10
 
 
15
 
16
  apprecn = ["Tech-Savvy Staff" , "Co-operative Staff" , "Well-Maintained Premises" , "Responsive Staff"]
17
 
18
+ def translate(input_text):
19
+ source_lang = detect(input_text)
20
+ translated = GoogleTranslator(source=source_lang, target='en').translate(text=input_text)
21
+ return translated
22
+
23
  def spam_detection(input_text):
24
 
25
  return spam_detector(input_text)[0]['label'] == 'clean'
 
50
  return zero_shot_classifier(input_text , candidate_labels = issues , multi_label = False)['labels'][0]
51
 
52
  def pipeline(input_text):
53
+
54
+ input_text = translate(input_text)
55
 
56
  if spam_detection(input_text):
57