yenniejun commited on
Commit
a90b5f0
Β·
1 Parent(s): 3033c0a

Fixing indents

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -8,6 +8,9 @@ HuggingFace Spaces that:
8
  # https://huggingface.co/blog/streamlit-spaces
9
  # https://huggingface.co/docs/hub/en/spaces-sdks-streamlit
10
 
 
 
 
11
  """
12
  import gradio as gr
13
  from string import punctuation
@@ -19,24 +22,24 @@ hanmun_roberta = gr.Interface.load("bdsl/HanmunRoBERTa")
19
 
20
 
21
  def inference(inputtext, model, strip_text):
22
- if strip_text:
23
- inputtext = strip_text(inputtext)
24
  if model == "HanmunRoBERTa":
25
  outlabel = hanmun_roberta(inputtext)
26
  return outlabel
27
 
28
  def strip_text(inputtext):
29
- characters_to_remove = "β—‹β–‘()〔〕:\"。·, ?ㆍ" + punctuation
30
- translating = str.maketrans('', '', characters_to_remove)
31
- return inputtext.translate(translating)
32
 
33
  gr.Interface(
34
  inference,
35
  [gr.inputs.Textbox(label="Input text",lines=10),
36
  gr.inputs.Dropdown(choices=["HanmunRoBERTa"],
37
- type="value",
38
- default="HanmunRoBERTa",
39
- label="model"),
40
  gr.inputs.Checkbox(label="Remove punctuation", value=True),
41
  ],
42
  [gr.outputs.Label(label="Output")],
 
8
  # https://huggingface.co/blog/streamlit-spaces
9
  # https://huggingface.co/docs/hub/en/spaces-sdks-streamlit
10
 
11
+ # https://www.gradio.app/docs/interface
12
+ # https://huggingface.co/spaces/docs-demos/roberta-base/blob/main/app.py
13
+
14
  """
15
  import gradio as gr
16
  from string import punctuation
 
22
 
23
 
24
  def inference(inputtext, model, strip_text):
25
+ if strip_text:
26
+ inputtext = strip_text(inputtext)
27
  if model == "HanmunRoBERTa":
28
  outlabel = hanmun_roberta(inputtext)
29
  return outlabel
30
 
31
  def strip_text(inputtext):
32
+ characters_to_remove = "β—‹β–‘()〔〕:\"。·, ?ㆍ" + punctuation
33
+ translating = str.maketrans('', '', characters_to_remove)
34
+ return inputtext.translate(translating)
35
 
36
  gr.Interface(
37
  inference,
38
  [gr.inputs.Textbox(label="Input text",lines=10),
39
  gr.inputs.Dropdown(choices=["HanmunRoBERTa"],
40
+ type="value",
41
+ default="HanmunRoBERTa",
42
+ label="model"),
43
  gr.inputs.Checkbox(label="Remove punctuation", value=True),
44
  ],
45
  [gr.outputs.Label(label="Output")],