Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

__init__.py 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Licensed under the Apache License, Version 2.0 (the "License");
  2. # you may not use this file except in compliance with the License.
  3. # You may obtain a copy of the License at
  4. #
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. #
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS,
  9. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. # See the License for the specific language governing permissions and
  11. # limitations under the License.
  12. #
  13. import datetime
  14. def refactor(cv):
  15. for n in ["raw_txt", "parser_name", "inference", "ori_text", "use_time", "time_stat"]:
  16. if n in cv and cv[n] is not None: del cv[n]
  17. cv["is_deleted"] = 0
  18. if "basic" not in cv: cv["basic"] = {}
  19. if cv["basic"].get("photo2"): del cv["basic"]["photo2"]
  20. for n in ["education", "work", "certificate", "project", "language", "skill", "training"]:
  21. if n not in cv or cv[n] is None: continue
  22. if type(cv[n]) == type({}): cv[n] = [v for _, v in cv[n].items()]
  23. if type(cv[n]) != type([]):
  24. del cv[n]
  25. continue
  26. vv = []
  27. for v in cv[n]:
  28. if "external" in v and v["external"] is not None: del v["external"]
  29. vv.append(v)
  30. cv[n] = {str(i): vv[i] for i in range(len(vv))}
  31. basics = [
  32. ("basic_salary_month", "salary_month"),
  33. ("expect_annual_salary_from", "expect_annual_salary"),
  34. ]
  35. for n, t in basics:
  36. if cv["basic"].get(n):
  37. cv["basic"][t] = cv["basic"][n]
  38. del cv["basic"][n]
  39. work = sorted([v for _, v in cv.get("work", {}).items()], key=lambda x: x.get("start_time", ""))
  40. edu = sorted([v for _, v in cv.get("education", {}).items()], key=lambda x: x.get("start_time", ""))
  41. if work:
  42. cv["basic"]["work_start_time"] = work[0].get("start_time", "")
  43. cv["basic"]["management_experience"] = 'Y' if any(
  44. [w.get("management_experience", '') == 'Y' for w in work]) else 'N'
  45. cv["basic"]["annual_salary"] = work[-1].get("annual_salary_from", "0")
  46. for n in ["annual_salary_from", "annual_salary_to", "industry_name", "position_name", "responsibilities",
  47. "corporation_type", "scale", "corporation_name"]:
  48. cv["basic"][n] = work[-1].get(n, "")
  49. if edu:
  50. for n in ["school_name", "discipline_name"]:
  51. if n in edu[-1]: cv["basic"][n] = edu[-1][n]
  52. cv["basic"]["updated_at"] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
  53. if "contact" not in cv: cv["contact"] = {}
  54. if not cv["contact"].get("name"): cv["contact"]["name"] = cv["basic"].get("name", "")
  55. return cv