max-long commited on
Commit
cbccbc9
·
verified ·
1 Parent(s): d7740e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -94,18 +94,18 @@ with gr.Blocks(title="Textile Machinery NER Demo") as demo:
94
  refresh_btn = gr.Button("Get New Snippet")
95
 
96
  def get_new_snippet():
97
- attempts = 0
98
- max_attempts = 1000 # Prevent infinite loops
99
- while attempts < max_attempts:
100
- try:
101
- sample = next(dataset_iter)
102
- title = sample.get('title', '')
103
- if title and 'textile' in title.lower():
104
- return title
105
- attempts += 1
106
- except StopIteration:
107
- break
108
- return "No more snippets available."
109
 
110
  # Connect refresh button
111
  refresh_btn.click(fn=get_new_snippet, outputs=input_text)
 
94
  refresh_btn = gr.Button("Get New Snippet")
95
 
96
  def get_new_snippet():
97
+ attempts = 0
98
+ max_attempts = 1000 # Prevent infinite loops
99
+ while attempts < max_attempts:
100
+ try:
101
+ sample = next(dataset_iter)
102
+ title = sample.get('title', '')
103
+ if title and 'textile' in title.lower():
104
+ return title
105
+ attempts += 1
106
+ except StopIteration:
107
+ break
108
+ return "No more snippets available."
109
 
110
  # Connect refresh button
111
  refresh_btn.click(fn=get_new_snippet, outputs=input_text)