Uniaff commited on
Commit
ea6fb88
1 Parent(s): 2311bcb

Update func_ai.py

Browse files
Files changed (1) hide show
  1. func_ai.py +4 -3
func_ai.py CHANGED
@@ -1,12 +1,13 @@
1
  import requests
2
  import torch
3
- from googletrans import Translator
4
  from transformers import pipeline
 
5
  import time
6
  import os
7
  VECTOR_API_URL = os.getenv('API_URL')
8
 
9
- translator = Translator()
10
 
11
 
12
  sentiment_model = pipeline(
@@ -26,7 +27,7 @@ classifier = pipeline(
26
 
27
 
28
  def classify_comment(text):
29
- translated_text = translator.translate(text, dest='en').text
30
  result = classifier(translated_text, ["interrogative", "non-interrogative"], clean_up_tokenization_spaces=True)
31
  top_class = result['labels'][0]
32
  return top_class
 
1
  import requests
2
  import torch
3
+ # from googletrans import Translator
4
  from transformers import pipeline
5
+ from deep_translator import GoogleTranslator
6
  import time
7
  import os
8
  VECTOR_API_URL = os.getenv('API_URL')
9
 
10
+ # translator = Translator()
11
 
12
 
13
  sentiment_model = pipeline(
 
27
 
28
 
29
  def classify_comment(text):
30
+ translated_text = GoogleTranslator(source='auto', target=target_language).translate(text)
31
  result = classifier(translated_text, ["interrogative", "non-interrogative"], clean_up_tokenization_spaces=True)
32
  top_class = result['labels'][0]
33
  return top_class