Repository navigation
Expand file tree
/
Copy pathtext_analysis.py
More file actions
76 lines (64 loc) · 2.5 KB
/
Copy pathtext_analysis.py
File metadata and controls
76 lines (64 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import jieba
import jieba.analyse
from sklearn.feature_extraction.text import TfidfVectorizer
from typing import Dict, List
import requests
import json
class TextAnalyzer:
"""
文本分析模块
功能:
1. 简历分析
2. 面试回答内容分析
3. 结合大模型进行语义分析
"""
def __init__(self):
# 初始化TF-IDF
self.vectorizer = TfidfVectorizer(tokenizer=jieba.cut)
# 加载专业术语词典
self._load_technical_terms()
def analyze_resume(self, resume_text: str, position: str) -> Dict[str, float]:
"""
分析简历与岗位匹配度
:param resume_text: 简历文本
:param position: 岗位类型
:return: 匹配度分析结果
"""
# 提取关键词
keywords = jieba.analyse.extract_tags(resume_text, topK=20, withWeight=True)
# 计算与岗位的匹配度
match_score = self._calculate_position_match(keywords, position)
return {
"keywords": [kw[0] for kw in keywords],
"match_score": match_score,
"technical_term_count": self._count_technical_terms(resume_text)
}
def analyze_answer_quality(self, answer_text: str) -> Dict[str, float]:
"""
分析回答质量
:param answer_text: 回答文本
:return: 质量分析结果
"""
# 使用大模型API进行语义分析
analysis_result = self._call_llm_api(answer_text)
return {
"logical_score": analysis_result.get("logical", 0.5),
"clarity_score": analysis_result.get("clarity", 0.5),
"depth_score": analysis_result.get("depth", 0.5),
"star_structure": analysis_result.get("star", False)
}
def _load_technical_terms(self):
"""加载专业术语词典"""
# 这里应加载各领域的专业术语
pass
def _calculate_position_match(self, keywords, position) -> float:
"""计算简历与岗位匹配度"""
# 这里应实现匹配度计算逻辑
return 0.8
def _count_technical_terms(self, text) -> int:
"""统计专业术语数量"""
return len([word for word in jieba.cut(text) if word in self.technical_terms])
def _call_llm_api(self, text) -> Dict:
"""调用大模型API进行语义分析"""
# 这里应实现API调用逻辑
return {"logical": 0.7, "clarity": 0.8, "depth": 0.6, "star": False}