A-Duss commited on
Commit
c978338
1 Parent(s): f59c7b5

add shitsu

Browse files
Files changed (2) hide show
  1. app.py +35 -3
  2. requirements.txt +1 -0
app.py CHANGED
@@ -1,7 +1,39 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  demo.launch()
 
1
  import gradio as gr
2
+ from shitsu import ShitsuScorer
3
 
 
 
4
 
5
+ text_list = [
6
+ "Photosynthesis is a system of biological processes by which photosynthetic organisms, such as most plants, algae, and cyanobacteria, convert light energy, typically from sunlight, into the chemical energy necessary to fuel their metabolism.",
7
+ "Congratulations! You have all been selected to receive a free gift card worth $1000. Click on this link [Link] to claim your reward now. Limited time offer, so act fast! Don't miss out on this amazing opportunity."]
8
+
9
+ # Choose a language from one of: 'am', 'ar', 'bg', 'bn', 'cs', 'da', 'de', 'el', 'en', 'es', 'fa', 'fi', 'fr', 'gu', 'ha', 'hi', 'hu', 'id', 'it', 'ja', 'jv', 'kn', 'ko', 'lt', 'mr', 'nl', 'no', 'yo', 'zh'
10
+ language_code = "en"
11
+ scorer = ShitsuScorer(language_code)
12
+ scores = scorer.score(text_list)
13
+ print(scores)
14
+ # array([ 0.9897383 , -0.08109612], dtype=float32)
15
+
16
+ def get_score(user_text, language_code):
17
+ scorer = ShitsuScorer(language_code)
18
+ scores = scorer.score(user_text)
19
+ return scores[0]
20
+
21
+ language_options = ['am', 'ar', 'bg', 'bn', 'cs', 'da', 'de', 'el', 'en', 'es', 'fa', 'fi', 'fr', 'gu', 'ha', 'hi', 'hu', 'id', 'it', 'ja', 'jv', 'kn', 'ko', 'lt', 'mr', 'nl', 'no', 'yo', 'zh']
22
+
23
+ with gr.Blocks() as demo:
24
+ with gr.Row():
25
+ user_text = gr.Textbox(label='Input text...')
26
+ submit_btn = gr.Button("Submit", scale=0)
27
+ # Searchable dropdown to choose language
28
+ language_choice = gr.Dropdown(
29
+ choices=language_options,
30
+ label="Choose a language",
31
+ info="Type to search",
32
+ allow_custom_value=True, # Allows typing to search
33
+ )
34
+ score = gr.Number(label="Result")
35
+
36
+ user_text.submit(get_score, inputs=[user_text, language_choice], outputs=[score])
37
+ submit_btn.click(get_score, inputs=[user_text, language_choice], outputs=[score])
38
+
39
  demo.launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ git+https://github.com/lightblue-tech/shitsu.git