//根据简历对象获得最合适的前五个岗位 public List <Recommend> GetMatchingResultsByResume(Resume resume, List <Post> posts) { matchingResults.Clear(); //获得post的需要测试的所有tf idf var resumeMap = GetResumeTf_Idf(resume); foreach (var post in posts) { var result = getMatchingResultByResume(post, resumeMap); matchingResults.Add(result); } var i = 0; matchingResults.Sort((r1, r2) => r2.RecommendNumber.CompareTo(r1.RecommendNumber)); var relayResults = new List <Recommend>(); foreach (var result in matchingResults) { i++; if (i > 5) { break; } result.ResumeId = resume.resumeId; relayResults.Add(result); } return(relayResults); }
//获得一个岗位和一个简历的匹配程度 private Recommend getMatchingResultByPost(Resume resume, Dictionary <string, IEnumerable <WordWeightPair> > post) { var recommend = new Recommend(); if (resume == null || post == null) { return(recommend); } //获得地点是否匹配 var addr = Similarity(resume.familyAddress + resume.resumeWorkPlace, post["addr"]); addr = addr > 0 ? addr : 0; // Console.Write("1"); // 获得职位是否匹配 var job = Similarity(resume.resumePostName, post["PostName"]); job = job > 0 ? job : 0; // Console.Write("2"); //获得工作年限匹配 var exTime = Similarity(resume.workYear, post["PostExperience"]); exTime = exTime > 0 ? exTime : 0; // Console.Write("3"); //获得岗位职责和个人信息匹配度 var info = Similarity(resume.resumeExperience, post["PostDescription"]); info = info > 0 ? info : 0; // Console.Write("4"); //技能匹配度 var skill = Similarity(resume.skill, post["PostDescription"]); skill = skill > 0 ? skill : 0; // Console.Write("5"); //学历匹配度 var academic = Similarity(resume.academic, post["AcademicRequirements"]); academic = academic > 0 ? academic : 0; // Console.Write("6"); //最终匹配结果 var result = addr + exTime + academic + job * 2 + info * 2 + skill * 3.5; recommend.ResumeId = resume.resumeId; recommend.RecommendNumber = result; return(recommend); }
//获得resume的需要测试的所有tf——idf private Dictionary <string, IEnumerable <WordWeightPair> > GetResumeTf_Idf(Resume resume) { var map = new Dictionary <string, IEnumerable <WordWeightPair> >(); //获得地点 map["addr"] = extractor.ExtractTagsWithWeight(resume.familyAddress + resume.resumeWorkPlace, 200); //获得职位 map["resumePostName"] = extractor.ExtractTagsWithWeight(resume.resumePostName, 200); //获得工作年限 map["workYear"] = extractor.ExtractTagsWithWeight(resume.workYear, 200); //获得岗位职责和个人信息 map["resumeExperience"] = extractor.ExtractTagsWithWeight(resume.resumeExperience, 200); //技能 map["skill"] = extractor.ExtractTagsWithWeight(resume.skill, 200); //学历 map["academic"] = extractor.ExtractTagsWithWeight(resume.academic, 200); return(map); }
public ActionResult <string> Post([FromBody] Resume input) { if (!ModelState.IsValid) { return(BadRequest()); } DataSet allPosts = productRepository.GetPosts(); list = DataSetToList <Post>(allPosts, 0); //DataSet allResumes = productRepository.GetResumes(); //lists = DataSetToList<Resume>(allResumes, 0); // foreach (var resume in lists) // { // finalResult = calculate.GetMatchingResultsByResume(resume, list); // Console.WriteLine("简历信息:期望职位名:{0},期望薪资:{1},工作经验年限:{2},技能:{3}", resume.resumePostName, //resume.resumeSalary, //resume.workYear, resume.skill); // foreach (var recommend in finalResult) // { // var post = _iPostService.GetById(recommend.PostId); // Console.WriteLine("职位信息:职位名:{0},薪资:{1},工作经验年限要求:{2},职位描述:{3}", post.PostName, post.PostSalary, // post.PostExperience, post.PostDescription); // Console.WriteLine("----------------"); // } // } //foreach (var post in list) //{ // finalResult = calculate.GetMatchingResultsByPost(lists, post); // Console.WriteLine("职位信息:职位名:{0},薪资:{1},工作经验年限要求:{2},职位描述:{3}", post.PostName, post.PostSalary, // post.PostExperience, post.PostDescription); // foreach (var recommend in finalResult) // { // Console.WriteLine("----------------"); // var resume = _resumeService.GetById(recommend.ResumeId); // Console.WriteLine("简历信息:期望职位名:{0},期望薪资:{1},工作经验年限:{2},技能:{3}", resume.ResumePostName, // resume.ResumeSalary, // resume.WorkYear, resume.Skill); // } //} finalResult = calculate.GetMatchingResultsByResume(input, list); foreach (var recommend in finalResult) { Recommend recommends = new Recommend { ResumeId = recommend.ResumeId, PostId = recommend.PostId, CompanyId = recommend.CompanyId, RecommendNumber = recommend.RecommendNumber }; _iRecommendService.Create(recommends, recommends.PostId, recommends.ResumeId); } return(Output("ok", 5)); }