简历解析步骤(第一步)技术与实现(1)识文字,取信息
继上篇文章理论:
简历解析,常见接收到的简历是图片或文档的方式,我们需要先将简历中的文字提取出来,然后再对文字进行算法分析以及AI训练,从而实现解析简历与提高解析度的效果。
先介绍我们整个解析过程和训练过程需要用到的技术:
- 文字识别:OCR服务(百度 AI 开放平台:通用文字识别)
- 算法(伪代码:不限语言)
- AI 机器学习 (ML.NET 或者 Python 一些算法库)
步骤: 第一步:通过文字识别的方式,提取出里面所有有价值的内容(可以转换的所有信息:因为本次讲解都是中文,所以接下来都以解析中文简历来作为例子)第二步:通过算法进行识别,找到符合要求的信息如:姓名、性别、年龄、学历、工作经历等。第三步:将识别出来的信息进行本地存储,然后通过人工去纠正错误,将该版本作为样板,交由机器学习算法进行学习运算,计算出模型。第四步:将得出来的模型再识别简历达到一定的量,再纠错,再交由机器学习算法进行学习运算,反复学习,直至通过率接近 100%。
步骤实现:
第一步:识文字,取信息
通过百度 AI 开放平台,识别文字,访问下面的网址,可以跳转到相关文档:
代码展示:
using System;
using System.Text;
using System.Web;
using System.IO;
using System.Net;
namespace ORCGO
{
public class Accurate
{
// 通用文字识别(高精度含位置版)
public static string accurate()
{
var photoAddress = @"C:\Users\dao\Desktop\简历.png";
return PhotoToString(photoAddress);
}
public static string PhotoToString(string photoAddress)
{
string token = "24.fd2856bffc593210817e8134b30be5b4.2592000.1637745382.282335-25050972";
string host = "https://aip.baidubce.com/rest/2.0/ocr/v1/accurate?access_token=" + token;
Encoding encoding = Encoding.Default;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(host);
request.Method = "post";
request.KeepAlive = true;
// 图片的base64编码
string base64 = getFileBase64(photoAddress);
String str = "image=" + HttpUtility.UrlEncode(base64);
byte[] buffer = encoding.GetBytes(str);
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, 0, buffer.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.Default);
string result = reader.ReadToEnd();
Console.WriteLine("通用文字识别(高精度含位置版):");
Console.WriteLine(result);
return result;
}
public static String getFileBase64(String fileName)
{
FileStream filestream = new FileStream(fileName, FileMode.Open);
byte[] arr = new byte[filestream.Length];
filestream.Read(arr, 0, (int)filestream.Length);
string baser64 = Convert.ToBase64String(arr);
filestream.Close();
return baser64;
}
}
}
调用这个类里面的方法,就可以了 PhotoToString
Program.cs
using System;
namespace ORCGO
{
class Program
{
static void Main(string[] args)
{
var photoAddress = @"C:\Users\dao\Desktop\简历.png";
Accurate.SBZP(photoAddress);
}
}
}
我们写一个简历
获得结果:
上面就是通过 百度AI 接口识别出来的信息,我们可以感受到准确度还是很高的。
需要源码的,评论区留下邮箱,或者加qq群:546496965