parse_resume_utils.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import re
  2. def extract_email(content):
  3. """
  4. Extracts email id of the expert
  5. """
  6. try:
  7. pattern = r"([a-z0-9]+@[a-z]+\.[a-z]{2,3})"
  8. return re.search(pattern, content).groups()[0]
  9. except:
  10. return "None"
  11. def extract_zipcode(content):
  12. """
  13. Extracts zipcode from the resume
  14. """
  15. try:
  16. pattern = r"(\w{2}\s\d{5})"
  17. return re.search(pattern, content).groups()[0]
  18. except:
  19. return "None"
  20. def extract_phone(content):
  21. """
  22. Extracts phone number of the expert.
  23. """
  24. try:
  25. pattern = r"(\(?\d{3}\)?\-?\s?\d{3}\-\d{4})"
  26. return re.search(pattern, content).group()
  27. except:
  28. return "None"
  29. def extract_case_numbers(content):
  30. """
  31. Extracts all the case numbers associated with resume
  32. """
  33. results = []
  34. case_numbers = re.compile(r"\d{2}\-\w+\-\d+\-\w+\-?\w+", re.IGNORECASE)
  35. for current in case_numbers.finditer(content):
  36. results.append(current.group().replace(",", ""))
  37. return list(set(results))
  38. def extract_litigation_experience(content):
  39. """
  40. Extracts the litigation experience of the expert
  41. """
  42. try:
  43. pattern = r"(\d+|\w+)\s?years"
  44. return re.search(pattern, content).group()
  45. except:
  46. return "None"
  47. def extract_patents_issued(content):
  48. """
  49. Returns the patents issued by the expert
  50. """
  51. regex = r"\d{1,3}\,\d{1,3}\,\d{3}\,?"
  52. results = []
  53. patent = re.compile(regex, re.IGNORECASE)
  54. for current in patent.finditer(content):
  55. results.append(current.group().replace(",", ""))
  56. return list(set(results))
  57. def extract_name(content):
  58. """
  59. Returns the name of the expert
  60. """
  61. pattern = r"(\w+\s\w+.*?)Resume"
  62. try:
  63. return re.search(pattern, content).groups()[0]
  64. except:
  65. return "None"