Dragonanta67 commited on
Commit
6ecd3d8
·
verified ·
1 Parent(s): 743dbfc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -21
app.py CHANGED
@@ -77,7 +77,7 @@ def analyze_education(text):
77
 
78
  def analyze_skills(text):
79
  technical_skills = ['python', 'java', 'javascript', 'c++', 'sql', 'machine learning',
80
- 'data analysis', 'excel', 'powerpoint', 'word', 'project management']
81
  found_skills = [skill for skill in technical_skills if skill.lower() in text.lower()]
82
  return min(len(found_skills) * 3, 20), ', '.join(found_skills) or 'Nav atrasts'
83
 
@@ -128,11 +128,11 @@ def generate_candidate_description(name, experience, education, skills, language
128
  def analyze_cv(file):
129
  if file is None:
130
  return "⚠️ Lūdzu, augšupielādējiet CV failu!"
131
-
132
  try:
133
  file_name = file.name
134
  ext = file_name.split('.')[-1].lower()
135
-
136
  if ext == 'pdf':
137
  text = extract_text_from_pdf(file)
138
  elif ext == 'docx':
@@ -141,19 +141,18 @@ def analyze_cv(file):
141
  text = extract_text_from_txt(file)
142
  else:
143
  return "❌ Neatbalstīts faila formāts! Atbalstītie: PDF, DOCX, TXT"
144
-
145
- # AR NER!
146
  name = extract_name_with_ner(text)
147
  email = extract_email(text)
148
  phone = extract_phone(text)
149
-
150
  exp_score, experience = analyze_experience(text)
151
  edu_score, education = analyze_education(text)
152
  skill_score, skills = analyze_skills(text)
153
  lang_score, languages = analyze_languages(text)
154
-
155
  total = exp_score + edu_score + skill_score + lang_score
156
-
157
 
158
  # Ģenerē aprakstu par kandidātu
159
  candidate_description = generate_candidate_description(name, experience, education, skills, languages)
@@ -168,7 +167,7 @@ def analyze_cv(file):
168
  🎓 Izglītība: {edu_score}/30 ({education})
169
  💻 Prasmes: {skill_score}/20 ({skills})
170
  🌐 Valodas: {lang_score}/20 ({languages})
171
-
172
  except Exception as e:
173
  return f"❌ Kļūda apstrādājot failu: {str(e)}"
174
 
@@ -177,24 +176,16 @@ demo = gr.Interface(
177
  fn=analyze_cv,
178
  inputs=gr.File(label="Ielādējiet CV failu", file_types=['.pdf', '.docx', '.txt']),
179
  outputs=gr.Textbox(label="Analīzes rezultāti", lines=25),
180
- Augšupielādējiet CV failu (PDF, DOCX vai TXT), un sistēma automatīski analizēs:
181
-
182
- - 🧑 Personīgo informāciju
183
- - 💼 Darba pieredzi
184
- - 🎓 Izglītību
185
- - 🌐 Valodu prasmes
186
- - 📦 Tehniskās prasmes
187
-
188
- **Rezultāti tiek vērtēti 100 punktu skalā**
189
- """,
190
- - 👤 Personīgo informāc
191
  - 💼 Darba pieredzi
192
  - 🎓 Izglītību
193
  - 🌐 Valodu prasmes
194
  - 📚 Tehniskās prasmes
195
 
196
  **Rezultāti tiek vērtēti 100 punktu skalā**
197
-
198
  )
199
 
200
  if __name__ == "__main__":
 
77
 
78
  def analyze_skills(text):
79
  technical_skills = ['python', 'java', 'javascript', 'c++', 'sql', 'machine learning',
80
+ 'data analysis', 'excel', 'powerpoint', 'word', 'project management']
81
  found_skills = [skill for skill in technical_skills if skill.lower() in text.lower()]
82
  return min(len(found_skills) * 3, 20), ', '.join(found_skills) or 'Nav atrasts'
83
 
 
128
  def analyze_cv(file):
129
  if file is None:
130
  return "⚠️ Lūdzu, augšupielādējiet CV failu!"
131
+
132
  try:
133
  file_name = file.name
134
  ext = file_name.split('.')[-1].lower()
135
+
136
  if ext == 'pdf':
137
  text = extract_text_from_pdf(file)
138
  elif ext == 'docx':
 
141
  text = extract_text_from_txt(file)
142
  else:
143
  return "❌ Neatbalstīts faila formāts! Atbalstītie: PDF, DOCX, TXT"
144
+
 
145
  name = extract_name_with_ner(text)
146
  email = extract_email(text)
147
  phone = extract_phone(text)
148
+
149
  exp_score, experience = analyze_experience(text)
150
  edu_score, education = analyze_education(text)
151
  skill_score, skills = analyze_skills(text)
152
  lang_score, languages = analyze_languages(text)
153
+
154
  total = exp_score + edu_score + skill_score + lang_score
155
+
156
 
157
  # Ģenerē aprakstu par kandidātu
158
  candidate_description = generate_candidate_description(name, experience, education, skills, languages)
 
167
  🎓 Izglītība: {edu_score}/30 ({education})
168
  💻 Prasmes: {skill_score}/20 ({skills})
169
  🌐 Valodas: {lang_score}/20 ({languages})
170
+ """
171
  except Exception as e:
172
  return f"❌ Kļūda apstrādājot failu: {str(e)}"
173
 
 
176
  fn=analyze_cv,
177
  inputs=gr.File(label="Ielādējiet CV failu", file_types=['.pdf', '.docx', '.txt']),
178
  outputs=gr.Textbox(label="Analīzes rezultāti", lines=25),
179
+ title="📄 CV Automatīskās Analīzes Sistēma",
180
+ description="""Augšupielādējiet CV failu (PDF, DOCX vai TXT), un sistēma automatīski analizēs:
181
+ - 👤 Personīgo informāciju
 
 
 
 
 
 
 
 
182
  - 💼 Darba pieredzi
183
  - 🎓 Izglītību
184
  - 🌐 Valodu prasmes
185
  - 📚 Tehniskās prasmes
186
 
187
  **Rezultāti tiek vērtēti 100 punktu skalā**
188
+ """
189
  )
190
 
191
  if __name__ == "__main__":