File size: 1,141 Bytes
cae88e7
04f4d48
 
9d859d6
cae88e7
 
 
 
 
 
 
 
 
 
 
b9ae502
cae88e7
 
 
 
68e6456
cae88e7
 
 
 
 
 
 
9d859d6
 
 
 
 
 
 
cae88e7
efad4ba
cae88e7
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
36
37
38
import gradio as gr
from googletrans import Translator
from textblob import TextBlob

def analyze(sentence):
    # Create a Translator object
    translator = Translator()
    
    # Translate the sentence from Japanese to English
    translation = translator.translate(sentence, src='ja', dest='en')
    
    # The translated sentence
    en_sentence = translation.text

    # Create a TextBlob object for the sentence
    blob = TextBlob(en_sentence)
    
    # Get the polarity score for the sentence
    polarity_score = blob.sentiment.polarity
    
    # ポラγƒͺティーーーーーー!
    if polarity_score > 0:
        return ("ポジティブ。あい぀はポジティブ。ガス欠とかするγͺ。ポジティブ。")
    elif polarity_score == 0:
        return ("-_-")
    else:
        return ("ηΈ¦η·šγ‚’δΊŒζœ¬δΈŠγ’γ‚‹γ‚ˆγ€‚γγ‚Œγ‚’δ½Ώγ£γŸγ‚‰γƒγ‚¬γƒ†γ‚£γƒ–γ§γ‚‚γƒγ‚Έγƒ†γ‚£γƒ–γ«γͺる。")

def func(sentence):
    try:
        result = analyze(sentence)
    except Exception as e:
        return str(e)
    else:
        return result

iface = gr.Interface(fn=func, inputs="text", outputs="text")
iface.launch()