simonschoe commited on
Commit
1ca1b3a
1 Parent(s): 53801b0

update app

Browse files
Files changed (1) hide show
  1. app.py +24 -20
app.py CHANGED
@@ -17,9 +17,10 @@ def classify(_input):
17
  wrapper method to compute label 1 probability and explanation for given input
18
  """
19
  result = classifier(_input)[0]
20
- score = result['score']
 
21
  if result['label'] == 'LABEL_0':
22
- score = 1-score
23
 
24
  # getting visualization
25
  attributions = explainer(_input)
@@ -34,8 +35,12 @@ def classify(_input):
34
  app = gr.Blocks()
35
 
36
  with app:
37
- gr.Markdown("# Transformation Intensity Classifier")
38
- gr.Markdown("## Detect Transformation Sentences in Quarterly Earnings Conference Calls")
 
 
 
 
39
  with gr.Row():
40
  with gr.Column():
41
  text_in = gr.Textbox(lines=1, placeholder="Insert text", label="Input Sentence")
@@ -43,11 +48,23 @@ with app:
43
  compute_bt = gr.Button("Classify")
44
  score_out = gr.Number(label="Score", interactive=False)
45
  html_out = gr.HTML(label="Explanation")
 
 
 
 
 
 
 
 
 
 
 
 
46
  with gr.Column():
47
  gr.Markdown(
48
  """
49
  #### Project Description
50
- Placeholder
51
  """
52
  )
53
  gr.Markdown(
@@ -58,17 +75,6 @@ with app:
58
  In addition, the app returns the tokenized version of the sentence, alongside word importances that are indicated by color codes. Those visuals illustrates the ability of the context-aware classifier to simultaneously pay attention to various parts in the input sentence to derive a final label.
59
  """
60
  )
61
- gr.Examples(
62
- examples=[
63
- ["If we look at the plans for 2018, it is to introduce 650 new products, which is an absolute all- time high."],
64
- ["We have been doing kind of an integrated campaign, so it's TV, online, we do the Google Ad Words - all those different elements together."],
65
- ["So that turned out to be beneficial for us, and I think, we'll just see how the market and interest rates move over the course of the year,"]
66
- ],
67
- inputs=[text_in],
68
- outputs=[score_out, html_out],
69
- fn=classify,
70
- cache_examples=True
71
- )
72
  gr.Markdown(
73
  """
74
  <p style="text-align: center;">
@@ -81,7 +87,5 @@ with app:
81
  compute_bt.click(classify, inputs=[text_in], outputs=[score_out, html_out])
82
 
83
 
84
- app.launch()
85
-
86
-
87
-
 
17
  wrapper method to compute label 1 probability and explanation for given input
18
  """
19
  result = classifier(_input)[0]
20
+ score = round(result['score'], 4)
21
+ print(score)
22
  if result['label'] == 'LABEL_0':
23
+ score = 1 - score
24
 
25
  # getting visualization
26
  attributions = explainer(_input)
 
35
  app = gr.Blocks()
36
 
37
  with app:
38
+ gr.Markdown(
39
+ """
40
+ # Transformation Talk Classifier
41
+ ## Detect Transformation-Related Sentences in Quarterly Earnings Calls
42
+ """
43
+ )
44
  with gr.Row():
45
  with gr.Column():
46
  text_in = gr.Textbox(lines=1, placeholder="Insert text", label="Input Sentence")
 
48
  compute_bt = gr.Button("Classify")
49
  score_out = gr.Number(label="Score", interactive=False)
50
  html_out = gr.HTML(label="Explanation")
51
+ gr.Examples(
52
+ examples=[
53
+ ["If we look at the plans for 2018, it is to introduce 650 new products, which is an absolute all- time high."],
54
+ ["We have been doing kind of an integrated campaign, so it's TV, online, we do the Google Ad Words - all those different elements together."],
55
+ ["So that turned out to be beneficial for us, and I think, we'll just see how the market and interest rates move over the course of the year,"]
56
+ ],
57
+ label="Examples (click to start detection)",
58
+ inputs=[text_in],
59
+ outputs=[score_out, html_out],
60
+ fn=classify,
61
+ cache_examples=True
62
+ )
63
  with gr.Column():
64
  gr.Markdown(
65
  """
66
  #### Project Description
67
+ Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
68
  """
69
  )
70
  gr.Markdown(
 
75
  In addition, the app returns the tokenized version of the sentence, alongside word importances that are indicated by color codes. Those visuals illustrates the ability of the context-aware classifier to simultaneously pay attention to various parts in the input sentence to derive a final label.
76
  """
77
  )
 
 
 
 
 
 
 
 
 
 
 
78
  gr.Markdown(
79
  """
80
  <p style="text-align: center;">
 
87
  compute_bt.click(classify, inputs=[text_in], outputs=[score_out, html_out])
88
 
89
 
90
+ if __name__ == "__main__":
91
+ app.launch()