Skip to content

Latest commit

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

doc_parser

A tiny, dependency-free Python package that takes the plain text of a resume (or any document with headed sections) and pulls out sections, emails, phone numbers, name candidates and a skills list.

PythonLicense

Why

In March 2025 I was building a CV-screening tool and could not find a small open source package that just did the boring text parts of resume parsing without dragging in spaCy or a model download. So I wrote the handful of regex and line heuristics I needed as an installable package with tests, so I could reuse it across projects.

Realistic use: you already have the text of a document (from PyPDF2, python-docx, OCR, a form field) and want a first-pass structure out of it, cheaply and deterministically, before doing anything smarter.

Quickstart

git clone https://github.com/joelstephen97/doc_parser.git
cd doc_parser
pip install -e .
python -m unittest discover -s tests # 8 tests
fromdoc_parserimportDocumentParsertext=open("resume.txt", encoding="utf-8").read()
doc=DocumentParser(text)
doc.extract_emails() # ['jane.roe@example.com']doc.extract_phone_numbers() # ['+971568098085']doc.extract_skills() # ['Python', 'FastAPI', 'PostgreSQL', 'Docker']doc.return_sections() # {'GENERAL': 'Jane Roe ...', 'SUMMARY': '...', 'SKILLS': '...'}doc.search("Python") # ['developer with five years in Python services. SKILLS Python, ...']doc.extract_name() # ['Jane Roe', 'SUMMARY', 'Backend', ...] (candidates, see below)

Or from the shell:

doc-parser resume.txt --search Python # or: python -m doc_parser resume.txt
doc-parser notes.txt --sections INTRODUCTION,BODY,CONCLUSION

The CLI prints one JSON object with emails, phone_numbers, name_candidates, skills, sections and, if asked, search.

Usage

DocumentParser(text, clean=True)

  • clean_text(text): collapses newlines and repeated whitespace. Applied on init unless clean=False; the original is kept in .original_text.
  • return_sections(custom_sections=None): walks the original lines; a line is a header if it is in the section set (defaults: OBJECTIVE, SUMMARY, EXPERIENCE, EDUCATION, SKILLS, PROJECTS, CERTIFICATIONS, AWARDS, EXTRACURRICULAR) or if it is all upper-case and at most four words. Text before the first header lands in GENERAL. Pass your own set of upper-case headers for non-resume documents.
  • search(keyword): case-insensitive substring match per word, returns snippets of five words either side.
  • extract_emails(): regex.
  • extract_phone_numbers(): keeps +1 (555) 123-4567 style numbers as written, normalises other + numbers to digits only, and picks up bare 10-digit numbers.
  • extract_name(): returns every Title Case / ALL CAPS run in the original text. It is a candidate list, not an answer: section headers and capitalised nouns come back too. In practice the first candidate on a resume is usually the name.
  • extract_skills(): splits the SKILLS section on commas.

How it works

Everything is re and string handling in one file, doc_parser/parser.py. There is no model, no network, no dependency. That is the point: it is predictable and fast, and it is easy to read the whole thing in five minutes and adjust a pattern.

Status and limitations

  • Verified August 2026: pip install -e . then python -m unittest discover -s tests runs 8 tests, all pass, on Python 3.12.
  • Heuristics only. Headers that are not upper-case, skills listed with bullets instead of commas, and names in lower case will be missed. extract_name over-matches by design (the TODO in the code is real).
  • Input must already be text; PDF/DOCX/OCR extraction is out of scope here (see my cv_analysis repo for that end of the pipeline).
  • Not on PyPI; install from the repo.

License

MIT, see LICENSE.

About

Dependency-free Python package that pulls sections, emails, phones, names and skills out of resume text

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages