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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -18
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import pandas as pd
2
  import re
 
3
  from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
4
  import gradio as gr
5
 
@@ -183,28 +184,28 @@ def process_text(input_text):
183
  # محاسبه و نمایش میانگین نمرات
184
  average_score = (job_score + education_score + skill_score + loc_score + age_score) / 5
185
 
186
- # ساخت خروجی به صورت متن
187
- output = f"""
188
- average_score: {average_score}
189
- full_name: {full_name}
190
- age: {age}
191
- location: {loc}
192
- job_score: {job_score}
193
- education_score: {education_score}
194
- skill_score: {skill_score}
195
- loc_score: {loc_score}
196
- age_score: {age_score}
197
- common_jobs: {list(common_jobs)}
198
- common_education: {list(common_education)}
199
- common_skills: {list(common_skills)}
200
- """
201
-
202
- return output
203
 
204
  iface = gr.Interface(
205
  fn=process_text,
206
  inputs=gr.Textbox(lines=10, placeholder="لطفاً متن خود را وارد کنید..."),
207
- outputs="text",
208
  title="متن پرداز",
209
  description="این ابزار متن شما را پردازش کرده و امتیازات مشابهت را محاسبه می‌کند."
210
  )
 
1
  import pandas as pd
2
  import re
3
+ import json
4
  from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
5
  import gradio as gr
6
 
 
184
  # محاسبه و نمایش میانگین نمرات
185
  average_score = (job_score + education_score + skill_score + loc_score + age_score) / 5
186
 
187
+ # ساخت خروجی JSON
188
+ output = {
189
+ "average_score": average_score,
190
+ "full_name": full_name,
191
+ "age": age,
192
+ "location": loc,
193
+ "job_score": job_score,
194
+ "education_score": education_score,
195
+ "skill_score": skill_score,
196
+ "loc_score": loc_score,
197
+ "age_score": age_score,
198
+ "common_jobs": list(common_jobs),
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
  )