Example #1
0
def resume_tag(request):
    # 获取参数并校验
    if 'cv_id' not in request.POST:
        return json_return.json_return(False, standard.PARAM_LACK.code, standard.PARAM_LACK.msg + u": cv_id")
    if 'source' not in request.POST:
        return json_return.json_return(False, standard.PARAM_LACK.code, standard.PARAM_LACK.msg + u": source")
    # if 'type' not in request.POST:
    #     return json_return.json_return(False, standard.PARAM_LACK.code, standard.PARAM_LACK.msg + u": type")
    cv_id = request.POST["cv_id"]
    source = request.POST["source"]
    # type = request.POST["type"]
    if source not in [u"智联", u"英才", u"前程无忧"]:
        return json_return.json_return(False, standard.PARAM_RANGE.code, standard.PARAM_RANGE.msg + u": source只能是[智联,英才,前程无忧]之一")
    # if type not in [u"产品", u"市场", u"技术", u"职能", u"设计", u"运营"]:
    #     return json_return.json_return(False, standard.PARAM_RANGE.code, standard.PARAM_RANGE.msg + u": type只能是六大类(产品,市场,技术,职能,设计,运营)之一")

    resume = find_resume_by_id(cv_id, source)
    if not resume:
        return json_return.json_return(False, standard.RETURN_DATA_NOT_EXISTE.code, standard.RETURN_DATA_NOT_EXISTE.msg + u": 没有该简历")
    tag_list = {}
    try:
        type_to_pinyin_map = {
            u"产品": "chanpin",
            u"市场": "shichang",
            u"技术": "jishu",
            u"职能": "zhineng",
            u"设计": "sheji",
            u"运营": "yunying"
        }
        for t in [u"产品", u"市场", u"技术", u"职能", u"设计", u"运营"]:
            tag_list[type_to_pinyin_map[t]] = getResumeTag(resume, t)
    except Exception, e:
        return json_return.json_return(False, standard.INNER_ERROR.code, standard.INNER_ERROR.msg + u": 关键词计算错误")
Example #2
0
def cal_dimension(request):
    # TODO 日志记录请求参数,返回结果
    # 获取参数并校验
    try:
        data = request.body
        resume = json.loads(data)
    except Exception, e:
        return json_return.json_return(False, standard.PARAM_FORMAT.code, standard.PARAM_FORMAT.msg + u": 非标准JSON格式")
Example #3
0
def get_dimension(request):
    # TODO 日志记录请求参数,返回结果
    # 获取参数并且校验
    if "cv_id" not in request.POST:
        return json_return.json_return(False, standard.PARAM_LACK.code, standard.PARAM_LACK.msg + u": cv_id")
    if "source" not in request.POST:
        return json_return.json_return(False, standard.PARAM_LACK.code, standard.PARAM_LACK.msg + u": source")
    if request.POST["source"] not in [u"智联", u"英才", u"前程无忧"]:
        return json_return.json_return(False, standard.PARAM_RANGE.code, standard.PARAM_RANGE.msg + u": source只能是[智联,英才,前程无忧]之一")
    cv_id = request.POST["cv_id"]
    source = request.POST["source"]
    # 查询数据
    mongo_query = {"cv_id": cv_id, "source": source}
    data = settings.MongoConf.dimension_collection.find_one(mongo_query)
    settings.MongoConf.dimension_mongo.close()
    # 判断查询结果,并返回
    if not data:
        return json_return.json_return(False, standard.RETURN_DATA_NOT_EXISTE.code, standard.RETURN_DATA_NOT_EXISTE.msg + u": 没有指定简历的维度信息")
    else:
        if data and '_id' in data:
            data.pop("_id")
        return json_return.json_return(data=data)
Example #4
0
        return json_return.json_return(False, standard.RETURN_DATA_NOT_EXISTE.code, standard.RETURN_DATA_NOT_EXISTE.msg + u": 没有该简历")
    tag_list = {}
    try:
        type_to_pinyin_map = {
            u"产品": "chanpin",
            u"市场": "shichang",
            u"技术": "jishu",
            u"职能": "zhineng",
            u"设计": "sheji",
            u"运营": "yunying"
        }
        for t in [u"产品", u"市场", u"技术", u"职能", u"设计", u"运营"]:
            tag_list[type_to_pinyin_map[t]] = getResumeTag(resume, t)
    except Exception, e:
        return json_return.json_return(False, standard.INNER_ERROR.code, standard.INNER_ERROR.msg + u": 关键词计算错误")
    return json_return.json_return(data=tag_list)


def getResumeTag(doc, type):
    resume_info = doc["self_introduction"]
    if not resume_info:
        resume_info = ""
    workExperienceList = doc["workExperienceList"]
    projectList = doc["projectList"]
    if workExperienceList:
        for experience in workExperienceList:
            resume_info += experience["experience_desc"]
    if projectList:
        for project in projectList:
            resume_info += project["project_desc"]
Example #5
0
        if data and '_id' in data:
            data.pop("_id")
        return json_return.json_return(data=data)


@csrf_exempt
def cal_dimension(request):
    # TODO 日志记录请求参数,返回结果
    # 获取参数并校验
    try:
        data = request.body
        resume = json.loads(data)
    except Exception, e:
        return json_return.json_return(False, standard.PARAM_FORMAT.code, standard.PARAM_FORMAT.msg + u": 非标准JSON格式")
    if not isinstance(resume, dict):
        return json_return.json_return(False, standard.PARAM_FORMAT.code, standard.PARAM_FORMAT.msg + u": JSON必须是一个字典")
    if 'cv_id' not in resume:
        return json_return.json_return(False, standard.PARAM_LACK.code, standard.PARAM_LACK.msg + u": cv_id")
    if 'source' not in resume:
        return json_return.json_return(False, standard.PARAM_LACK.code, standard.PARAM_LACK.msg + u": source")
    if 'resume_id' not in resume:
        return json_return.json_return(False, standard.PARAM_LACK.code, standard.PARAM_LACK.msg + u": resume_id")
    if 'workExperienceList' not in resume:
        return json_return.json_return(False, standard.PARAM_LACK.code, standard.PARAM_LACK.msg + u": workExperienceList")
    if resume["source"] not in [u"智联", u"英才", u"前程无忧"]:
        return json_return.json_return(False, standard.PARAM_RANGE.code, standard.PARAM_RANGE.msg + u": source只能是[智联,英才,前程无忧]之一")
    # 开始计算
    try:
        cv_id = resume["cv_id"]
        source = resume["source"]
        resume_id = resume["resume_id"]