Appearance
简历画像
我们支持客户通过 SaaS 接口或私有化部署方式使用简历画像服务,服务提供标准的 Restful 接口。
简历画像基于简历解析能力进一步生成更丰富的简历画像标签,简历画像结果覆盖了简历解析的所有字段,本文档仅介绍简历画像新增字段,简历画像页面完整介绍了简历画像的所有字段。
接口请求格式
解析接口以 POST + application/json 方式提供,通过 HTTP 请求调用。
请求方法
POST
HEADER 参数设置
| 字段 | 值 | 是否必填 | 说明 |
|---|---|---|---|
| Content-Type | application/json; charset=utf-8 | 是 | 请求内容类型 |
| user_id | your user id | 是 | 用户 ID |
| user_secret | your user secret | 是 | 用户秘钥 |
提示
用户 ID 及秘钥由后台生成,欢迎联系我们开通服务,竭诚为您服务 🎉🎉🎉
私有化部署模式下,请求 HEADER 中不需要设置user_id和user_secret这两个字段。
请求 Body 参数设置
| 字段 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| file_name | String | 是 | 简历文件名,带后缀名,如.pdf、.doc、.docx、.txt等 |
| file_content | String | 是 | Base64 编码后的简历文件内容,不能为空字符串,Base64 解码后的内容也不能空 |
| parse_avatar | Integer | 否 | 是否解析头像,为如下枚举值:0: 不需要解析头像1: 需要解析头像缺省时默认值为 0 |
请求 Body 参考样例
json
{
"file_name": "test.pdf",
"file_content": "base64 encoded content",
"mode": "standard",
"parse_avatar": 1
}接口响应格式
响应 HEADER 自定义内容
接口返回的 Response 的 HEADER 中定义了用户的额度信息,具体内容如下:
| 字段 | 类型 | 说明 |
|---|---|---|
| user_id | String | 用户 ID |
| subscription | String | 用户订阅模式,为如下枚举值:yearly: 包年monthly: 包月traffic: 频次 |
| expiry_date | String | 包含年月日的日期格式,如2099.01.01,表示2099.01.01当日零点开始包年包月服务失效,在之前均有效,具体格式参考日期格式,订阅模式为yearly、monthly时字段有效 |
| quota | Integer | 单位: 次,总的额度 |
| quota_usage | Integer | 单位: 次,已经使用额度 |
提示
私有化部署模式下,Response 的 HEADER 中没有上述字段。
响应 Body 部分整体格式
画像接口以 Json 格式组织并返回画像结果,包含三部分内容:
画像状态信息
画像状态信息字段名为status,类型为Object,包含画像成功或失败的状态码及描述信息,定义如下:
| 字段 | 类型 | 说明 |
|---|---|---|
| code | Integer | 状态码(详细定义参考返回状态码表)200: 画像正常其他: 画像异常 |
| message | String | 状态描述信息 |
画像解析器信息
画像解析器信息字段名为profile_info,类型为Object,包含当前使用的解析器版本及画像时间(北京时间),定义如下:
| 字段 | 类型 | 说明 |
|---|---|---|
| version | String | 解析器版本号,包含三部分:主版本号、子版本号、阶段版本号,并以"."连接,如1.0.0 |
| profile_time | String | 画像时间,时间格式为yyyy.MM.dd HH:mm:ss,如:2024.01.01 01:01:01 |
画像结果
画像结果字段名为result,类型为Object,包含解析器提取的各个字段信息,具体定义参考解析结果格式
整体返回格式示例
json
{
"status": {
"code": 200,
"message": "解析成功"
},
"profile_info": {
"version": "1.0.0",
"profile_time": "2000.01.01 01:01:01"
},
"result": {
...
}
}画像结果格式
工作经历
工作经历字段名为career_list,类型为Array[Object],每一个元素对应一段工作经历,简历画像新增字段定义如下:
| 序号 | 字段 | 类型 | 含义 | 说明 |
|---|---|---|---|---|
| 1 | position_type_l1 | Array[Object] | 一级职能类别 | AI 预测的该条工作经历的一级职能,具体定义参考AI 预测一级职能类别。职能体系参考职能分类标签枚举值字段定义,本文中 AI 预测的职能体系定义都相同,参考地址后续不再赘述。 |
| 2 | position_type_l2 | Array[Object] | 二级职能类别 | AI 预测的该条工作经历的二级职能,具体定义参考AI 预测二级职能类别。 |
| 3 | position_type_l3 | Array[Object] | 三级职能类别 | AI 预测的该条工作经历的三级职能,具体定义参考AI 预测三级职能类别。 |
| 4 | industry_l1 | Array[Object] | 一级行业类别 | AI 预测的该条工作经历的一级行业,具体定义参考AI 预测一级行业类别。行业体系参考行业分类标签枚举值字段定义,本文中 AI 预测的行业体系定义都相同,参考地址后续不再赘述。 |
| 5 | industry_l2 | Array[Object] | 二级行业类别 | AI 预测的该条工作经历的二级行业,具体定义参考AI 预测二级行业类别。 |
| 6 | company_info | Object | 公司信息 | 公司信息依赖外部知识库,非简历填写内容,具体定义参考公司信息字段。 |
工作经历字段格式示例
json
"career_list": [
{
"company": "上海xxx科技有限公司",
"position": "测试工程师",
"position_type": "测试",
...
"position_type_l1": [
{
"l1": "互联网/AI",
"weight": 0.83
},
...
],
"position_type_l2": [
{
"l1": "互联网/AI",
"l2": "测试",
"weight": 0.76
},
...
],
"position_type_l3": [
{
"l1": "互联网/AI",
"l2": "测试",
"l3": "测试工程师",
"weight": 0.69
},
...
],
"industry_l1": [
{
"l1": "互联网/AI",
"weight": 0.77
},
...
],
"industry_l2": [
{
"l1": "互联网/AI",
"l2": "计算机软件",
"weight": 0.65
},
...
],
"company_info": {
"name": "阿里巴巴(中国)网络技术有限公司",
"nature": "民营",
"country": "中国",
"city": "杭州",
"products": [
"支付宝",
...
],
"tags": [
"互联网大厂",
...
],
"industry_tags": [
"电子商务",
...
]
}
},
...
]公司信息字段
公司信息字段名为company_info,字段数据来源于外部知识库,非简历填写内容,类型为Object,定义如下:
| 序号 | 字段 | 类型 | 含义 | 说明 |
|---|---|---|---|---|
| 1 | name | String | 公司名称 | 如阿里巴巴(中国)网络技术有限公司 |
| 2 | nature | String | 公司性质 | 如民营 |
| 3 | country | String | 所在国家 | 如中国 |
| 4 | city | String | 所在国家 | 如杭州 |
| 5 | products | Array[String] | 公司产品 | 如支付宝 |
| 6 | tags | Array[String] | 标签 | 如互联网大厂 |
| 7 | industry_tags | Array[String] | 行业标签 | 如电子商务 |
工作经历字段格式示例
json
"company_info": {
"name": "阿里巴巴(中国)网络技术有限公司",
"nature": "民营",
"country": "中国",
"city": "杭州",
"products": [
"支付宝",
...
],
"tags": [
"互联网大厂",
...
],
"industry_tags": [
"电子商务",
...
]
}项目经历
项目经历字段名为project_list,类型为Array[Object],每一个元素对应一段项目经历,简历画像新增字段定义如下:
| 序号 | 字段 | 类型 | 含义 | 说明 |
|---|---|---|---|---|
| 1 | position_type_l1 | Array[Object] | 一级职能类别 | AI 预测的该条项目经历的一级职能,具体定义参考AI 预测一级职能类别。 |
| 2 | position_type_l2 | Array[Object] | 二级职能类别 | AI 预测的该条项目经历的二级职能,具体定义参考AI 预测二级职能类别。 |
| 3 | position_type_l3 | Array[Object] | 三级职能类别 | AI 预测的该条项目经历的三级职能,具体定义参考AI 预测三级职能类别。 |
| 4 | industry_l1 | Array[Object] | 一级行业类别 | AI 预测的该条项目经历的一级行业,具体定义参考AI 预测一级行业类别。 |
| 5 | industry_l2 | Array[Object] | 二级行业类别 | AI 预测的该条项目经历的二级行业,具体定义参考AI 预测二级行业类别。 |
项目经历字段格式示例
json
"project_list": [
{
"name": "xxx系统",
"position": "Java开发",
...
"position_type_l1": [
{
"l1": "互联网/AI",
"weight": 0.83
},
...
],
"position_type_l2": [
{
"l1": "互联网/AI",
"l2": "后端开发",
"weight": 0.76
},
...
],
"position_type_l3": [
{
"l1": "互联网/AI",
"l2": "后端开发",
"l3": "Java",
"weight": 0.69
},
...
],
"industry_l1": [
{
"l1": "互联网/AI",
"weight": 0.77
},
...
],
"industry_l2": [
{
"l1": "互联网/AI",
"l2": "计算机软件",
"weight": 0.65
},
...
]
},
...
]AI 预测职能
AI 预测一级职能
AI 预测人才的一级职能字段名为position_type_l1,类型为Object,具体定义参考AI 预测一级职能类别。
AI 预测一级职能字段格式示例
json
"position_type_l1": [
{
"l1": "互联网/AI",
"weight": 0.71
},
...
]AI 预测二级职能
AI 预测人才的二级职能字段名为position_type_l2,类型为Object,具体定义参考AI 预测二级职能类别。
AI 预测二级职能字段格式示例
json
"position_type_l2": [
{
"l1": "互联网/AI",
"l2": "后端开发",
"weight": 0.83
},
...
]AI 预测三级职能
AI 预测人才的三级职能字段名为position_type_l3,类型为Object,具体定义参考AI 预测三级职能类别。
AI 预测三级职能字段格式示例
json
"position_type_l2": [
{
"l1": "互联网/AI",
"l2": "后端开发",
"l3": "Java",
"weight": 0.83
},
...
]AI 预测行业
AI 预测一级行业
AI 预测人才的一级行业字段名为industry_l1,类型为Object,具体定义参考AI 预测一级行业类别。
AI 预测一级行业字段格式示例
json
"industry_l1": [
{
"l1": "互联网/AI",
"weight": 0.71
},
...
]AI 预测二级行业
AI 预测人才的二级行业字段名为industry_l2,类型为Object,具体定义参考AI 预测二级行业类别。
AI 预测二级行业字段格式示例
json
"industry_l2": [
{
"l1": "互联网/AI",
"l2": "计算机软件",
"weight": 0.83
},
...
]软素质标签
软素质标签字段名为soft_skill,类型为Object,定义如下:
| 序号 | 字段 | 类型 | 含义 | 说明 |
|---|---|---|---|---|
| 1 | soft_skill | String | 软素质标签 | 枚举值,如沟通能力,具体定义参考软素质标签枚举值定义 |
| 2 | mention | Array[String] | 软素质描述 | 软素质标签的描述文本,如沟通能力强 |
软素质标签字段格式示例
json
"soft_skill": [
{
"soft_skill": "沟通能力",
"mention": [
"沟通能力强",
...
]
},
...
]工作稳定性
工作稳定性字段名为career_stability,类型为Object,定义如下:
| 序号 | 字段 | 类型 | 含义 | 说明 |
|---|---|---|---|---|
| 1 | long_career_num | Integer | 长时间工作经历段数 | 如3 |
| 2 | short_career_num | Integer | 短时间工作经历段数 | 如2 |
| 3 | avg_career_time | Float | 平均每段工作经历时长 | 如20.5,单位月 |
| 4 | avg_position_type_l1_time | Float | 平均每个一级职能工作时长 | 如20.5,单位月 |
| 5 | avg_position_type_l2_time | Float | 平均每个二级职能工作时长 | 如11.5,单位月 |
| 6 | avg_position_type_l3_time | Float | 平均每个三级职能工作时长 | 如11.2,单位月 |
| 7 | avg_industry_l1_time | Float | 平均每个一级行业工作时长 | 如13.2,单位月 |
| 8 | avg_industry_l2_time | Float | 平均每个二级行业工作时长 | 如11.6,单位月 |
| 9 | stability | Integer | 职业稳定性 | 枚举值:0 -> 不稳定1 -> 稳定 |
工作稳定性字段格式示例
json
"career_stability": {
"long_career_num": 3,
"short_career_num": 2,
"avg_career_time": 20.5,
"avg_position_type_l1_time": 20.5,
"avg_position_type_l2_time": 11.5,
"avg_position_type_l3_time": 11.2,
"avg_industry_l1_time": 13.2,
"avg_industry_l2_time": 11.6,
"stability": 0
}简历风险点
简历风险点字段名为risks,类型为Array[Object],Object为简历风险点,定义如下:
| 序号 | 字段 | 类型 | 含义 | 说明 |
|---|---|---|---|---|
| 1 | risk | String | 简历风险点 | 枚举值: 工作不稳定 工作经历空窗期 跳槽频繁 教育经历空窗期 |
| 2 | content | String | 风险点描述 | 如平均每段工作经历持续 7 个月,共 3 段工作经历持续时间在 1 年以下 |
| 3 | source | String | 风险点来源 | 风险点来源:education -> 教育经历career -> 工作经历 |
简历风险点字段格式示例
json
"risks": [
{
"risk": "工作不稳定",
"content": "平均每段工作经历持续 7 个月,共 3 段工作经历持续时间在 1 年以下",
"source": "career",
},
...
]简历亮点
简历亮点字段名为highlights,类型为Array[Object],Object为简历亮点,定义如下:
| 序号 | 字段 | 类型 | 含义 | 说明 |
|---|---|---|---|---|
| 1 | highlight | String | 简历亮点 | 枚举值:工作稳定 名企经历 211院校毕业 985院校毕业 双一流院校毕业 QS200院校毕业 |
| 2 | content | String | 亮点描述 | 如毕业于 985 院校:清华大学 |
| 3 | source | String | 亮点来源 | 亮点来源:education -> 教育经历career -> 工作经历 |
简历亮点字段格式示例
json
"highlights": [
{
"risk": "985院校毕业",
"content": "毕业于 985 院校:清华大学",
"source": "education",
},
...
]AI 预测薪资
AI 预测薪资字段名为predicted_salary,类型为String,值为枚举值:
| ID | 枚举值 |
|---|---|
| 1 | 3K以下 |
| 2 | 3-5K |
| 3 | 5-10K |
| 4 | 10-20K |
| 5 | 20-30K |
| 6 | 30-50K |
| 7 | 50K以上 |
简历亮点字段格式示例
json
"predicted_salary": "30-50K"画像子字段定义
AI 预测职能类别
AI 预测一级职能类别
AI 预测一级职能类别类型为Array[Object],最多保留概率最高的 5 个工作职能,每个Object的定义如下:
| 序号 | 字段 | 类型 | 含义 | 说明 |
|---|---|---|---|---|
| 1 | l1 | String | 一级职能类别 | AI 预测的一级职能类别,如互联网/AI |
| 2 | weight | Float | 一级职能类别概率 | AI 预测的一级职能类别概率,值在[0,1]之间,如0.84 |
AI 预测二级职能类别
AI 预测二级职能类别类型为Array[Object],最多保留概率最高的 5 个工作职能,每个Object的定义如下:
| 序号 | 字段 | 类型 | 含义 | 说明 |
|---|---|---|---|---|
| 1 | l1 | String | 一级职能类别 | AI 预测的二级职能类别对应的一级职能类别,如互联网/AI |
| 2 | l2 | String | 二级职能类别 | AI 预测的二级职能类别,如后端开发 |
| 3 | weight | Float | 二级职能类别概率 | AI 预测的二级职能类别概率,值在[0,1]之间,如0.77 |
AI 预测三级职能类别
AI 预测三级职能类别类型为Array[Object],最多保留概率最高的 5 个工作职能,每个Object的定义如下:
| 序号 | 字段 | 类型 | 含义 | 说明 |
|---|---|---|---|---|
| 1 | l1 | String | 一级职能类别 | AI 预测的三级职能类别对应的一级职能类别,如互联网/AI |
| 2 | l2 | String | 二级职能类别 | AI 预测的三级职能类别对应的二级职能类别,如后端开发 |
| 3 | l3 | String | 三级职能类别 | AI 预测的三级职能类别,如Python |
| 4 | weight | Float | 三级职能类别概率 | AI 预测的三级职能类别概率,值在[0,1]之间,如0.68 |
AI 预测行业类别
AI 预测一级行业类别
AI 预测一级行业类别类型为Array[Object],最多保留概率最高的 5 个行业,每个Object的定义如下:
| 序号 | 字段 | 类型 | 含义 | 说明 |
|---|---|---|---|---|
| 1 | l1 | String | 一级行业类别 | AI 预测的一级行业职能类别,如互联网/AI |
| 2 | weight | Float | 一级行业类别概率 | AI 预测的行业职能类别概率,值在[0,1]之间,如0.84 |
AI 预测二级行业类别
AI 预测二级行业类别类型为Array[Object],最多保留概率最高的 5 个行业,每个Object的定义如下:
| 序号 | 字段 | 类型 | 含义 | 说明 |
|---|---|---|---|---|
| 1 | l1 | String | 一级行业类别 | AI 预测的二级行业类别对应的一级行业类别,如互联网/AI |
| 2 | l2 | String | 二级行业类别 | AI 预测的二级行业类别,如计算机软件 |
| 3 | weight | Float | 二级行业类别概率 | AI 预测的二级行业类别概率,值在[0,1]之间,如0.77 |
接口请求代码样例
python
# _*_ coding:utf-8 _*_
# 需安装: requests
import sys
import os
import requests
import base64
import json
reload(sys)
sys.setdefaultencoding('utf8')
class ResumeParser:
def __init__(self, url, user_id, user_secret):
self.url = url
self.user_id = user_id
self.user_secret = user_secret
def parse(self, file_name, dir_path, parse_avatar):
# 获取完整的简历文件路径
file_path = os.path.join(dir_path, file_name)
# 获取简历文件内容并Base64编码
content = open(file_path, 'rb').read()
b64_content = base64.b64encode(content)
# 设置请求头
headers = {
'Content-Type': 'application/json; charset=utf-8',
'user_id': self.user_id,
'user_secret': self.user_secret,
}
# 设置请求Body
data = {
'file_name': file_name,
'file_content': b64_content,
'parse_avatar': parse_avatar
}
# 请求解析服务获取结果
response = requests.post(self.url, json=data, timeout=10, verify=False, headers=headers)
result = json.loads(response.text)
# 返回解析结果
return result
def test():
url = 'https://qingsong-ai.com/api/resume/profile' # 简历解析服务URL
user_id = 'your user id' # 您的用户ID
user_secret = 'your user secret' # 您的秘钥
file_name = 'resume file name' # 简历文件名
dir_path = 'resume file dictionary path' # 简历文件目录路径
parse_avatar = 0 # 是否需要提取头像
# 调用解析服务并打印解析结果
resume_parser = ResumeParser(url, user_id, user_secret)
result = resume_parser.parse(file_name, dir_path, parse_avatar)
print json.dumps(result, indent=4, ensure_ascii=False)
if __name__ == '__main__':
test()python
# _*_ coding:utf-8 _*_
# 需安装: requests
import os
import requests
import base64
import json
class ResumeParser:
def __init__(self, url, user_id, user_secret):
self.url = url
self.user_id = user_id
self.user_secret = user_secret
def parse(self, file_name, dir_path, parse_avatar):
# 获取完整的简历文件路径
file_path = os.path.join(dir_path, file_name)
# 获取简历文件内容并Base64编码
content = open(file_path, 'rb').read()
b64_content = base64.b64encode(content).decode('utf8')
# 设置请求头
headers = {
'Content-Type': 'application/json; charset=utf-8',
'user_id': self.user_id,
'user_secret': self.user_secret,
}
# 设置请求Body
data = {
'file_name': file_name,
'file_content': b64_content,
'parse_avatar': parse_avatar
}
# 请求解析服务获取结果
response = requests.post(self.url, json=data, timeout=10, verify=False, headers=headers)
result = json.loads(response.text)
# 返回解析结果
return result
def test():
url = 'https://qingsong-ai.com/api/resume/profile' # 简历解析服务URL
user_id = 'your user id' # 您的用户ID
user_secret = 'your user secret' # 您的秘钥
file_name = 'resume file name' # 简历文件名
dir_path = 'resume file dictionary path' # 简历文件目录路径
parse_avatar = 0 # 是否需要提取头像
# 调用解析服务并打印解析结果
resume_parser = ResumeParser(url, user_id, user_secret)
result = resume_parser.parse(file_name, dir_path, parse_avatar)
print(json.dumps(result, indent=4, ensure_ascii=False))
if __name__ == '__main__':
test()java
// 需安装: apache-http, fastjson2
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONWriter;
import org.apache.http.Consts;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Base64;
public class ResumeParserTest {
private final String url;
private final String userId;
private final String userSecret;
public ResumeParserTest(String url, String userId, String userSecret) {
this.url = url;
this.userId = userId;
this.userSecret = userSecret;
}
public JSONObject resumeParse(String fileName, String dirPath, int parseAvatar) throws IOException {
// 获取完整的简历文件路径
Path dir = Paths.get(dirPath);
Path filePath = dir.resolve(fileName);
// 获取简历文件内容并Base64编码
byte[] content = Files.readAllBytes(filePath);
String b64Content = new String(Base64.getEncoder().encode(content));
HttpPost httpPost = new HttpPost(this.url);
// 设置请求头
httpPost.addHeader("Content-Type", "application/json; charset=utf-8");
httpPost.setHeader("user_id", userId);
httpPost.setHeader("user_secret", userSecret);
// 设置请求Body
JSONObject data = new JSONObject();
data.put("file_name", fileName);
data.put("file_content", b64Content);
data.put("parse_avatar", parseAvatar);
httpPost.setEntity(new StringEntity(data.toString(), Consts.UTF_8));
// 请求解析服务获取结果
HttpClient httpclient = HttpClients.createDefault();
HttpResponse response = httpclient.execute(httpPost);
String result = EntityUtils.toString(response.getEntity(), Consts.UTF_8);
// 返回解析结果
return JSONObject.parseObject(result);
}
public static void test() throws IOException {
String url = "https://qingsong-ai.com/api/resume/profile"; // 简历解析服务URL
String userId = "your user id"; // 您的用户ID
String userSecret = "your user secret"; // 您的秘钥
String fileName = "resume file name"; // 简历文件名
String dirPath = "resume file dictionary path"; // 简历文件目录路径
int parseAvatar = 0; // 是否需要提取头像
// 调用解析服务并打印解析结果
ResumeParserTest resumeParser = new ResumeParserTest(url, userId, userSecret);
JSONObject result = resumeParser.resumeParse(fileName, dirPath, parseAvatar);
System.out.println(JSONObject.toJSONString(result, JSONWriter.Feature.PrettyFormat));
}
public static void main(String[] args) throws Exception {
test();
}
}C#
// 需安装: Newtonsoft.Json
using System;
using System.IO;
using System.Text;
using System.Net;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace ResumeParserTest
{
class ResumeParser
{
private string url;
private string userId;
private string userSecret;
public ResumeParser(string url, string userId, string userSecret)
{
this.url = url;
this.userId = userId;
this.userSecret = userSecret;
}
public string Parse(string fileName, string dirPath, int parseAvatar)
{
// 获取完整的简历文件路径
string filePath = Path.Combine(dirPath, fileName);
// 获取简历文件内容并Base64编码
byte[] content = File.ReadAllBytes(filePath);
string b64Content = Convert.ToBase64String(content);
// 设置请求头
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(this.url);
req.Method = "POST";
req.ContentType = "application/json; charset=utf-8";
req.Headers.Add("user_id", this.userId);
req.Headers.Add("user_secret", this.userSecret);
// 设置请求Body
JObject data = new JObject();
data["file_name"] = fileName;
data["file_content"] = b64Content;
data["parse_avatar"] = parseAvatar;
byte[] byteData = Encoding.UTF8.GetBytes(data.ToString());
req.ContentLength = byteData.Length;
// 请求解析服务获取结果
using (Stream postStream = req.GetRequestStream())
{
postStream.Write(byteData, 0, byteData.Length);
}
using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse())
{
using (StreamReader reader = new StreamReader(resp.GetResponseStream()))
{
string result = reader.ReadToEnd();
return result;
}
}
return null;
}
}
class Tester
{
static void Test()
{
String url = "https://qingsong-ai.com/api/resume/profile"; // 简历解析服务URL
String userId = "your user id"; // 您的用户ID
String userSecret = "your user secret"; // 您的秘钥
String fileName = "resume file name"; // 简历文件名
String dirPath = "resume file dictionary path"; // 简历文件目录路径
int parseAvatar = 0; // 是否需要提取头像
// 调用解析服务并打印解析结果
ResumeParser resumeParser = new ResumeParser(url, userId, userSecret);
string result = resumeParser.Parse(fileName, dirPath, parseAvatar);
if (result != null)
{
dynamic jsonObject = JsonConvert.DeserializeObject(result);
string resultShow = JsonConvert.SerializeObject(jsonObject, Formatting.Indented);
Console.WriteLine(resultShow);
}
else
{
Console.WriteLine("解析错误");
}
}
static void Main(string[] args)
{
Test();
}
}
}JavaScript
// 需安装: axios
const path = require("path");
const fs = require("fs");
const axios = require("axios");
class ResumeParser {
constructor(url, userId, userSecret) {
this.url = url;
this.userId = userId;
this.userSecret = userSecret;
}
async parse(fileName, dirPath, parseAvatar) {
// 获取完整的简历文件路径
const filePath = path.join(dirPath, fileName);
// 获取简历文件内容并Base64编码
const content = fs.readFileSync(filePath);
const b64Content = content.toString("base64");
// 设置请求头
const headers = {
"Content-Type": "application/json; charset=utf-8",
user_id: this.userId,
user_secret: this.userSecret,
};
// 设置请求Body
const data = {
file_name: fileName,
file_content: b64Content,
parse_avatar: parseAvatar,
};
// 请求解析服务获取并返回结果
return axios
.post(this.url, data, { headers: headers })
.then((response) => {
return response.data;
})
.catch((error) => {
return error;
});
}
}
function test() {
const url = "https://qingsong-ai.com/api/resume/profile"; // 简历解析服务URL
const userId = "your user id"; // 您的用户ID
const userSecret = "your user secret"; // 您的秘钥
var fileName = "resume file name"; // 简历文件名
var dirPath = "resume file dictionary path"; // 简历文件目录路径
var parseAvatar = 0; // 是否需要提取头像
// 调用解析服务并打印解析结果
const resumeParser = new ResumeParser(url, userId, userSecret);
resumeParser
.parse(fileName, dirPath, parseAvatar)
.then((result) => {
console.log(JSON.stringify(result, null, 4));
})
.catch((error) => {
console.error("解析失败: ", error);
});
}
test();Go
package main
import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"path/filepath"
)
type ResumeParser struct {
url string
userId string
userSecret string
}
func (resumeParser ResumeParser) parse(fileName string, dirPath string, parseAvatar int) (string, error) {
// 获取完整的简历文件路径
filePath := filepath.Join(dirPath, fileName)
// 获取简历文件内容并Base64编码
content, err := ioutil.ReadFile(filePath)
if err != nil {
fmt.Println("无法读取文件: ", err)
return "", err
}
b64Content := base64.StdEncoding.EncodeToString(content)
// 设置请求Body
data, err := json.Marshal(map[string]interface{}{
"file_name": fileName,
"file_content": b64Content,
"parse_avatar": parseAvatar,
})
if err != nil {
fmt.Println("设置请求Body错误: ", err)
return "", err
}
req, err := http.NewRequest("POST", resumeParser.url, bytes.NewBuffer(data))
if err != nil {
fmt.Println("创建POST请求错误: ", err)
return "", err
}
// 设置请求头
req.Header.Set("Content-Type", "application/json; charset=utf-8")
req.Header.Set("user_id", resumeParser.userId)
req.Header.Set("user_secret", resumeParser.userSecret)
// 请求解析服务获取结果
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("解析请求错误: ", err)
return "", err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("读取请求响应错误: ", err)
return "", err
}
result := string(body)
// 返回解析结果
return result, nil
}
func test() {
url := "https://qingsong-ai.com/api/resume/profile" // 简历解析服务URL
userId := "your user id" // 您的用户ID
userSecret := "your user secret" // 您的秘钥
fileName := "resume file name" // 简历文件名
dirPath := "resume file dictionary path" // 简历文件目录路径
parseAvatar := 0 // 是否需要提取头像
// 调用解析服务并打印解析结果
resumeParser := ResumeParser{url, userId, userSecret}
resultStr, err := resumeParser.parse(fileName, dirPath, parseAvatar)
if err != nil {
fmt.Println("获取简历解析结果失败: ", err)
}
var result map[string]interface{}
err = json.Unmarshal([]byte(resultStr), &result)
if err != nil {
fmt.Println("Json反序列化失败: ", err)
}
resultShow, err := json.MarshalIndent(result, "", " ")
fmt.Println(string(resultShow))
}
func main() {
test()
}PHP
<?php
class ResumeParser
{
private $url;
private $userId;
private $userSecret;
public function __construct($url, $userId, $userSecret)
{
$this->url = $url;
$this->userId = $userId;
$this->userSecret = $userSecret;
}
public function parse($fileName, $dirPath, $parseAvatar)
{
// 获取完整的简历文件路径
$filePath = join(DIRECTORY_SEPARATOR, array($dirPath, $fileName));
// 获取简历文件内容并Base64编码
$content = file_get_contents($filePath);
$b64Content = base64_encode($content);
// 设置请求Body
$ch = curl_init($this->url);
$dataArr = array(
'file_name' => $fileName,
'file_content' => $b64Content,
'parse_avatar' => $parseAvatar
);
$data = json_encode($dataArr);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// 设置请求头
$headers = array(
'Content-Type: application/json; charset=utf-8',
'user_id: ' . $this->userId,
'user_secret: ' . $this->userSecret
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// 请求解析服务获取结果
$response = curl_exec($ch);
if (curl_errno($ch)) {
$error_msg = curl_error($ch);
curl_close($ch);
die('解析错误: ' . $error_msg);
}
curl_close($ch);
$result = json_decode($response, null);
// 返回解析结果
return $result;
}
}
function test()
{
$url = 'https://qingsong-ai.com/api/resume/profile'; // 简历解析服务URL
$userId = 'your user id'; // 您的用户ID
$userSecret = 'your user secret'; // 您的秘钥
$fileName = 'resume file name'; // 简历文件名
$dirPath = 'resume file dictionary path'; // 简历文件目录路径
$parseAvatar = 0; // 是否需要提取头像
// 调用解析服务并打印解析结果
$resumeParser = new ResumeParser($url, $userId, $userSecret);
$result = $resumeParser->parse($fileName, $dirPath, $parseAvatar);
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
}
test();
?>Ruby
require 'base64'
require 'net/http'
require 'json'
require 'uri'
class ResumeParser
def initialize(url, user_id, user_secret)
@url = url
@user_id = user_id
@user_secret = user_secret
end
def parse(file_name, dir_path, parse_avatar)
# 获取完整的简历文件路径
file_path = File.join(dir_path, file_name)
# 获取简历文件内容并Base64编码
file = File.open(file_path, 'rb')
content = file.read
file.close
b64_content = Base64.strict_encode64(content)
# 设置请求头
headers = {
'Content-Type' => 'application/json; charset=utf-8',
'user_id' => @user_id,
'user_secret' => @user_secret
}
uri = URI(@url)
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.path, headers)
# 设置请求Body
request.body = { file_name: file_name,
file_content: b64_content,
parse_avatar: parse_avatar }.to_json
# 请求解析服务获取结果
response = http.request(request)
result = response.read_body
JSON.parse(result)
end
end
def test()
url = 'https://qingsong-ai.com/api/resume/profile'; # 简历解析服务URL
user_id = 'your user id'; # 您的用户ID
user_secret = 'your user secret'; # 您的秘钥
file_name = 'resume file name'; # 简历文件名
dir_path = 'resume file dictionary path'; # 简历文件目录路径
parse_avatar = 0; # 是否需要提取头像
# 调用解析服务并打印解析结果
resume_parser = ResumeParser.new(url, user_id, user_secret)
result = resume_parser.parse(file_name, dir_path, parse_avatar)
puts JSON.pretty_generate(result)
end
test()Objective-C
#import <Foundation/Foundation.h>
@interface ResumeParser : NSObject
@property (nonatomic, strong) NSString *url;
@property (nonatomic, strong) NSString *userId;
@property (nonatomic, strong) NSString *userSecret;
- (instancetype)initWithUrl:(NSString *)url withUserId:(NSString *)userId withUserSecret:(NSString *)userSecret;
- (NSDictionary *)parse:(NSString *)fileName withDirPath:(NSString *)dirPath withMode:(NSString *)mode withParseAvatar:(NSNumber *)parseAvatar;
@end
@implementation ResumeParser
- (instancetype)initWithUrl:(NSString *)url withUserId:(NSString *)userId withUserSecret:(NSString *)userSecret {
self = [super init];
if (self) {
_url = url;
_userId = userId;
_userSecret = userSecret;
}
return self;
}
- (NSDictionary *)parse:(NSString *)fileName withDirPath:(NSString *)dirPath withParseAvatar:(NSNumber *)parseAvatar {
// 获取完整的简历文件路径
NSString *filePath = [dirPath stringByAppendingPathComponent:fileName];
// 获取简历文件内容并Base64编码
NSData *content = [NSData dataWithContentsOfFile:filePath];
NSString *b64Content = [content base64EncodedStringWithOptions:0];
NSURL *nsUrl = [NSURL URLWithString:_url];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:nsUrl];
[request setHTTPMethod:@"POST"];
// 设置请求头
[request setValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:_userId forHTTPHeaderField:@"user_id"];
[request setValue:_userSecret forHTTPHeaderField:@"user_secret"];
// 设置请求Body
NSDictionary *jsonDict = @{
@"file_name": fileName,
@"file_content": b64Content,
@"parse_avatar": parseAvatar,
};
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:0 error:nil];
[request setHTTPBody:jsonData];
// 请求解析服务获取结果
NSURLResponse *response = nil;
NSError *error = nil;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if (error == nil && responseData != nil) {
NSDictionary *responseDict = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:nil];
// 返回解析结果
return responseDict;
} else {
return nil;
}
}
@end
void test() {
NSString *url = @"https://qingsong-ai.com/api/resume/profile"; // 简历解析服务URL
NSString *userId = @"your user id"; // 您的用户ID
NSString *userSecret = @"your user secret"; // 您的秘钥
NSString *fileName = @"resume file name"; // 简历文件名
NSString *dirPath = @"resume file dictionary path"; // 简历文件目录路径
NSNumber *parseAvatar = [NSNumber numberWithInt:0]; // 是否需要提取头像
@autoreleasepool {
// 调用解析服务并打印解析结果
ResumeParser *resumeParser = [[ResumeParser alloc] initWithUrl:url withUserId:userId withUserSecret:userSecret];
NSDictionary *result = [resumeParser parse:fileName withDirPath:dirPath withParseAvatar:parseAvatar];
if (result != nil) {
NSData *resultNSData = [NSJSONSerialization dataWithJSONObject:result
options:NSJSONWritingPrettyPrinted
error:nil];
NSString *resultStr= [[NSString alloc] initWithData:resultNSData encoding:NSUTF8StringEncoding];
NSLog(@"%@", resultStr);
}
[resumeParser release];
}
}
int main(int argc, char *argv[]) {
test();
return 0;
}Shell
curl -i -X POST 'https://qingsong-ai.com/api/resume/profile' \
-H 'Content-Type: application/json; charset=UTF-8' \
-H 'user_id: your_user_id' \
-H 'user_secret: your_user_secret' \
--data '{"file_name": "resume file name", "file_content": "Base64编码后的简历文件内容", "parse_avatar": 0}'