cdcvd commited on
Commit
d054022
·
verified ·
1 Parent(s): aeb2f96

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -62,27 +62,34 @@ def compare_skills(skill_1, skill_2):
62
 
63
  return score, common_skill
64
 
65
- def extract_ner_info(text, nlp):
66
  ner_results = nlp(text)
67
  full_name = ''
68
  loc = ''
69
  age = None
70
-
71
- for i in range(len(ner_results)):
 
72
  if ner_results[i]['entity'] == 'B-pers':
73
- full_name = ner_results[i]['word']
74
- for j in range(i+1, len(ner_results)):
 
 
75
  if ner_results[j]['entity'].startswith('I-pers'):
76
  full_name += ner_results[j]['word'].replace('##', '')
 
77
  else:
78
  break
79
-
80
  if ner_results[i]['entity'] == 'I-fac' and not loc:
81
  loc = ner_results[i]['word']
82
-
 
83
  age_match = re.search(r'سن\s*:\s*(\d+)', text)
84
  if age_match:
85
  age = int(age_match.group(1))
 
 
86
 
87
  return full_name, loc, age
88
 
@@ -181,7 +188,7 @@ deep learning
181
 
182
  # نمره‌دهی لوکیشن
183
  fixed_loc = "شیراز"
184
- loc_score = 100 if loc == fixed_loc else 0
185
 
186
  # نمره‌دهی سن
187
  age_score = 100 if age and 18 <= age <= 30 else 0
 
62
 
63
  return score, common_skill
64
 
65
+ def extract_ner_info(text, nlp, fixed_loc):
66
  ner_results = nlp(text)
67
  full_name = ''
68
  loc = ''
69
  age = None
70
+ # جمع‌آوری قطعات B-pers و I-pers برای تشکیل نام کامل
71
+ i = 0
72
+ while i < len(ner_results):
73
  if ner_results[i]['entity'] == 'B-pers':
74
+ if full_name: # اگر قبلاً نامی پیدا کرده‌ایم، فاصله اضافه کن
75
+ full_name += ' '
76
+ full_name += ner_results[i]['word']
77
+ for j in range(i + 1, len(ner_results)):
78
  if ner_results[j]['entity'].startswith('I-pers'):
79
  full_name += ner_results[j]['word'].replace('##', '')
80
+ i = j # به موقعیت جدید برو
81
  else:
82
  break
83
+ # جمع‌آوری قطعات I-fac برای مکان
84
  if ner_results[i]['entity'] == 'I-fac' and not loc:
85
  loc = ner_results[i]['word']
86
+ i += 1
87
+ # استخراج سن از متن
88
  age_match = re.search(r'سن\s*:\s*(\d+)', text)
89
  if age_match:
90
  age = int(age_match.group(1))
91
+ # بررسی امتیاز شباهت مکان
92
+
93
 
94
  return full_name, loc, age
95
 
 
188
 
189
  # نمره‌دهی لوکیشن
190
  fixed_loc = "شیراز"
191
+ loc_score = 100 if fixed_loc in loc else 0
192
 
193
  # نمره‌دهی سن
194
  age_score = 100 if age and 18 <= age <= 30 else 0