cdcvd commited on
Commit
3c7517e
·
verified ·
1 Parent(s): 7c0115f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -3,6 +3,7 @@ import re
3
  import json
4
  from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
5
  import gradio as gr
 
6
 
7
  def read_from_excel(file_path):
8
  df = pd.read_excel(file_path)
@@ -199,13 +200,16 @@ def process_text(input_text):
199
  "common_education": list(common_education),
200
  "common_skills": list(common_skills)
201
  }
202
-
203
- return json.dumps(output, ensure_ascii=False, indent=4)
 
 
 
204
 
205
  iface = gr.Interface(
206
  fn=process_text,
207
  inputs=gr.Textbox(lines=10, placeholder="لطفاً متن خود را وارد کنید..."),
208
- outputs="json",
209
  title="متن پرداز",
210
  description="این ابزار متن شما را پردازش کرده و امتیازات مشابهت را محاسبه می‌کند."
211
  )
 
3
  import json
4
  from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
5
  import gradio as gr
6
+ import tempfile
7
 
8
  def read_from_excel(file_path):
9
  df = pd.read_excel(file_path)
 
200
  "common_education": list(common_education),
201
  "common_skills": list(common_skills)
202
  }
203
+
204
+ # ذخیره خروجی JSON در یک فایل موقت
205
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".json", mode='w', encoding='utf-8') as tmp_file:
206
+ json.dump(output, tmp_file, ensure_ascii=False, indent=4)
207
+ return tmp_file.name
208
 
209
  iface = gr.Interface(
210
  fn=process_text,
211
  inputs=gr.Textbox(lines=10, placeholder="لطفاً متن خود را وارد کنید..."),
212
+ outputs=gr.File(label="دانلود فایل JSON"),
213
  title="متن پرداز",
214
  description="این ابزار متن شما را پردازش کرده و امتیازات مشابهت را محاسبه می‌کند."
215
  )