A-Duss commited on
Commit
88abc31
·
1 Parent(s): 635f231

Added examples

Browse files
Files changed (1) hide show
  1. app.py +27 -4
app.py CHANGED
@@ -3,6 +3,23 @@ from shitsu import ShitsuScorer
3
 
4
  scorer = ShitsuScorer('en')
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  def get_score(user_text):
7
  score = scorer.score([user_text])[0]
8
  yield f'<div class="nice-box"> Score: {score}</div>'
@@ -37,27 +54,31 @@ theme = gr.themes.Soft(
37
  secondary_hue="sky",
38
  )
39
 
40
-
41
  with gr.Blocks(theme=theme, css=css) as demo:
42
 
43
  title = gr.HTML(
44
- """<h1><img src="https://huggingface.co/spaces/Dusduo/shitsu-text-scorer-demo/shitsu-logo.jpeg" alt="LightBlue"> Shitsu Text Scorer</h1>""",
45
  elem_id="title",
46
  )
47
  gr.Markdown(
48
- """This is a demo of [Shitsu text scorer](https://huggingface.co/lightblue/shitsu_text_scorer) which scores text based on the amount of useful, textbook-like information in it.
49
 
50
  It outputs a score generally between 0 and 1 but can exceed both of these bounds as it is a regressor.
51
  """
52
  )
53
  with gr.Row():
54
- user_text = gr.Textbox(label='Input text...')
55
  with gr.Column(scale=0):
56
  submit_btn = gr.Button("Submit")
57
  score = gr.HTML(
58
  value='<div class="nice-box"> Score... </div>',
59
  label="Output"
60
  )
 
 
 
 
61
  # Searchable dropdown to choose language
62
  # language_choice = gr.Dropdown(
63
  # choices=language_options,
@@ -75,6 +96,8 @@ with gr.Blocks(theme=theme, css=css) as demo:
75
  This model can also be found on [Github](https://github.com/lightblue-tech/shitsu) and has its own pip installable package.
76
  """
77
  )
 
 
78
  user_text.submit(get_score, inputs=[user_text], outputs=[score])
79
  submit_btn.click(get_score, inputs=[user_text], outputs=[score])
80
 
 
3
 
4
  scorer = ShitsuScorer('en')
5
 
6
+ example_inputs = [
7
+ "Photosynthesis is the process by which green plants and some other organisms use sunlight to synthesize foods with the help of chlorophyll. It involves the intake of carbon dioxide and water and produces glucose and oxygen as by-products.",
8
+ "Hey, how was your day? Did you manage to finish that project you were working on?",
9
+ "In economics, the law of supply and demand describes the relationship between the availability of a particular product and the desire for that product. When supply increases, prices tend to drop, and when demand increases, prices tend to rise.",
10
+ "The Pythagorean theorem is a fundamental relation in Euclidean geometry among the three sides of a right triangle. It states that the square of the hypotenuse is equal to the sum of the squares of the other two sides.",
11
+ "Hey, do you want to grab coffee later? There's a new café that opened downtown.",
12
+ "Newton's second law of motion states that the acceleration of an object is directly proportional to the net force acting on the object and inversely proportional to the object's mass. The formula for this is F = ma.",
13
+ "The Beatles were a popular band in the 1960s. They released many hit songs.",
14
+ "In computer science, an algorithm is a finite sequence of well-defined instructions, typically used to solve a class of problems or perform a computation. Algorithms are essential to the functioning of modern software systems.",
15
+ "Chocolate is a type of sweet food that people often eat for dessert.",
16
+ "I'm thinking of going to the beach this weekend. The weather is supposed to be great!",
17
+ "Quantum mechanics is a fundamental theory in physics that provides a description of the physical properties of nature at the scale of atoms and subatomic particles.",
18
+ "I saw a great movie last night. You should check it out if you get a chance.",
19
+ "The mitochondrion is known as the powerhouse of the cell because it generates most of the cell's supply of adenosine triphosphate (ATP), used as a source of chemical energy.",
20
+ "Can you believe it's already September? This year is flying by!"
21
+ ]
22
+
23
  def get_score(user_text):
24
  score = scorer.score([user_text])[0]
25
  yield f'<div class="nice-box"> Score: {score}</div>'
 
54
  secondary_hue="sky",
55
  )
56
 
57
+ #"https://huggingface.co/spaces/Dusduo/shitsu-text-scorer-demo/shitsu-logo.jpeg"
58
  with gr.Blocks(theme=theme, css=css) as demo:
59
 
60
  title = gr.HTML(
61
+ """<h1><img src="file=shitsu-logo.jpeg" alt="LightBlue"> Shitsu Text Scorer</h1>""",
62
  elem_id="title",
63
  )
64
  gr.Markdown(
65
+ """This is a demo of [Shitsu text scorer](https://huggingface.co/lightblue/shitsu_text_scorer) for English, which scores text based on the amount of useful, textbook-like information in it.
66
 
67
  It outputs a score generally between 0 and 1 but can exceed both of these bounds as it is a regressor.
68
  """
69
  )
70
  with gr.Row():
71
+ user_text = gr.Textbox(label='Input text', placeholder='Type something here...')
72
  with gr.Column(scale=0):
73
  submit_btn = gr.Button("Submit")
74
  score = gr.HTML(
75
  value='<div class="nice-box"> Score... </div>',
76
  label="Output"
77
  )
78
+
79
+ # Add examples to the textbox
80
+ gr.Examples(examples=example_inputs, inputs=user_text)
81
+
82
  # Searchable dropdown to choose language
83
  # language_choice = gr.Dropdown(
84
  # choices=language_options,
 
96
  This model can also be found on [Github](https://github.com/lightblue-tech/shitsu) and has its own pip installable package.
97
  """
98
  )
99
+
100
+ # Set up the user submit events
101
  user_text.submit(get_score, inputs=[user_text], outputs=[score])
102
  submit_btn.click(get_score, inputs=[user_text], outputs=[score])
103