├── .github └── FUNDING.yml ├── .gitignore ├── .travis.yml ├── LICENSE ├── MANIFEST.in ├── OmkarResume.pdf ├── README.md ├── README.rst ├── docs ├── cli.md └── index.md ├── export_to_csv.py ├── mkdocs.yml ├── pre_requisites.py ├── pyresparser ├── CHANGELOG.md ├── __init__.py ├── command_line.py ├── constants.py ├── custom_t.py ├── custom_train.py ├── meta.json ├── ner │ ├── cfg │ ├── model │ └── moves ├── requirements.txt ├── resume_parser.py ├── skills.csv ├── tokenizer ├── traindata.json ├── utils.py └── vocab │ ├── key2row │ ├── lexemes.bin │ ├── strings.json │ └── vectors ├── rank_candidate.py ├── requirements.txt ├── setup.py └── test_name.py /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [pyresparser] 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | cache: pip 3 | matrix: 4 | include: 5 | - python: 3.5 6 | - python: 3.6 7 | - python: 3.7 8 | install: 9 | - pip install -r requirements.txt 10 | - python -m spacy download en_core_web_sm 11 | - python -m nltk.downloader words 12 | - python -m nltk.downloader stopwords 13 | - pip install pytest 14 | - pip install coverage 15 | - pip install codecov 16 | - pip install flake8 17 | before_script: 18 | - "flake8 pyresparser" 19 | script: 20 | - "coverage run -m pytest" 21 | after_success: 22 | - codecov 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.md 2 | include bin/pyresparser.py 3 | 4 | recursive-include pyresparser * 5 | 6 | exclude pyresparser/traindata.json 7 | exclude pyresparser/custom_train.py 8 | exclude pyresparser/custom_test.py -------------------------------------------------------------------------------- /OmkarResume.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OmkarPathak/pyresparser/a66f25b583f2dd8dbd18f419321eed57b04a006e/OmkarResume.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pyresparser 2 | 3 | ``` 4 | A simple resume parser used for extracting information from resumes 5 | ``` 6 | 7 | Built with ❤︎ and :coffee: by [Omkar Pathak](https://github.com/OmkarPathak) 8 | 9 | --- 10 | 11 | [![GitHub stars](https://img.shields.io/github/stars/OmkarPathak/pyresparser.svg)](https://github.com/OmkarPathak/pyresparser/stargazers) 12 | [![PyPI](https://img.shields.io/pypi/v/pyresparser.svg)](https://pypi.org/project/pyresparser/) 13 | [![Downloads](https://pepy.tech/badge/pyresparser)](https://pepy.tech/project/pyresparser) 14 | [![GitHub](https://img.shields.io/github/license/omkarpathak/pyresparser.svg)](https://github.com/OmkarPathak/pyresparser/blob/master/LICENSE) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/Django.svg) [![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-:D-1EAEDB.svg)](https://saythanks.io/to/omkarpathak27@gmail.com) 15 | [![Build Status](https://travis-ci.com/OmkarPathak/pyresparser.svg?branch=master)](https://travis-ci.com/OmkarPathak/pyresparser) 16 | [![codecov](https://codecov.io/gh/OmkarPathak/pyresparser/branch/master/graph/badge.svg)](https://codecov.io/gh/OmkarPathak/pyresparser) 17 | 18 | # Features 19 | 20 | - Extract name 21 | - Extract email 22 | - Extract mobile numbers 23 | - Extract skills 24 | - Extract total experience 25 | - Extract college name 26 | - Extract degree 27 | - Extract designation 28 | - Extract company names 29 | 30 | # Installation 31 | 32 | - You can install this package using 33 | 34 | ```bash 35 | pip install pyresparser 36 | ``` 37 | 38 | - For NLP operations we use spacy and nltk. Install them using below commands: 39 | 40 | ```bash 41 | # spaCy 42 | python -m spacy download en_core_web_sm 43 | 44 | # nltk 45 | python -m nltk.downloader words 46 | python -m nltk.downloader stopwords 47 | ``` 48 | 49 | # Documentation 50 | 51 | Official documentation is available at: https://www.omkarpathak.in/pyresparser/ 52 | 53 | # Supported File Formats 54 | 55 | - PDF and DOCx files are supported on all Operating Systems 56 | - If you want to extract DOC files you can install [textract](https://textract.readthedocs.io/en/stable/installation.html) for your OS (Linux, MacOS) 57 | - Note: You just have to install textract (and nothing else) and doc files will get parsed easily 58 | 59 | # Usage 60 | 61 | - Import it in your Python project 62 | 63 | ```python 64 | from pyresparser import ResumeParser 65 | data = ResumeParser('/path/to/resume/file').get_extracted_data() 66 | ``` 67 | 68 | # CLI 69 | 70 | For running the resume extractor you can also use the `cli` provided 71 | 72 | ```bash 73 | usage: pyresparser [-h] [-f FILE] [-d DIRECTORY] [-r REMOTEFILE] 74 | [-re CUSTOM_REGEX] [-sf SKILLSFILE] [-e EXPORT_FORMAT] 75 | 76 | optional arguments: 77 | -h, --help show this help message and exit 78 | -f FILE, --file FILE resume file to be extracted 79 | -d DIRECTORY, --directory DIRECTORY 80 | directory containing all the resumes to be extracted 81 | -r REMOTEFILE, --remotefile REMOTEFILE 82 | remote path for resume file to be extracted 83 | -re CUSTOM_REGEX, --custom-regex CUSTOM_REGEX 84 | custom regex for parsing mobile numbers 85 | -sf SKILLSFILE, --skillsfile SKILLSFILE 86 | custom skills CSV file against which skills are 87 | searched for 88 | -e EXPORT_FORMAT, --export-format EXPORT_FORMAT 89 | the information export format (json) 90 | ``` 91 | 92 | # Notes: 93 | 94 | - If you are running the app on windows, then you can only extract .docs and .pdf files 95 | 96 | # Result 97 | 98 | The module would return a list of dictionary objects with result as follows: 99 | 100 | ``` 101 | [ 102 | { 103 | 'college_name': ['Marathwada Mitra Mandal’s College of Engineering'], 104 | 'company_names': None, 105 | 'degree': ['B.E. IN COMPUTER ENGINEERING'], 106 | 'designation': ['Manager', 107 | 'TECHNICAL CONTENT WRITER', 108 | 'DATA ENGINEER'], 109 | 'email': 'omkarpathak27@gmail.com', 110 | 'mobile_number': '8087996634', 111 | 'name': 'Omkar Pathak', 112 | 'no_of_pages': 3, 113 | 'skills': ['Operating systems', 114 | 'Linux', 115 | 'Github', 116 | 'Testing', 117 | 'Content', 118 | 'Automation', 119 | 'Python', 120 | 'Css', 121 | 'Website', 122 | 'Django', 123 | 'Opencv', 124 | 'Programming', 125 | 'C', 126 | ...], 127 | 'total_experience': 1.83 128 | } 129 | ] 130 | ``` 131 | 132 | # References that helped me get here 133 | 134 | - Some of the core concepts behind the algorithm have been taken from [https://github.com/divapriya/Language_Processing](https://github.com/divapriya/Language_Processing) which has been summed up in this blog [https://medium.com/@divalicious.priya/information-extraction-from-cv-acec216c3f48](https://medium.com/@divalicious.priya/information-extraction-from-cv-acec216c3f48). Thanks to Priya for sharing this concept 135 | 136 | - [https://www.kaggle.com/nirant/hitchhiker-s-guide-to-nlp-in-spacy](https://www.kaggle.com/nirant/hitchhiker-s-guide-to-nlp-in-spacy) 137 | 138 | - [https://www.analyticsvidhya.com/blog/2017/04/natural-language-processing-made-easy-using-spacy-%E2%80%8Bin-python/](https://www.analyticsvidhya.com/blog/2017/04/natural-language-processing-made-easy-using-spacy-%E2%80%8Bin-python/) 139 | 140 | - **Special thanks** to dataturks for their [annotated dataset](https://dataturks.com/blog/named-entity-recognition-in-resumes.php) 141 | 142 | # Donation 143 | 144 | If you have found my softwares to be of any use to you, do consider helping me pay my internet bills. This would encourage me to create many such softwares :smile: 145 | 146 | | PayPal | Donate via PayPal! | 147 | |:-------------------------------------------:|:-------------------------------------------------------------:| 148 | | ₹ (INR) | Donate via Instamojo | 149 | 150 | # Stargazer over time 151 | [![Stargazers over time](https://starchart.cc/OmkarPathak/pyresparser.svg)](https://starchart.cc/OmkarPathak/pyresparser) 152 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | pyresparser 2 | =========== 3 | 4 | :: 5 | 6 | A simple resume parser used for extracting information from resumes 7 | 8 | Built with ❤︎ and :coffee: by `Omkar 9 | Pathak `__ 10 | 11 | -------------- 12 | 13 | |GitHub stars| |PyPI| |Downloads| |GitHub| |PyPI - Python Version| |Say 14 | Thanks!| |Build Status| |codecov| 15 | 16 | Features 17 | ======== 18 | 19 | - Extract name 20 | - Extract email 21 | - Extract mobile numbers 22 | - Extract skills 23 | - Extract total experience 24 | - Extract college name 25 | - Extract degree 26 | - Extract designation 27 | - Extract company names 28 | 29 | Installation 30 | ============ 31 | 32 | - You can install this package using 33 | 34 | .. code:: bash 35 | 36 | pip install pyresparser 37 | 38 | - For NLP operations we use spacy and nltk. Install them using below 39 | commands: 40 | 41 | .. code:: bash 42 | 43 | # spaCy 44 | python -m spacy download en_core_web_sm 45 | 46 | # nltk 47 | python -m nltk.downloader words 48 | 49 | Documentation 50 | ============= 51 | 52 | Official documentation is available at: 53 | https://www.omkarpathak.in/pyresparser/ 54 | 55 | Supported File Formats 56 | ====================== 57 | 58 | - PDF and DOCx files are supported on all Operating Systems 59 | - If you want to extract DOC files you can install 60 | `textract `__ 61 | for your OS (Linux, MacOS) 62 | - Note: You just have to install textract (and nothing else) and doc 63 | files will get parsed easily 64 | 65 | Usage 66 | ===== 67 | 68 | - Import it in your Python project 69 | 70 | .. code:: python 71 | 72 | from pyresparser import ResumeParser 73 | data = ResumeParser('/path/to/resume/file').get_extracted_data() 74 | 75 | CLI 76 | === 77 | 78 | For running the resume extractor you can also use the ``cli`` provided 79 | 80 | .. code:: bash 81 | 82 | usage: pyresparser [-h] [-f FILE] [-d DIRECTORY] [-r REMOTEFILE] 83 | [-re CUSTOM_REGEX] [-sf SKILLSFILE] [-e EXPORT_FORMAT] 84 | 85 | optional arguments: 86 | -h, --help show this help message and exit 87 | -f FILE, --file FILE resume file to be extracted 88 | -d DIRECTORY, --directory DIRECTORY 89 | directory containing all the resumes to be extracted 90 | -r REMOTEFILE, --remotefile REMOTEFILE 91 | remote path for resume file to be extracted 92 | -re CUSTOM_REGEX, --custom-regex CUSTOM_REGEX 93 | custom regex for parsing mobile numbers 94 | -sf SKILLSFILE, --skillsfile SKILLSFILE 95 | custom skills CSV file against which skills are 96 | searched for 97 | -e EXPORT_FORMAT, --export-format EXPORT_FORMAT 98 | the information export format (json) 99 | 100 | Notes: 101 | ====== 102 | 103 | - If you are running the app on windows, then you can only extract 104 | .docs and .pdf files 105 | 106 | Result 107 | ====== 108 | 109 | The module would return a list of dictionary objects with result as 110 | follows: 111 | 112 | :: 113 | 114 | [ 115 | { 116 | 'college_name': ['Marathwada Mitra Mandal’s College of Engineering'], 117 | 'company_names': None, 118 | 'degree': ['B.E. IN COMPUTER ENGINEERING'], 119 | 'designation': ['Manager', 120 | 'TECHNICAL CONTENT WRITER', 121 | 'DATA ENGINEER'], 122 | 'email': 'omkarpathak27@gmail.com', 123 | 'mobile_number': '8087996634', 124 | 'name': 'Omkar Pathak', 125 | 'no_of_pages': 3, 126 | 'skills': ['Operating systems', 127 | 'Linux', 128 | 'Github', 129 | 'Testing', 130 | 'Content', 131 | 'Automation', 132 | 'Python', 133 | 'Css', 134 | 'Website', 135 | 'Django', 136 | 'Opencv', 137 | 'Programming', 138 | 'C', 139 | ...], 140 | 'total_experience': 1.83 141 | } 142 | ] 143 | 144 | References that helped me get here 145 | ================================== 146 | 147 | - https://www.kaggle.com/nirant/hitchhiker-s-guide-to-nlp-in-spacy 148 | 149 | - https://www.analyticsvidhya.com/blog/2017/04/natural-language-processing-made-easy-using-spacy-%E2%80%8Bin-python/ 150 | 151 | - [https://medium.com/@divalicious.priya/information-extraction-from-cv-acec216c3f48](https://medium.com/@divalicious.priya/information-extraction-from-cv-acec216c3f48) 152 | 153 | - **Special thanks** to dataturks for their `annotated 154 | dataset `__ 155 | 156 | Donation 157 | ======== 158 | 159 | If you have found my softwares to be of any use to you, do consider 160 | helping me pay my internet bills. This would encourage me to create many 161 | such softwares :smile: 162 | 163 | +-----------+----+ 164 | | PayPal | | 165 | +===========+====+ 166 | | ₹ (INR) | | 167 | +-----------+----+ 168 | 169 | Stargazer over time 170 | =================== 171 | 172 | |Stargazers over time| 173 | 174 | .. |GitHub stars| image:: https://img.shields.io/github/stars/OmkarPathak/pyresparser.svg 175 | :target: https://github.com/OmkarPathak/pyresparser/stargazers 176 | .. |PyPI| image:: https://img.shields.io/pypi/v/pyresparser.svg 177 | :target: https://pypi.org/project/pyresparser/ 178 | .. |Downloads| image:: https://pepy.tech/badge/pyresparser 179 | :target: https://pepy.tech/project/pyresparser 180 | .. |GitHub| image:: https://img.shields.io/github/license/omkarpathak/pyresparser.svg 181 | :target: https://github.com/OmkarPathak/pyresparser/blob/master/LICENSE 182 | .. |PyPI - Python Version| image:: https://img.shields.io/pypi/pyversions/Django.svg 183 | .. |Say Thanks!| image:: https://img.shields.io/badge/Say%20Thanks-:D-1EAEDB.svg 184 | :target: https://saythanks.io/to/OmkarPathak 185 | .. |Build Status| image:: https://travis-ci.com/OmkarPathak/pyresparser.svg?branch=master 186 | :target: https://travis-ci.com/OmkarPathak/pyresparser 187 | .. |codecov| image:: https://codecov.io/gh/OmkarPathak/pyresparser/branch/master/graph/badge.svg 188 | :target: https://codecov.io/gh/OmkarPathak/pyresparser 189 | .. |Stargazers over time| image:: https://starchart.cc/OmkarPathak/pyresparser.svg 190 | :target: https://starchart.cc/OmkarPathak/pyresparser 191 | -------------------------------------------------------------------------------- /docs/cli.md: -------------------------------------------------------------------------------- 1 | # CLI 2 | 3 | `pyresparser` comes with a **cli** option which you can use right away in your terminal 4 | 5 | ```bash 6 | usage: pyresparser [-h] [-f FILE] [-d DIRECTORY] [-r REMOTEFILE] 7 | [-sf SKILLSFILE] 8 | 9 | optional arguments: 10 | -h, --help show this help message and exit 11 | -f FILE, --file FILE resume file to be extracted 12 | -d DIRECTORY, --directory DIRECTORY directory containing all the resumes to be extracted 13 | -r REMOTEFILE, --remotefile REMOTEFILE remote path for resume file to be extracted 14 | -sf SKILLSFILE, --skillsfile SKILLSFILE custom skills CSV file against which skills are searched for 15 | ``` 16 | 17 | ## Parsing single resume 18 | 19 | For extracting data from a **single resume** file, use 20 | 21 | ```bash 22 | pyresparser -f /path/to/resume/file 23 | ``` 24 | 25 | ## Parsing mutliple resumes 26 | 27 | For extracting data from several resumes, place them in a **directory** and then execute 28 | 29 | ```bash 30 | pyresparser -d /path/to/resume/directory/ 31 | ``` 32 | 33 | ## Parsing hosted resumes 34 | 35 | For extracting data from **remote resumes**, execute 36 | 37 | ```bash 38 | pyresparser -r https://www.example.com/path/to/resume/file 39 | ``` 40 | 41 | ## Specifying skills explicitly 42 | 43 | Pyresparser comes with built-in skills file that defaults to many technical skills. You can find the default skills file [here](https://github.com/OmkarPathak/pyresparser/blob/master/pyresparser/skills.csv). 44 | 45 | For extracting data against your specified skills, create a CSV file with no headers and execute 46 | 47 | ```bash 48 | pyresparser -sf /path/to/resume/file.csv -f /path/to/resume/file 49 | ``` 50 | 51 | ## Specifying export format 52 | 53 | For specifying the export format you can use the following option: 54 | 55 | ```bash 56 | pyresparser -e json -f /path/to/resume/file 57 | ``` 58 | 59 | Note: Currently only JSON export is supported 60 | 61 | ## Custom regex for parsing phone numbers 62 | 63 | While pyresparser parses most of the phone numbers correctly, there is a possibility of new patterns being added in near future. Hence, we can explicitly provide the regex required to parse the desired phone numbers. This can be done using 64 | 65 | ```bash 66 | pyresparser -re '' -f /path/to/resume/file 67 | ``` -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # Pyresparser 2 | 3 | A simple resume parser used for extracting information from resumes 4 | 5 | # Features 6 | 7 | - Extract name 8 | - Extract email 9 | - Extract mobile numbers 10 | - Extract skills 11 | - Extract total experience 12 | - Extract college name 13 | - Extract degree 14 | - Extract designation 15 | - Extract company names 16 | 17 | # Getting Started 18 | 19 | ## Installation 20 | 21 | - You can install this package using 22 | 23 | ```bash 24 | pip install pyresparser 25 | ``` 26 | 27 | - For NLP operations we use spacy and nltk. Install them using below commands: 28 | 29 | ```bash 30 | # spaCy 31 | python -m spacy download en_core_web_sm 32 | 33 | # nltk 34 | python -m nltk.downloader words 35 | python -m nltk.downloader stopwords 36 | ``` 37 | 38 | ## Usage 39 | 40 | - Import it in your Python project 41 | 42 | ```python 43 | from pyresparser import ResumeParser 44 | data = ResumeParser('/path/to/resume/file').get_extracted_data() 45 | ``` 46 | 47 | ## Result 48 | 49 | The module would return a list of dictionary objects with result as follows: 50 | 51 | ``` 52 | [ 53 | { 54 | 'college_name': ['Marathwada Mitra Mandal’s College of Engineering'], 55 | 'company_names': None, 56 | 'degree': ['B.E. IN COMPUTER ENGINEERING'], 57 | 'designation': ['Manager', 58 | 'TECHNICAL CONTENT WRITER', 59 | 'DATA ENGINEER'], 60 | 'email': 'omkarpathak27@gmail.com', 61 | 'mobile_number': '8087996634', 62 | 'name': 'Omkar Pathak', 63 | 'no_of_pages': 3, 64 | 'skills': ['Operating systems', 65 | 'Linux', 66 | 'Github', 67 | 'Testing', 68 | 'Content', 69 | 'Automation', 70 | 'Python', 71 | 'Css', 72 | 'Website', 73 | 'Django', 74 | 'Opencv', 75 | 'Programming', 76 | 'C', 77 | ...], 78 | 'total_experience': 1.83 79 | } 80 | ] 81 | ``` 82 | 83 | ## Supported Resume File Formats 84 | 85 | - Parsing of PDF and DOCx files are supported on all Operating Systems 86 | - If you want to parse DOC files you can install [textract](https://textract.readthedocs.io/en/stable/installation.html) for your OS (Linux, MacOS) 87 | - Note: You just have to install textract (and nothing else) and doc files will get parsed easily 88 | 89 | # Advanced Options 90 | 91 | ## Explicitly specifying skills file 92 | 93 | Pyresparser comes with built-in skills file that defaults to many technical skills. You can find the default skills file [here](https://github.com/OmkarPathak/pyresparser/blob/master/pyresparser/skills.csv). 94 | 95 | For extracting data against your specified skills, create a CSV file with no headers. 96 | 97 | ```python 98 | from pyresparser import ResumeParser 99 | data = ResumeParser('/path/to/resume/file', skills_file='/path/to/skills.csv').get_extracted_data() 100 | ``` 101 | 102 | ## Explicitly providing regex to parse phone numbers 103 | 104 | While pyresparser parses most of the phone numbers correctly, there is a possibility of new patterns being added in near future. Hence, we can explicitly provide the regex required to parse the desired phone numbers. This can be done using 105 | 106 | ```python 107 | from pyresparser import ResumeParser 108 | data = ResumeParser('/path/to/resume/file', custom_regex='pattern').get_extracted_data() 109 | ``` -------------------------------------------------------------------------------- /export_to_csv.py: -------------------------------------------------------------------------------- 1 | from pyresparser.resume_parser import ResumeParser 2 | from rank_candidate import sort_candidates 3 | from datetime import datetime 4 | import pandas as pd 5 | import sys 6 | import csv 7 | import os 8 | 9 | result = [] 10 | fields = ['Date', 'Skills', 'Name', 'Contact Number', 'Email ID', 'Current Company', 'Experience', 'College Name', 'Designation', 'Filename'] 11 | 12 | for root, directories, filenames in os.walk(sys.argv[1]): 13 | for filename in filenames: 14 | try: 15 | file_name = os.path.join(root, filename) 16 | print('Extracting data from ' + file_name) 17 | parser = ResumeParser(file_name) 18 | data = parser.get_extracted_data() 19 | name = data.get('name') 20 | email = data.get('email') 21 | mobile_number = data.get('mobile_number') 22 | skills = ', '.join(data.get('skills')) if data.get('skills') else '' 23 | total_experience = str(data.get('total_experience')) 24 | experience = ' '.join(data.get('experience')) if data.get('experience') else '' 25 | company_names = ', '.join(data.get('company_names')) if data.get('company_names') else '' 26 | college_name = data.get('college_name') 27 | designation = ', '.join(data.get('designation')) if data.get('designation') else '' 28 | 29 | result.append( 30 | [ 31 | datetime.today().strftime('%d-%B-%y'), 32 | skills, 33 | name, 34 | mobile_number, 35 | email, 36 | company_names, 37 | experience, 38 | college_name, 39 | designation, 40 | file_name 41 | ] 42 | ) 43 | except: 44 | continue 45 | 46 | # writing to csv file 47 | df = pd.DataFrame(result, columns=fields) 48 | 49 | try: 50 | ranked_df = sort_candidates(sys.argv[2], df) 51 | 52 | # Sort candidates in descending order of score 53 | ranked_df.sort_values(by="Score", ascending=False, inplace=True) 54 | ranked_df.to_csv(os.path.join(root, (datetime.today().strftime('Extracted-Resumes-%d-%m-%y.csv'))), index=False) 55 | except IndexError: 56 | df.to_csv(os.path.join(root, (datetime.today().strftime('Extracted-Resumes-%d-%m-%y.csv'))), index=False) 57 | 58 | # with open(os.path.join(root, (datetime.today().strftime('%d-%m-%y.csv'))), 'w', encoding="utf-8") as csvfile: 59 | # try: 60 | # # creating a csv writer object 61 | # csvwriter = csv.writer(csvfile) 62 | 63 | # # writing the fields 64 | # csvwriter.writerow(fields) 65 | 66 | # # writing the data rows 67 | # csvwriter.writerows(result) 68 | # except: 69 | # print('Some of the file might be corrupted or is not supported by parser') 70 | # print(ranked_df) 71 | -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: pyresparser 2 | nav: 3 | - Home: index.md 4 | - CLI: cli.md 5 | repo_url: https://github.com/OmkarPathak/pyresparser 6 | site_author: Omkar Pathak 7 | google_analytics: ['UA-111548790-1', 'omkarpathak.in'] 8 | markdown_extensions: 9 | - toc: 10 | permalink: True 11 | separator: "_" -------------------------------------------------------------------------------- /pre_requisites.py: -------------------------------------------------------------------------------- 1 | import os 2 | import nltk 3 | 4 | # Install SpaCy Dependencies 5 | os.system('python -m pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.3.1/en_core_web_sm-2.3.1.tar.gz') 6 | 7 | # Install nltk Dependencies 8 | nltk.download('maxent_ne_chunker') 9 | nltk.download('words') 10 | nltk.download('stopwords') 11 | nltk.download('punkt') 12 | nltk.download('wordnet') 13 | nltk.download('averaged_perceptron_tagger') -------------------------------------------------------------------------------- /pyresparser/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## What will be available in 1.0.6 2 | 3 | - Exporting data in JSON 4 | - More robust phone number parsing (earlier it was only for Indian numbers, now internationals are supported as well) 5 | - Custom regex option for parsing phone numbers 6 | - Added banner for CLI 7 | - Address parsing will be available 8 | - .doc parsing bug resolved 9 | - Tests are made available for better code coverage -------------------------------------------------------------------------------- /pyresparser/__init__.py: -------------------------------------------------------------------------------- 1 | from . import utils 2 | from . import constants 3 | from .resume_parser import ResumeParser 4 | 5 | __all__ = [ 6 | 'utils', 7 | 'constants', 8 | 'ResumeParser' 9 | ] 10 | -------------------------------------------------------------------------------- /pyresparser/command_line.py: -------------------------------------------------------------------------------- 1 | # Author: Omkar Pathak 2 | 3 | import os 4 | import json 5 | import argparse 6 | from pprint import pprint 7 | import io 8 | import sys 9 | import multiprocessing as mp 10 | import urllib 11 | from urllib.request import Request, urlopen 12 | from pyresparser import ResumeParser 13 | 14 | 15 | def print_cyan(text): 16 | print("\033[96m {}\033[00m" .format(text)) 17 | 18 | 19 | class ResumeParserCli(object): 20 | 21 | def __init__(self): 22 | self.__parser = argparse.ArgumentParser() 23 | self.__parser.add_argument( 24 | '-f', 25 | '--file', 26 | help="resume file to be extracted") 27 | self.__parser.add_argument( 28 | '-d', 29 | '--directory', 30 | help="directory containing all the resumes to be extracted") 31 | self.__parser.add_argument( 32 | '-r', 33 | '--remotefile', 34 | help="remote path for resume file to be extracted") 35 | self.__parser.add_argument( 36 | '-re', 37 | '--custom-regex', 38 | help="custom regex for parsing mobile numbers") 39 | self.__parser.add_argument( 40 | '-sf', 41 | '--skillsfile', 42 | help="custom skills CSV file against \ 43 | which skills are searched for") 44 | self.__parser.add_argument( 45 | '-e', 46 | '--export-format', 47 | help="the information export format (json)") 48 | self.__parser.add_argument( 49 | '-o', 50 | '--export-filepath', 51 | help="the export file path") 52 | 53 | def __banner(self): 54 | banner_string = r''' 55 | ____ __ __________ _________ ____ _____________ _____ 56 | / __ \/ / / / ___/ _ \/ ___/ __ \/ __ `/ ___/ ___/ _ \/ ___/ 57 | / /_/ / /_/ / / / __(__ ) /_/ / /_/ / / (__ ) __/ / 58 | / .___/\__, /_/ \___/____/ .___/\__,_/_/ /____/\___/_/ 59 | /_/ /____/ /_/ 60 | 61 | - By Omkar Pathak (omkarpathak27@gmail.com) 62 | ''' 63 | print(banner_string) 64 | 65 | def export_data(self, exported_data, args): 66 | '''function to export resume data in specified format 67 | ''' 68 | if args.export_format: 69 | if args.export_format == 'json': 70 | with open(args.export_filepath, 'w') as fd: 71 | json.dump(exported_data, fd, sort_keys=True, indent=4) 72 | abs_path = os.path.abspath(args.export_filepath) 73 | print('Data exported successfully at: ' + abs_path) 74 | sys.exit(0) 75 | else: 76 | return exported_data 77 | 78 | def extract_resume_data(self): 79 | args = self.__parser.parse_args() 80 | 81 | if args.export_format and not args.export_filepath: 82 | print('Please specify output file path using -o option') 83 | sys.exit(1) 84 | 85 | if args.remotefile: 86 | return self.export_data( 87 | self.__extract_from_remote_file( 88 | args.remotefile, 89 | args.skillsfile, 90 | args.custom_regex 91 | ), 92 | args 93 | ) 94 | 95 | if args.file and not args.directory: 96 | return self.export_data( 97 | self.__extract_from_file( 98 | args.file, 99 | args.skillsfile, 100 | args.custom_regex 101 | ), 102 | args 103 | ) 104 | elif args.directory and not args.file: 105 | return self.export_data( 106 | self.__extract_from_directory( 107 | args.directory, 108 | args.skillsfile, 109 | args.custom_regex 110 | ), 111 | args 112 | ) 113 | else: 114 | self.__parser.print_help() 115 | 116 | def __extract_from_file(self, file, skills_file=None, custom_regex=None): 117 | if os.path.exists(file): 118 | print_cyan('Extracting data from: {}'.format(file)) 119 | resume_parser = ResumeParser(file, skills_file, custom_regex) 120 | return [resume_parser.get_extracted_data()] 121 | else: 122 | print('File not found. Please provide a valid file name') 123 | sys.exit(1) 124 | 125 | def __extract_from_directory( 126 | self, 127 | directory, 128 | skills_file=None, 129 | custom_regex=None 130 | ): 131 | if os.path.exists(directory): 132 | pool = mp.Pool(mp.cpu_count()) 133 | 134 | resumes = [] 135 | for root, _, filenames in os.walk(directory): 136 | for filename in filenames: 137 | file = os.path.join(root, filename) 138 | resumes.append([file, skills_file, custom_regex]) 139 | results = pool.map(resume_result_wrapper, resumes) 140 | pool.close() 141 | pool.join() 142 | 143 | return results 144 | else: 145 | print('Directory not found. Please provide a valid directory') 146 | sys.exit(1) 147 | 148 | def __extract_from_remote_file( 149 | self, 150 | remote_file, 151 | skills_file, 152 | custom_regex 153 | ): 154 | try: 155 | print_cyan('Extracting data from: {}'.format(remote_file)) 156 | req = Request(remote_file, headers={'User-Agent': 'Mozilla/5.0'}) 157 | webpage = urlopen(req).read() 158 | _file = io.BytesIO(webpage) 159 | _file.name = remote_file.split('/')[-1] 160 | resume_parser = ResumeParser(_file, skills_file, custom_regex) 161 | return [resume_parser.get_extracted_data()] 162 | except urllib.error.HTTPError: 163 | print('File not found. Please provide correct URL for resume file') 164 | sys.exit(1) 165 | 166 | 167 | def resume_result_wrapper(args): 168 | print_cyan('Extracting data from: {}'.format(args[0])) 169 | parser = ResumeParser(args[0], args[1], args[2]) 170 | return parser.get_extracted_data() 171 | 172 | 173 | def main(): 174 | cli_obj = ResumeParserCli() 175 | pprint(cli_obj.extract_resume_data()) 176 | -------------------------------------------------------------------------------- /pyresparser/constants.py: -------------------------------------------------------------------------------- 1 | from nltk.corpus import stopwords 2 | 3 | # Omkar Pathak 4 | NAME_PATTERN = [{'POS': 'PROPN'}, {'POS': 'PROPN'}] 5 | 6 | # Education (Upper Case Mandatory) 7 | EDUCATION = [ 8 | 'BE', 'B.E.', 'B.E', 'BS', 'B.S', 'ME', 'M.E', 9 | 'M.E.', 'MS', 'M.S', 'BTECH', 'MTECH', 10 | 'SSC', 'HSC', 'CBSE', 'ICSE', 'X', 'XII' 11 | ] 12 | 13 | NOT_ALPHA_NUMERIC = r'[^a-zA-Z\d]' 14 | 15 | NUMBER = r'\d+' 16 | 17 | # For finding date ranges 18 | MONTHS_SHORT = r'''(jan)|(feb)|(mar)|(apr)|(may)|(jun)|(jul) 19 | |(aug)|(sep)|(oct)|(nov)|(dec)''' 20 | MONTHS_LONG = r'''(january)|(february)|(march)|(april)|(may)|(june)|(july)| 21 | (august)|(september)|(october)|(november)|(december)''' 22 | MONTH = r'(' + MONTHS_SHORT + r'|' + MONTHS_LONG + r')' 23 | YEAR = r'(((20|19)(\d{2})))' 24 | 25 | STOPWORDS = set(stopwords.words('english')) 26 | 27 | RESUME_SECTIONS_PROFESSIONAL = [ 28 | 'experience', 29 | 'education', 30 | 'interests', 31 | 'professional experience', 32 | 'publications', 33 | 'skills', 34 | 'certifications', 35 | 'objective', 36 | 'career objective', 37 | 'summary', 38 | 'leadership' 39 | ] 40 | 41 | RESUME_SECTIONS_GRAD = [ 42 | 'accomplishments', 43 | 'experience', 44 | 'education', 45 | 'interests', 46 | 'projects', 47 | 'professional experience', 48 | 'publications', 49 | 'skills', 50 | 'certifications', 51 | 'objective', 52 | 'career objective', 53 | 'summary', 54 | 'leadership' 55 | ] 56 | -------------------------------------------------------------------------------- /pyresparser/custom_t.py: -------------------------------------------------------------------------------- 1 | import os 2 | import io 3 | import spacy 4 | import docx2txt 5 | import constants as cs 6 | from pdfminer.converter import TextConverter 7 | from pdfminer.pdfinterp import PDFPageInterpreter 8 | from pdfminer.pdfinterp import PDFResourceManager 9 | from pdfminer.layout import LAParams 10 | from pdfminer.pdfpage import PDFPage 11 | from pdfminer.pdfparser import PDFSyntaxError 12 | 13 | 14 | def extract_text_from_pdf(pdf_path): 15 | ''' 16 | Helper function to extract the plain text from .pdf files 17 | 18 | :param pdf_path: path to PDF file to be extracted (remote or local) 19 | :return: iterator of string of extracted text 20 | ''' 21 | # https://www.blog.pythonlibrary.org/2018/05/03/exporting-data-from-pdfs-with-python/ 22 | if not isinstance(pdf_path, io.BytesIO): 23 | # extract text from local pdf file 24 | with open(pdf_path, 'rb') as fh: 25 | try: 26 | for page in PDFPage.get_pages( 27 | fh, 28 | caching=True, 29 | check_extractable=True 30 | ): 31 | resource_manager = PDFResourceManager() 32 | fake_file_handle = io.StringIO() 33 | converter = TextConverter( 34 | resource_manager, 35 | fake_file_handle, 36 | codec='utf-8', 37 | laparams=LAParams() 38 | ) 39 | page_interpreter = PDFPageInterpreter( 40 | resource_manager, 41 | converter 42 | ) 43 | page_interpreter.process_page(page) 44 | 45 | text = fake_file_handle.getvalue() 46 | yield text 47 | 48 | # close open handles 49 | converter.close() 50 | fake_file_handle.close() 51 | except PDFSyntaxError: 52 | return 53 | else: 54 | # extract text from remote pdf file 55 | try: 56 | for page in PDFPage.get_pages( 57 | pdf_path, 58 | caching=True, 59 | check_extractable=True 60 | ): 61 | resource_manager = PDFResourceManager() 62 | fake_file_handle = io.StringIO() 63 | converter = TextConverter( 64 | resource_manager, 65 | fake_file_handle, 66 | codec='utf-8', 67 | laparams=LAParams() 68 | ) 69 | page_interpreter = PDFPageInterpreter( 70 | resource_manager, 71 | converter 72 | ) 73 | page_interpreter.process_page(page) 74 | 75 | text = fake_file_handle.getvalue() 76 | yield text 77 | 78 | # close open handles 79 | converter.close() 80 | fake_file_handle.close() 81 | except PDFSyntaxError: 82 | return 83 | 84 | 85 | def get_number_of_pages(file_name): 86 | try: 87 | if isinstance(file_name, io.BytesIO): 88 | # for remote pdf file 89 | count = 0 90 | for page in PDFPage.get_pages( 91 | file_name, 92 | caching=True, 93 | check_extractable=True 94 | ): 95 | count += 1 96 | return count 97 | else: 98 | # for local pdf file 99 | if file_name.endswith('.pdf'): 100 | count = 0 101 | with open(file_name, 'rb') as fh: 102 | for page in PDFPage.get_pages( 103 | fh, 104 | caching=True, 105 | check_extractable=True 106 | ): 107 | count += 1 108 | return count 109 | else: 110 | return None 111 | except PDFSyntaxError: 112 | return None 113 | 114 | 115 | def extract_text_from_docx(doc_path): 116 | ''' 117 | Helper function to extract plain text from .docx files 118 | 119 | :param doc_path: path to .docx file to be extracted 120 | :return: string of extracted text 121 | ''' 122 | try: 123 | temp = docx2txt.process(doc_path) 124 | text = [line.replace('\t', ' ') for line in temp.split('\n') if line] 125 | return ' '.join(text) 126 | except KeyError: 127 | return ' ' 128 | 129 | 130 | def extract_text_from_doc(doc_path): 131 | ''' 132 | Helper function to extract plain text from .doc files 133 | 134 | :param doc_path: path to .doc file to be extracted 135 | :return: string of extracted text 136 | ''' 137 | try: 138 | try: 139 | import textract 140 | except ImportError: 141 | return ' ' 142 | temp = textract.process(doc_path).decode('utf-8') 143 | text = [line.replace('\t', ' ') for line in temp.split('\n') if line] 144 | return ' '.join(text) 145 | except KeyError: 146 | return ' ' 147 | 148 | 149 | def extract_text(file_path, extension): 150 | ''' 151 | Wrapper function to detect the file extension and call text 152 | extraction function accordingly 153 | 154 | :param file_path: path of file of which text is to be extracted 155 | :param extension: extension of file `file_name` 156 | ''' 157 | text = '' 158 | if extension == '.pdf': 159 | for page in extract_text_from_pdf(file_path): 160 | text += ' ' + page 161 | elif extension == '.docx': 162 | text = extract_text_from_docx(file_path) 163 | elif extension == '.doc': 164 | text = extract_text_from_doc(file_path) 165 | return text 166 | 167 | 168 | def extract_entity_sections_grad(text): 169 | ''' 170 | Helper function to extract all the raw text from sections of resume 171 | specifically for graduates and undergraduates 172 | 173 | :param text: Raw text of resume 174 | :return: dictionary of entities 175 | ''' 176 | text_split = [i.strip() for i in text.split('\n')] 177 | # sections_in_resume = [i for i in text_split if i.lower() in sections] 178 | entities = {} 179 | key = False 180 | for phrase in text_split: 181 | if len(phrase) == 1: 182 | p_key = phrase 183 | else: 184 | p_key = set(phrase.lower().split()) & set(cs.RESUME_SECTIONS_GRAD) 185 | try: 186 | p_key = list(p_key)[0] 187 | except IndexError: 188 | pass 189 | if p_key in cs.RESUME_SECTIONS_GRAD: 190 | entities[p_key] = [] 191 | key = p_key 192 | elif key and phrase.strip(): 193 | entities[key].append(phrase) 194 | return entities 195 | 196 | 197 | nlp = spacy.load(os.path.dirname(os.path.abspath(__file__))) 198 | # resumes = '/home/omkarpathak27/Documents/GITS/resumeparser/resumes/' 199 | # text_raw = extract_text(resume, '.pdf') 200 | # text = ' '.join(text_raw.split()) 201 | # print(text) 202 | # for resume in os.listdir(resumes): 203 | text_raw = extract_text( 204 | '/home/omkarpathak27/Downloads/OmkarResume.pdf', 205 | '.pdf' 206 | ) 207 | # entity = extract_entity_sections_grad(text_raw) 208 | # if 'experience' in entity.keys(): 209 | doc2 = nlp(text_raw) 210 | entities = {} 211 | for ent in doc2.ents: 212 | if ent.label_ not in entities.keys(): 213 | entities[ent.label_] = [ent.text] 214 | else: 215 | entities[ent.label_].append(ent.text) 216 | for key in entities.keys(): 217 | entities[key] = list(set(entities[key])) 218 | print(entities) 219 | # print(doc2.ents) 220 | -------------------------------------------------------------------------------- /pyresparser/custom_train.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf8 3 | """Example of training an additional entity type 4 | 5 | This script shows how to add a new entity type to an existing pre-trained NER 6 | model. To keep the example short and simple, only four sentences are provided 7 | as examples. In practice, you'll need many more — a few hundred would be a 8 | good start. You will also likely need to mix in examples of other entity 9 | types, which might be obtained by running the entity recognizer over unlabelled 10 | sentences, and adding their annotations to the training set. 11 | 12 | The actual training is performed by looping over the examples, and calling 13 | `nlp.entity.update()`. The `update()` method steps through the words of the 14 | input. At each word, it makes a prediction. It then consults the annotations 15 | provided on the GoldParse instance, to see whether it was right. If it was 16 | wrong, it adjusts its weights so that the correct action will score higher 17 | next time. 18 | 19 | After training your model, you can save it to a directory. We recommend 20 | wrapping models as Python packages, for ease of deployment. 21 | 22 | For more details, see the documentation: 23 | * Training: https://spacy.io/usage/training 24 | * NER: https://spacy.io/usage/linguistic-features#named-entities 25 | 26 | Compatible with: spaCy v2.1.0+ 27 | Last tested with: v2.1.0 28 | """ 29 | from __future__ import unicode_literals 30 | from __future__ import print_function 31 | import re 32 | import plac 33 | import random 34 | from pathlib import Path 35 | import spacy 36 | import json 37 | import logging 38 | 39 | 40 | # new entity label 41 | LABEL = "COL_NAME" 42 | 43 | # training data 44 | # Note: If you're using an existing model, make sure to mix in examples of 45 | # other entity types that spaCy correctly recognized before. Otherwise, your 46 | # model might learn the new type, but "forget" what it previously knew. 47 | # https://explosion.ai/blog/pseudo-rehearsal-catastrophic-forgetting 48 | 49 | # training data 50 | # TRAIN_DATA = [ 51 | # ("i study in maria college", {"entities": [(11, 24, LABEL)]}), 52 | # ("completed graduation from napier university (edinburgh, 53 | # united kingdom)", {"entities": [(26, 43, LABEL)]}), 54 | # ("studied in school of continuing and professional studies", 55 | # {"entities": [(11, 16, LABEL)]}), 56 | # ("studied at chinese university of hong kong", {"entities": 57 | # [(11, 29, LABEL)]}), 58 | # ("studied in University of Strathclyde", {"entities": 59 | # [(11, 37, LABEL)]}), 60 | # ] 61 | 62 | 63 | def trim_entity_spans(data: list) -> list: 64 | """Removes leading and trailing white spaces from entity spans. 65 | 66 | Args: 67 | data (list): The data to be cleaned in spaCy JSON format. 68 | 69 | Returns: 70 | list: The cleaned data. 71 | """ 72 | invalid_span_tokens = re.compile(r'\s') 73 | 74 | cleaned_data = [] 75 | for text, annotations in data: 76 | entities = annotations['entities'] 77 | valid_entities = [] 78 | for start, end, label in entities: 79 | valid_start = start 80 | valid_end = end 81 | while valid_start < len(text) and invalid_span_tokens.match( 82 | text[valid_start]): 83 | valid_start += 1 84 | while valid_end > 1 and invalid_span_tokens.match( 85 | text[valid_end - 1]): 86 | valid_end -= 1 87 | valid_entities.append([valid_start, valid_end, label]) 88 | cleaned_data.append([text, {'entities': valid_entities}]) 89 | 90 | return cleaned_data 91 | 92 | 93 | def convert_dataturks_to_spacy(dataturks_JSON_FilePath): 94 | try: 95 | training_data = [] 96 | lines = [] 97 | with open(dataturks_JSON_FilePath, 'r', encoding="utf8") as f: 98 | lines = f.readlines() 99 | 100 | for line in lines: 101 | data = json.loads(line) 102 | text = data['content'] 103 | entities = [] 104 | if data['annotation'] is not None: 105 | for annotation in data['annotation']: 106 | # only a single point in text annotation. 107 | point = annotation['points'][0] 108 | labels = annotation['label'] 109 | # handle both list of labels or a single label. 110 | if not isinstance(labels, list): 111 | labels = [labels] 112 | 113 | for label in labels: 114 | # dataturks indices are both inclusive [start, end] 115 | # but spacy is not [start, end) 116 | entities.append(( 117 | point['start'], 118 | point['end'] + 1, 119 | label 120 | )) 121 | 122 | training_data.append((text, {"entities": entities})) 123 | return training_data 124 | except Exception: 125 | logging.exception("Unable to process " + dataturks_JSON_FilePath) 126 | return None 127 | 128 | 129 | TRAIN_DATA = trim_entity_spans(convert_dataturks_to_spacy("traindata.json")) 130 | 131 | 132 | @plac.annotations( 133 | model=("Model name. Defaults to blank 'en' model.", "option", "m", str), 134 | new_model_name=("New model name for model meta.", "option", "nm", str), 135 | output_dir=("Optional output directory", "option", "o", Path), 136 | n_iter=("Number of training iterations", "option", "n", int), 137 | ) 138 | def main( 139 | model=None, 140 | new_model_name="training", 141 | output_dir='/home/omkarpathak27/Downloads/zipped/pyresparser/pyresparser', 142 | n_iter=30 143 | ): 144 | """Set up the pipeline and entity recognizer, and train the new entity.""" 145 | random.seed(0) 146 | if model is not None: 147 | nlp = spacy.load(model) # load existing spaCy model 148 | print("Loaded model '%s'" % model) 149 | else: 150 | nlp = spacy.blank("en") # create blank Language class 151 | print("Created blank 'en' model") 152 | # Add entity recognizer to model if it's not in the pipeline 153 | # nlp.create_pipe works for built-ins that are registered with spaCy 154 | 155 | if "ner" not in nlp.pipe_names: 156 | print("Creating new pipe") 157 | ner = nlp.create_pipe("ner") 158 | nlp.add_pipe(ner, last=True) 159 | 160 | # otherwise, get it, so we can add labels to it 161 | else: 162 | ner = nlp.get_pipe("ner") 163 | 164 | # add labels 165 | for _, annotations in TRAIN_DATA: 166 | for ent in annotations.get('entities'): 167 | ner.add_label(ent[2]) 168 | 169 | # if model is None or reset_weights: 170 | # optimizer = nlp.begin_training() 171 | # else: 172 | # optimizer = nlp.resume_training() 173 | move_names = list(ner.move_names) 174 | # get names of other pipes to disable them during training 175 | other_pipes = [pipe for pipe in nlp.pipe_names if pipe != "ner"] 176 | with nlp.disable_pipes(*other_pipes): # only train NER 177 | optimizer = nlp.begin_training() 178 | # batch up the examples using spaCy's minibatch 179 | for itn in range(n_iter): 180 | print("Starting iteration " + str(itn)) 181 | random.shuffle(TRAIN_DATA) 182 | losses = {} 183 | for text, annotations in TRAIN_DATA: 184 | nlp.update( 185 | [text], # batch of texts 186 | [annotations], # batch of annotations 187 | drop=0.2, # dropout - make it harder to memorise data 188 | sgd=optimizer, # callable to update weights 189 | losses=losses) 190 | print("Losses", losses) 191 | 192 | # test the trained model 193 | test_text = "Marathwada Mitra Mandals College of Engineering" 194 | doc = nlp(test_text) 195 | print("Entities in '%s'" % test_text) 196 | for ent in doc.ents: 197 | print(ent.label_, ent.text) 198 | 199 | # save model to output directory 200 | if output_dir is not None: 201 | output_dir = Path(output_dir) 202 | if not output_dir.exists(): 203 | output_dir.mkdir() 204 | nlp.meta["name"] = new_model_name # rename model 205 | nlp.to_disk(output_dir) 206 | print("Saved model to", output_dir) 207 | 208 | # test the saved model 209 | print("Loading from", output_dir) 210 | nlp2 = spacy.load(output_dir) 211 | # Check the classes have loaded back consistently 212 | assert nlp2.get_pipe("ner").move_names == move_names 213 | doc2 = nlp2(test_text) 214 | for ent in doc2.ents: 215 | print(ent.label_, ent.text) 216 | 217 | 218 | if __name__ == "__main__": 219 | plac.call(main) 220 | -------------------------------------------------------------------------------- /pyresparser/meta.json: -------------------------------------------------------------------------------- 1 | {"lang":"en","name":"training","version":"0.0.0","spacy_version":">=2.1.4","description":"","author":"","email":"","url":"","license":"","vectors":{"width":0,"vectors":0,"keys":0,"name":"spacy_pretrained_vectors"},"pipeline":["ner"]} -------------------------------------------------------------------------------- /pyresparser/ner/cfg: -------------------------------------------------------------------------------- 1 | { 2 | "beam_width":1, 3 | "beam_density":0.0, 4 | "beam_update_prob":1.0, 5 | "cnn_maxout_pieces":3, 6 | "nr_class":101, 7 | "hidden_depth":1, 8 | "token_vector_width":96, 9 | "hidden_width":64, 10 | "maxout_pieces":2, 11 | "pretrained_vectors":null, 12 | "bilstm_depth":0 13 | } -------------------------------------------------------------------------------- /pyresparser/ner/model: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OmkarPathak/pyresparser/a66f25b583f2dd8dbd18f419321eed57b04a006e/pyresparser/ner/model -------------------------------------------------------------------------------- /pyresparser/ner/moves: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OmkarPathak/pyresparser/a66f25b583f2dd8dbd18f419321eed57b04a006e/pyresparser/ner/moves -------------------------------------------------------------------------------- /pyresparser/requirements.txt: -------------------------------------------------------------------------------- 1 | attrs==19.1.0 2 | blis==0.2.4 3 | certifi==2019.6.16 4 | chardet==3.0.4 5 | cymem==2.0.2 6 | docx2txt==0.7 7 | idna==2.8 8 | jsonschema==3.0.1 9 | murmurhash==1.0.2 10 | nltk==3.4.5 11 | numpy==1.16.4 12 | pandas==0.24.2 13 | pdfminer.six==20181108 14 | plac==0.9.6 15 | preshed==2.0.1 16 | pycryptodome==3.8.2 17 | pyrsistent==0.15.2 18 | python-dateutil==2.8.0 19 | pytz==2019.1 20 | requests==2.22.0 21 | six==1.12.0 22 | sortedcontainers==2.1.0 23 | spacy==2.1.4 24 | srsly==0.0.7 25 | textract==1.6.1 26 | thinc==7.0.4 27 | tqdm==4.32.2 28 | urllib3==1.25.3 29 | wasabi==0.2.2 -------------------------------------------------------------------------------- /pyresparser/resume_parser.py: -------------------------------------------------------------------------------- 1 | # Author: Omkar Pathak 2 | 3 | import os 4 | import multiprocessing as mp 5 | import io 6 | import spacy 7 | import pprint 8 | from spacy.matcher import Matcher 9 | from . import utils 10 | 11 | 12 | class ResumeParser(object): 13 | 14 | def __init__( 15 | self, 16 | resume, 17 | skills_file=None, 18 | custom_regex=None 19 | ): 20 | nlp = spacy.load('en_core_web_sm') 21 | custom_nlp = spacy.load(os.path.dirname(os.path.abspath(__file__))) 22 | self.__skills_file = skills_file 23 | self.__custom_regex = custom_regex 24 | self.__matcher = Matcher(nlp.vocab) 25 | self.__details = { 26 | 'name': None, 27 | 'email': None, 28 | 'mobile_number': None, 29 | 'skills': None, 30 | 'college_name': None, 31 | 'degree': None, 32 | 'designation': None, 33 | 'experience': None, 34 | 'company_names': None, 35 | 'no_of_pages': None, 36 | 'total_experience': None, 37 | } 38 | self.__resume = resume 39 | if not isinstance(self.__resume, io.BytesIO): 40 | ext = os.path.splitext(self.__resume)[1].split('.')[1] 41 | else: 42 | ext = self.__resume.name.split('.')[1] 43 | self.__text_raw = utils.extract_text(self.__resume, '.' + ext) 44 | self.__text = ' '.join(self.__text_raw.split()) 45 | self.__nlp = nlp(self.__text) 46 | self.__custom_nlp = custom_nlp(self.__text_raw) 47 | self.__noun_chunks = list(self.__nlp.noun_chunks) 48 | self.__get_basic_details() 49 | 50 | def get_extracted_data(self): 51 | return self.__details 52 | 53 | def __get_basic_details(self): 54 | cust_ent = utils.extract_entities_wih_custom_model( 55 | self.__custom_nlp 56 | ) 57 | name = utils.extract_name(self.__nlp, matcher=self.__matcher) 58 | email = utils.extract_email(self.__text) 59 | mobile = utils.extract_mobile_number(self.__text, self.__custom_regex) 60 | skills = utils.extract_skills( 61 | self.__nlp, 62 | self.__noun_chunks, 63 | self.__skills_file 64 | ) 65 | # edu = utils.extract_education( 66 | # [sent.string.strip() for sent in self.__nlp.sents] 67 | # ) 68 | entities = utils.extract_entity_sections_grad(self.__text_raw) 69 | 70 | # extract name 71 | try: 72 | self.__details['name'] = cust_ent['Name'][0] 73 | except (IndexError, KeyError): 74 | self.__details['name'] = name 75 | 76 | # extract email 77 | self.__details['email'] = email 78 | 79 | # extract mobile number 80 | self.__details['mobile_number'] = mobile 81 | 82 | # extract skills 83 | self.__details['skills'] = skills 84 | 85 | # extract college name 86 | try: 87 | self.__details['college_name'] = entities['College Name'] 88 | except KeyError: 89 | pass 90 | 91 | # extract education Degree 92 | try: 93 | self.__details['degree'] = cust_ent['Degree'] 94 | except KeyError: 95 | pass 96 | 97 | # extract designation 98 | try: 99 | self.__details['designation'] = cust_ent['Designation'] 100 | except KeyError: 101 | pass 102 | 103 | # extract company names 104 | try: 105 | self.__details['company_names'] = cust_ent['Companies worked at'] 106 | except KeyError: 107 | pass 108 | 109 | try: 110 | self.__details['experience'] = entities['experience'] 111 | try: 112 | exp = round( 113 | utils.get_total_experience(entities['experience']) / 12, 114 | 2 115 | ) 116 | self.__details['total_experience'] = exp 117 | except KeyError: 118 | self.__details['total_experience'] = 0 119 | except KeyError: 120 | self.__details['total_experience'] = 0 121 | self.__details['no_of_pages'] = utils.get_number_of_pages( 122 | self.__resume 123 | ) 124 | return 125 | 126 | 127 | def resume_result_wrapper(resume): 128 | parser = ResumeParser(resume) 129 | return parser.get_extracted_data() 130 | 131 | 132 | if __name__ == '__main__': 133 | pool = mp.Pool(mp.cpu_count()) 134 | 135 | resumes = [] 136 | data = [] 137 | for root, directories, filenames in os.walk('resumes/'): 138 | for filename in filenames: 139 | file = os.path.join(root, filename) 140 | resumes.append(file) 141 | 142 | results = [ 143 | pool.apply_async( 144 | resume_result_wrapper, 145 | args=(x,) 146 | ) for x in resumes 147 | ] 148 | 149 | results = [p.get() for p in results] 150 | 151 | pprint.pprint(results) 152 | -------------------------------------------------------------------------------- /pyresparser/skills.csv: -------------------------------------------------------------------------------- 1 | technical skills,ajenti,django-suit,django-xadmin,flask-admin,flower,grappelli,wooey,algorithms,pypattyrn,python-patterns,sortedcontainers,django-simple-captcha,django-simple-spam-blocker,django-compressor,django-pipeline,django-storages,fanstatic,fileconveyor,flask-assets,jinja-assets-compressor,webassets,audiolazy,audioread,beets,dejavu,django-elastic-transcoder,eyed3,id3reader,m3u8,mingus,pyaudioanalysis,pydub,pyechonest,talkbox,timeside,tinytag,authomatic,django-allauth,django-oauth-toolkit,flask-oauthlib,oauthlib,python-oauth2,python-social-auth,rauth,sanction,jose,pyjwt,python-jws,python-jwt,bitbake,buildout,platformio,pybuilder,scons,django-cms,djedi-cms,feincms,kotti,mezzanine,opps,plone,quokka,wagtail,widgy,beaker,diskcache,django-cache-machine,django-cacheops,django-viewlet,dogpile.cache,hermescache,johnny-cache,pylibmc,errbot,coala,code2flow,pycallgraph,flake8,pylama,pylint,mypy,asciimatics,cement,click,cliff,clint,colorama,docopt,gooey,python-fire,python-prompt-toolkit,aws-cli,bashplotlib,caniusepython3,cookiecutter,doitlive,howdoi,httpie,mycli,pathpicker,percol,pgcli,saws,thefuck,try,python-future,python-modernize,six,opencv,pyocr,pytesseract,simplecv,eventlet,gevent,multiprocessing,threading,tomorrow,uvloop,config,configobj,configparser,profig,python-decouple,cryptography,hashids,paramiko,passlib,pynacl,blaze,orange,pandas,cerberus,colander,jsonschema,schematics,valideer,voluptuous,altair,bokeh,ggplot,matplotlib,pygal,pygraphviz,pyqtgraph,seaborn,vispy,pickledb,pipelinedb,tinydb,zodb,mysql,mysql-python,mysqlclient,oursql,pymysql,postgresql,psycopg2,queries,txpostgres,apsw,pymssql,nosql,cassandra-python-driver,happybase,plyvel,py2neo,pycassa,pymongo,redis-py,telephus,txredis,arrow,chronyk,dateutil,delorean,moment,pendulum,pytime,pytz,when.py,ipdb,pdb++,pudb,remote-pdb,wdb,line_profiler,memory_profiler,profiling,vprof,caffe,keras,mxnet,neupy,pytorch,tensorflow,theano,ansible,cloud-init,cuisine,docker,fabric,fabtools,honcho,openstack,pexpect,psutil,saltstack,supervisor,dh-virtualenv,nuitka,py2app,py2exe,pyinstaller,pynsist,sphinx,awesome-sphinxdoc,mkdocs,pdoc,pycco,s3cmd,s4cmd,you-get,youtube-dl,alipay,cartridge,django-oscar,django-shop,merchant,money,python-currencies,forex-python,shoop,emacs,elpy,sublime,anaconda,sublimejedi,vim,jedi-vim,python-mode,youcompleteme,ptvs,visual,python,magic,liclipse,pycharm,spyder,envelopes,flanker,imbox,inbox.py,lamson,marrow,modoboa,nylas,yagmail,pipenv,p,pyenv,venv,virtualenv,virtualenvwrapper,imghdr,mimetypes,path.py,pathlib,python-magic,unipath,watchdog,cffi,ctypes,pycuda,swig,deform,django-bootstrap3,django-crispy-forms,django-remote-forms,wtforms,cytoolz,fn.py,funcy,toolz,curses,enaml,flexx,kivy,pyglet,pygobject,pyqt,pyside,pywebview,tkinter,toga,urwid,wxpython,cocos2d,panda3d,pygame,pyogre,pyopengl,pysdl2,renpy,django-countries,geodjango,geoip,geojson,geopy,pygeoip,beautifulsoup,bleach,cssutils,html5lib,lxml,markupsafe,pyquery,untangle,weasyprint,xmldataset,xmltodict,grequests,httplib2,requests,treq,urllib3,ino,keyboard,mouse,pingo,pyro,pyuserinput,scapy,wifi,hmap,imgseek,nude.py,pagan,pillow,pybarcode,pygram,python-qrcode,quads,scikit-image,thumbor,wand,clpython,cpython,cython,grumpy,ironpython,jython,micropython,numba,peachpy,pyjion,pypy,pysec,pyston,stackless,interactive,bpython,jupyter,ptpython,babel,pyicu,apscheduler,django-schedule,doit,gunnery,joblib,plan,schedule,spiff,taskflow,eliot,logbook,logging,sentry,metrics,nupic,scikit-learn,spark,vowpal_porpoise,xgboost,pyspark,luigi,mrjob,streamparse,dask,python(x,y),pythonlibs,pythonnet,pywin32,winpython,gensim,jieba,langid.py,nltk,pattern,polyglot,snownlp,spacy,textblob,mininet,pox,pyretic,sdx,asyncio,diesel,pulsar,pyzmq,twisted,txzmq,napalm,django-activity-stream,stream-framework,django,sqlalchemy,awesome-sqlalchemy,orator,peewee,ponyorm,pydal,python-sql,pip,conda,curdling,pip-tools,wheel,warehouse,bandersnatch,devpi,localshop,carteblanche,django-guardian,django-rules,delegator.py subprocesses for,sarge,sh,celery,huey,mrq,rq,simpleq,annoy,fastfm,implicit,libffm,lightfm,surprise,tensorrec,django-rest-framework,django-tastypie,flask,eve,flask-api-utils,flask-api,flask-restful,flask-restless,pyramid,cornice,falcon,hug,restless,ripozo,sandman,apistar,simplejsonrpcserver,simplexmlrpcserver,zerorpc,astropy,bcbio-nextgen,bccb,biopython,cclib,networkx,nipy,numpy,obspy,pydy,pymc,rdkit,scipy,statsmodels,sympy,zipline,simpy,django-haystack,elasticsearch-dsl-py,elasticsearch-py,esengine,pysolr,solrpy,whoosh,marshmallow,apex,python-lambda,zappa,tablib,marmir,openpyxl,pyexcel,python-docx,relatorio,unoconv,xlsxwriter,xlwings,xlwt / xlrd,pdf,pdfminer,pypdf2,reportlab,markdown,mistune,python-markdown,yaml,pyyaml,csvkit,unp,cactus,hyde,lektor,nikola,pelican,tinkerer,django-taggit,genshi,jinja2,mako,hypothesis,mamba,nose,nose2,pytest,robot,unittest,green,tox,locust,pyautogui,selenium,sixpack,splinter,doublex,freezegun,httmock,httpretty,mock,responses,vcr.py,factory_boy,mixer,model_mommy,mimesis,fake2db,faker,radar,chardet,difflib,ftfy,fuzzywuzzy,levenshtein,pangu.py,pyfiglet,pypinyin,shortuuid,unidecode,uniout,xpinyin,slugify,awesome-slugify,python-slugify,unicode-slugify,parser,phonenumbers,ply,pygments,pyparsing,python-nameparser,python-user-agents,sqlparse,apache-libcloud,boto3,django-wordpress,facebook-sdk,facepy,gmail,google-api-python-client,gspread,twython,furl,purl,pyshorteners,short_url,webargs,moviepy,scikit-video,wsgi-compatible,bjoern,fapws3,gunicorn,meinheld,netius,paste,rocket,uwsgi,waitress,werkzeug,haul,html2text,lassie,micawber,newspaper,opengraph,python-goose,python-readability,sanitize,sumy,textract,cola,demiurge,feedparser,grab,mechanicalsoup,portia,pyspider,robobrowser,scrapy,bottle,cherrypy,awesome-django,awesome-flask,awesome-pyramid,sanic,tornado,turbogears,web2py,github,autobahnpython,crossbar,django-socketio,websocket-for-python,javascript,php,c#,c++,ruby,css,c,objective-c,shell,scala,swift,matlab,clojure,octave,machine learning,data analytics,predictive analytics,html,js,accounts payable,receivables,inventory controls,payroll,deposits,bank reconciliation,planning and enacting cash-flows,report preparation,financial models,financial controls,documentation,time management,schedules,benchmarking,future state assessment,business process re-engineering,as-is analysis,defining solutions and scope,gap analysis,role change,wireframing,prototyping,user stories,financial analysis/modeling,swot analysis,quickbooks,quicken,erp,enterprise resource planning,spanish,german,rest,soap,json,website,ui,ux,design,crm,cms,communication,coding,windows,servers,unix,linux,redhat,solaris,java,perl,vb script,xml,database,oracle,microsoft sql,sql,microsoft word,microsoft powerpoint,powerpoint,word,excel,visio,microsoft visio,microsoft excel,adobe,photoshop,hadoop,hbase,hive,zookeeper,openserver,auto cad,pl/sql,ruby on rails,asp,jsp,operations,technical,training,sales,marketing,reporting,compliance,strategy,research,analytical,engineering,policies,budget,finance,project management,health,customer service,content,presentation,brand,presentations,safety,certification,seo,digital marketing,accounting,regulations,legal,engagement,analytics,distribution,coaching,testing,vendors,consulting,writing,contracts,inventory,retail,healthcare,regulatory,scheduling,construction,logistics,mobile,c�(programming language),correspondence,controls,human resources,specifications,recruitment,procurement,partnership,partnerships,management experience,negotiation,hardware,programming,agile,forecasting,advertising,business development,audit,architecture,supply chain,governance,staffing,continuous improvement,product development,networking,recruiting,product management,sap,troubleshooting,computer science,budgeting,electrical,customer experience,economics,information technology,transportation,social media,automation,lifecycle,filing,modeling,investigation,editing,purchasing,kpis,hospital,forecasts,acquisition,expenses,billing,workflow,product owner,analyze,cross functional,business process,process,improvement,pivot tables,pivot,vlookups,sharepoint,microsoft sharepoint,access database,access,test case,jira,tfs,hp alm,tableau,business object,business intelligence,jad,solicitation,kaban,vue.js,sketch,indesign,illustrator,english,french,active directory,data center,solution architecture,dns,network design,open source,desktop support,application support,administration,change management,video,invoices,administrative support,payments,lean,process improvement,installation,risk management,transactions,investigations,r (programming language),data analysis,statistics,protocols,program management,quality assurance,banking,outreach,sourcing,microsoft office,merchandising,r,teaching,pharmaceutical,fulfillment,positioning,tax,service delivery,investigate,editorial,account management,valid drivers license,electronics,pr,public relations,assembly,facebook,spreadsheets,recruit,proposal,data entry,hotel,ordering,branding,life cycle,real estate,relationship management,researching,process improvements,chemistry,saas,cad,sales experience,mathematics,customer-facing,audio,project management skills,six sigma,hospitality,mechanical engineering,auditing,employee relations,android,security clearance,licensing,fundraising,repairs,iso,market research,business strategy,pmp,data management,quality control,reconciliation,conversion,business analysis,financial analysis,ecommerce,client service,publishing,supervising,complex projects,key performance indicators,scrum,sports,e-commerce,journalism,d (programming language),data collection,higher education,marketing programs,financial management,business plans,user experience,client relationships,cloud,analytical skills,cisco,internal stakeholders,product marketing,regulatory requirements,itil,information security,aviation,supply chain management,industry experience,autocad,purchase orders,acquisitions,tv,instrumentation,strategic direction,law enforcement,call center,experiments,technical skills,human resource,business cases,build relationships,invoicing,support services,marketing strategy,operating systems,biology,start-up,electrical engineering,workflows,routing,non-profit,marketing plans,due diligence,business management,iphone,architectures,reconcile,dynamic environment,external partners,asset management,emea,intranet,sops,sas,digital media,prospecting,financial reporting,project delivery,operational excellence,standard operating procedures,technical knowledge,on-call,talent management,stakeholder management,tablets,analyze data,financial statements,microsoft office suite,fitness,case management,value proposition,industry trends,rfp,broadcast,portfolio management,fabrication,financial performance,customer requirements,psychology,marketing materials,resource management,physics,mortgage,development activities,end user,business planning,root cause,analysis,leadership development,relationship building,sdlc,on-boarding,quality standards,regulatory compliance,aws,kpi,status reports,product line,drafting,phone calls,product knowledge,business stakeholders,technical issues,admissions,supervisory experience,usability,pharmacy,commissioning,project plan,ms excel,fda,test plans,variances,financing,travel arrangements,internal customers,medical device,counsel,inventory management,performance metrics,lighting,outsourcing,performance improvement,management consulting,graphic design,transport,information management,.net,startup,matrix,front-end,project planning,business systems,accounts receivable,public health,hris,instructional design,in-store,employee engagement,cost effective,sales management,api,adobe creative suite,twitter,program development,event planning,cash flow,strategic plans,vendor management,trade shows,hotels,segmentation,contract management,gis,talent acquisition,photography,internal communications,client services,ibm,financial reports,product quality,beverage,strong analytical skills,underwriting,cpr,mining,sales goals,chemicals,scripting,migration,software engineering,mis,therapeutic,general ledger,ms project,standardization,retention,spelling,media relations,os,daily operations,immigration,product design,etl,field sales,driving record,peoplesoft,benchmark,quality management,apis,test cases,internal controls,telecom,business issues,research projects,data quality,strategic initiatives,office software,cfa,co-op,big data,journal entries,vmware,help desk,statistical analysis,datasets,alliances,solidworks,prototype,lan,sci,budget management,rfps,flex,gaap,experimental,cpg,information system,customer facing,process development,web services,international,travel,revenue growth,software development life cycle,operations management,computer applications,risk assessments,sales operations,raw materials,internal audit,physical security,sql server,affiliate,computer software,manage projects,business continuity,litigation,it infrastructure,cost reduction,small business,annual budget,ios,html5,real-time,consulting experience,circuits,risk assessment,cross-functional team,public policy,analyzing data,consulting services,google drive,ad words,pay per click,email,db2,expense tracking,reports,wordpress,yoast,ghostwriting,corel draw,automated billing,system,customer management,debugging,system administration,network configuration,software installation,security,tech support,updates,tci/ip,dhcp,wan/lan,ubuntu,virtualized networks,network automation,cloud management,ai,salesforce,mango db,math,calculus,product launch,mvp 2 | -------------------------------------------------------------------------------- /pyresparser/tokenizer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OmkarPathak/pyresparser/a66f25b583f2dd8dbd18f419321eed57b04a006e/pyresparser/tokenizer -------------------------------------------------------------------------------- /pyresparser/utils.py: -------------------------------------------------------------------------------- 1 | # Author: Omkar Pathak 2 | 3 | import io 4 | import os 5 | import re 6 | import nltk 7 | import pandas as pd 8 | import docx2txt 9 | from datetime import datetime 10 | from dateutil import relativedelta 11 | from . import constants as cs 12 | from pdfminer.converter import TextConverter 13 | from pdfminer.pdfinterp import PDFPageInterpreter 14 | from pdfminer.pdfinterp import PDFResourceManager 15 | from pdfminer.layout import LAParams 16 | from pdfminer.pdfpage import PDFPage 17 | from pdfminer.pdfparser import PDFSyntaxError 18 | from nltk.stem import WordNetLemmatizer 19 | from nltk.corpus import stopwords 20 | 21 | 22 | def extract_text_from_pdf(pdf_path): 23 | ''' 24 | Helper function to extract the plain text from .pdf files 25 | 26 | :param pdf_path: path to PDF file to be extracted (remote or local) 27 | :return: iterator of string of extracted text 28 | ''' 29 | # https://www.blog.pythonlibrary.org/2018/05/03/exporting-data-from-pdfs-with-python/ 30 | if not isinstance(pdf_path, io.BytesIO): 31 | # extract text from local pdf file 32 | with open(pdf_path, 'rb') as fh: 33 | try: 34 | for page in PDFPage.get_pages( 35 | fh, 36 | caching=True, 37 | check_extractable=True 38 | ): 39 | resource_manager = PDFResourceManager() 40 | fake_file_handle = io.StringIO() 41 | converter = TextConverter( 42 | resource_manager, 43 | fake_file_handle, 44 | codec='utf-8', 45 | laparams=LAParams() 46 | ) 47 | page_interpreter = PDFPageInterpreter( 48 | resource_manager, 49 | converter 50 | ) 51 | page_interpreter.process_page(page) 52 | 53 | text = fake_file_handle.getvalue() 54 | yield text 55 | 56 | # close open handles 57 | converter.close() 58 | fake_file_handle.close() 59 | except PDFSyntaxError: 60 | return 61 | else: 62 | # extract text from remote pdf file 63 | try: 64 | for page in PDFPage.get_pages( 65 | pdf_path, 66 | caching=True, 67 | check_extractable=True 68 | ): 69 | resource_manager = PDFResourceManager() 70 | fake_file_handle = io.StringIO() 71 | converter = TextConverter( 72 | resource_manager, 73 | fake_file_handle, 74 | codec='utf-8', 75 | laparams=LAParams() 76 | ) 77 | page_interpreter = PDFPageInterpreter( 78 | resource_manager, 79 | converter 80 | ) 81 | page_interpreter.process_page(page) 82 | 83 | text = fake_file_handle.getvalue() 84 | yield text 85 | 86 | # close open handles 87 | converter.close() 88 | fake_file_handle.close() 89 | except PDFSyntaxError: 90 | return 91 | 92 | 93 | def get_number_of_pages(file_name): 94 | try: 95 | if isinstance(file_name, io.BytesIO): 96 | # for remote pdf file 97 | count = 0 98 | for page in PDFPage.get_pages( 99 | file_name, 100 | caching=True, 101 | check_extractable=True 102 | ): 103 | count += 1 104 | return count 105 | else: 106 | # for local pdf file 107 | if file_name.endswith('.pdf'): 108 | count = 0 109 | with open(file_name, 'rb') as fh: 110 | for page in PDFPage.get_pages( 111 | fh, 112 | caching=True, 113 | check_extractable=True 114 | ): 115 | count += 1 116 | return count 117 | else: 118 | return None 119 | except PDFSyntaxError: 120 | return None 121 | 122 | 123 | def extract_text_from_docx(doc_path): 124 | ''' 125 | Helper function to extract plain text from .docx files 126 | 127 | :param doc_path: path to .docx file to be extracted 128 | :return: string of extracted text 129 | ''' 130 | try: 131 | temp = docx2txt.process(doc_path) 132 | text = [line.replace('\t', ' ') for line in temp.split('\n') if line] 133 | return ' '.join(text) 134 | except KeyError: 135 | return ' ' 136 | 137 | 138 | def extract_text_from_doc(doc_path): 139 | ''' 140 | Helper function to extract plain text from .doc files 141 | 142 | :param doc_path: path to .doc file to be extracted 143 | :return: string of extracted text 144 | ''' 145 | try: 146 | try: 147 | import textract 148 | except ImportError: 149 | return ' ' 150 | text = textract.process(doc_path).decode('utf-8') 151 | return text 152 | except KeyError: 153 | return ' ' 154 | 155 | 156 | def extract_text(file_path, extension): 157 | ''' 158 | Wrapper function to detect the file extension and call text 159 | extraction function accordingly 160 | 161 | :param file_path: path of file of which text is to be extracted 162 | :param extension: extension of file `file_name` 163 | ''' 164 | text = '' 165 | if extension == '.pdf': 166 | for page in extract_text_from_pdf(file_path): 167 | text += ' ' + page 168 | elif extension == '.docx': 169 | text = extract_text_from_docx(file_path) 170 | elif extension == '.doc': 171 | text = extract_text_from_doc(file_path) 172 | return text 173 | 174 | 175 | def extract_entity_sections_grad(text): 176 | ''' 177 | Helper function to extract all the raw text from sections of 178 | resume specifically for graduates and undergraduates 179 | 180 | :param text: Raw text of resume 181 | :return: dictionary of entities 182 | ''' 183 | text_split = [i.strip() for i in text.split('\n')] 184 | # sections_in_resume = [i for i in text_split if i.lower() in sections] 185 | entities = {} 186 | key = False 187 | for phrase in text_split: 188 | if len(phrase) == 1: 189 | p_key = phrase 190 | else: 191 | p_key = set(phrase.lower().split()) & set(cs.RESUME_SECTIONS_GRAD) 192 | try: 193 | p_key = list(p_key)[0] 194 | except IndexError: 195 | pass 196 | if p_key in cs.RESUME_SECTIONS_GRAD: 197 | entities[p_key] = [] 198 | key = p_key 199 | elif key and phrase.strip(): 200 | entities[key].append(phrase) 201 | 202 | # entity_key = False 203 | # for entity in entities.keys(): 204 | # sub_entities = {} 205 | # for entry in entities[entity]: 206 | # if u'\u2022' not in entry: 207 | # sub_entities[entry] = [] 208 | # entity_key = entry 209 | # elif entity_key: 210 | # sub_entities[entity_key].append(entry) 211 | # entities[entity] = sub_entities 212 | 213 | # pprint.pprint(entities) 214 | 215 | # make entities that are not found None 216 | # for entity in cs.RESUME_SECTIONS: 217 | # if entity not in entities.keys(): 218 | # entities[entity] = None 219 | return entities 220 | 221 | 222 | def extract_entities_wih_custom_model(custom_nlp_text): 223 | ''' 224 | Helper function to extract different entities with custom 225 | trained model using SpaCy's NER 226 | 227 | :param custom_nlp_text: object of `spacy.tokens.doc.Doc` 228 | :return: dictionary of entities 229 | ''' 230 | entities = {} 231 | for ent in custom_nlp_text.ents: 232 | if ent.label_ not in entities.keys(): 233 | entities[ent.label_] = [ent.text] 234 | else: 235 | entities[ent.label_].append(ent.text) 236 | for key in entities.keys(): 237 | entities[key] = list(set(entities[key])) 238 | return entities 239 | 240 | 241 | def get_total_experience(experience_list): 242 | ''' 243 | Wrapper function to extract total months of experience from a resume 244 | 245 | :param experience_list: list of experience text extracted 246 | :return: total months of experience 247 | ''' 248 | exp_ = [] 249 | for line in experience_list: 250 | experience = re.search( 251 | r'(?P\w+.\d+)\s*(\D|to)\s*(?P\w+.\d+|present)', 252 | line, 253 | re.I 254 | ) 255 | if experience: 256 | exp_.append(experience.groups()) 257 | total_exp = sum( 258 | [get_number_of_months_from_dates(i[0], i[2]) for i in exp_] 259 | ) 260 | total_experience_in_months = total_exp 261 | return total_experience_in_months 262 | 263 | 264 | def get_number_of_months_from_dates(date1, date2): 265 | ''' 266 | Helper function to extract total months of experience from a resume 267 | 268 | :param date1: Starting date 269 | :param date2: Ending date 270 | :return: months of experience from date1 to date2 271 | ''' 272 | if date2.lower() == 'present': 273 | date2 = datetime.now().strftime('%b %Y') 274 | try: 275 | if len(date1.split()[0]) > 3: 276 | date1 = date1.split() 277 | date1 = date1[0][:3] + ' ' + date1[1] 278 | if len(date2.split()[0]) > 3: 279 | date2 = date2.split() 280 | date2 = date2[0][:3] + ' ' + date2[1] 281 | except IndexError: 282 | return 0 283 | try: 284 | date1 = datetime.strptime(str(date1), '%b %Y') 285 | date2 = datetime.strptime(str(date2), '%b %Y') 286 | months_of_experience = relativedelta.relativedelta(date2, date1) 287 | months_of_experience = (months_of_experience.years 288 | * 12 + months_of_experience.months) 289 | except ValueError: 290 | return 0 291 | return months_of_experience 292 | 293 | 294 | def extract_entity_sections_professional(text): 295 | ''' 296 | Helper function to extract all the raw text from sections of 297 | resume specifically for professionals 298 | 299 | :param text: Raw text of resume 300 | :return: dictionary of entities 301 | ''' 302 | text_split = [i.strip() for i in text.split('\n')] 303 | entities = {} 304 | key = False 305 | for phrase in text_split: 306 | if len(phrase) == 1: 307 | p_key = phrase 308 | else: 309 | p_key = set(phrase.lower().split()) \ 310 | & set(cs.RESUME_SECTIONS_PROFESSIONAL) 311 | try: 312 | p_key = list(p_key)[0] 313 | except IndexError: 314 | pass 315 | if p_key in cs.RESUME_SECTIONS_PROFESSIONAL: 316 | entities[p_key] = [] 317 | key = p_key 318 | elif key and phrase.strip(): 319 | entities[key].append(phrase) 320 | return entities 321 | 322 | 323 | def extract_email(text): 324 | ''' 325 | Helper function to extract email id from text 326 | 327 | :param text: plain text extracted from resume file 328 | ''' 329 | email = re.findall(r"([^@|\s]+@[^@]+\.[^@|\s]+)", text) 330 | if email: 331 | try: 332 | return email[0].split()[0].strip(';') 333 | except IndexError: 334 | return None 335 | 336 | 337 | def extract_name(nlp_text, matcher): 338 | ''' 339 | Helper function to extract name from spacy nlp text 340 | 341 | :param nlp_text: object of `spacy.tokens.doc.Doc` 342 | :param matcher: object of `spacy.matcher.Matcher` 343 | :return: string of full name 344 | ''' 345 | pattern = [cs.NAME_PATTERN] 346 | 347 | matcher.add('NAME', None, *pattern) 348 | 349 | matches = matcher(nlp_text) 350 | 351 | for _, start, end in matches: 352 | span = nlp_text[start:end] 353 | if 'name' not in span.text.lower(): 354 | return span.text 355 | 356 | 357 | def extract_mobile_number(text, custom_regex=None): 358 | ''' 359 | Helper function to extract mobile number from text 360 | 361 | :param text: plain text extracted from resume file 362 | :return: string of extracted mobile numbers 363 | ''' 364 | # Found this complicated regex on : 365 | # https://zapier.com/blog/extract-links-email-phone-regex/ 366 | # mob_num_regex = r'''(?:(?:\+?([1-9]|[0-9][0-9]| 367 | # [0-9][0-9][0-9])\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]| 368 | # [2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([0-9][1-9]| 369 | # [0-9]1[02-9]|[2-9][02-8]1| 370 | # [2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]| 371 | # [2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{7}) 372 | # (?:\s*(?:#|x\.?|ext\.?| 373 | # extension)\s*(\d+))?''' 374 | if not custom_regex: 375 | mob_num_regex = r'''(\d{3}[-\.\s]??\d{3}[-\.\s]??\d{4}|\(\d{3}\) 376 | [-\.\s]*\d{3}[-\.\s]??\d{4}|\d{3}[-\.\s]??\d{4})''' 377 | phone = re.findall(re.compile(mob_num_regex), text) 378 | else: 379 | phone = re.findall(re.compile(custom_regex), text) 380 | if phone: 381 | number = ''.join(phone[0]) 382 | return number 383 | 384 | 385 | def extract_skills(nlp_text, noun_chunks, skills_file=None): 386 | ''' 387 | Helper function to extract skills from spacy nlp text 388 | 389 | :param nlp_text: object of `spacy.tokens.doc.Doc` 390 | :param noun_chunks: noun chunks extracted from nlp text 391 | :return: list of skills extracted 392 | ''' 393 | tokens = [token.text for token in nlp_text if not token.is_stop] 394 | if not skills_file: 395 | data = pd.read_csv( 396 | os.path.join(os.path.dirname(__file__), 'skills.csv') 397 | ) 398 | else: 399 | data = pd.read_csv(skills_file) 400 | skills = list(data.columns.values) 401 | skillset = [] 402 | # check for one-grams 403 | for token in tokens: 404 | if token.lower() in skills: 405 | skillset.append(token) 406 | 407 | # check for bi-grams and tri-grams 408 | for token in noun_chunks: 409 | token = token.text.lower().strip() 410 | if token in skills: 411 | skillset.append(token) 412 | return [i.capitalize() for i in set([i.lower() for i in skillset])] 413 | 414 | 415 | def cleanup(token, lower=True): 416 | if lower: 417 | token = token.lower() 418 | return token.strip() 419 | 420 | 421 | def extract_education(nlp_text): 422 | ''' 423 | Helper function to extract education from spacy nlp text 424 | 425 | :param nlp_text: object of `spacy.tokens.doc.Doc` 426 | :return: tuple of education degree and year if year if found 427 | else only returns education degree 428 | ''' 429 | edu = {} 430 | # Extract education degree 431 | try: 432 | for index, text in enumerate(nlp_text): 433 | for tex in text.split(): 434 | tex = re.sub(r'[?|$|.|!|,]', r'', tex) 435 | if tex.upper() in cs.EDUCATION and tex not in cs.STOPWORDS: 436 | edu[tex] = text + nlp_text[index + 1] 437 | except IndexError: 438 | pass 439 | 440 | # Extract year 441 | education = [] 442 | for key in edu.keys(): 443 | year = re.search(re.compile(cs.YEAR), edu[key]) 444 | if year: 445 | education.append((key, ''.join(year.group(0)))) 446 | else: 447 | education.append(key) 448 | return education 449 | 450 | 451 | def extract_experience(resume_text): 452 | ''' 453 | Helper function to extract experience from resume text 454 | 455 | :param resume_text: Plain resume text 456 | :return: list of experience 457 | ''' 458 | wordnet_lemmatizer = WordNetLemmatizer() 459 | stop_words = set(stopwords.words('english')) 460 | 461 | # word tokenization 462 | word_tokens = nltk.word_tokenize(resume_text) 463 | 464 | # remove stop words and lemmatize 465 | filtered_sentence = [ 466 | w for w in word_tokens if w not 467 | in stop_words and wordnet_lemmatizer.lemmatize(w) 468 | not in stop_words 469 | ] 470 | sent = nltk.pos_tag(filtered_sentence) 471 | 472 | # parse regex 473 | cp = nltk.RegexpParser('P: {+}') 474 | cs = cp.parse(sent) 475 | 476 | # for i in cs.subtrees(filter=lambda x: x.label() == 'P'): 477 | # print(i) 478 | 479 | test = [] 480 | 481 | for vp in list( 482 | cs.subtrees(filter=lambda x: x.label() == 'P') 483 | ): 484 | test.append(" ".join([ 485 | i[0] for i in vp.leaves() 486 | if len(vp.leaves()) >= 2]) 487 | ) 488 | 489 | # Search the word 'experience' in the chunk and 490 | # then print out the text after it 491 | x = [ 492 | x[x.lower().index('experience') + 10:] 493 | for i, x in enumerate(test) 494 | if x and 'experience' in x.lower() 495 | ] 496 | return x 497 | -------------------------------------------------------------------------------- /pyresparser/vocab/key2row: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OmkarPathak/pyresparser/a66f25b583f2dd8dbd18f419321eed57b04a006e/pyresparser/vocab/key2row -------------------------------------------------------------------------------- /pyresparser/vocab/lexemes.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OmkarPathak/pyresparser/a66f25b583f2dd8dbd18f419321eed57b04a006e/pyresparser/vocab/lexemes.bin -------------------------------------------------------------------------------- /pyresparser/vocab/vectors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OmkarPathak/pyresparser/a66f25b583f2dd8dbd18f419321eed57b04a006e/pyresparser/vocab/vectors -------------------------------------------------------------------------------- /rank_candidate.py: -------------------------------------------------------------------------------- 1 | from multiprocessing import cpu_count, Pool 2 | from typing import Set 3 | from pyresparser.utils import extract_skills 4 | import pandas as pd 5 | import spacy 6 | 7 | 8 | def get_candidate_score( 9 | job_skill_count: int, 10 | job_skills: Set[str], 11 | candidate_skills: Set[str] 12 | ) -> float: 13 | """ 14 | This function compares the candidate skills with job description skills 15 | and rates the candidate based on the fraction of common skills 16 | 17 | :param job_skill_count: Number of job skills 18 | :param job_skills: Set of job skills 19 | :param candidate_skills: Set of candidate skills 20 | :return: Candidate score 21 | """ 22 | 23 | common_skills = job_skills.intersection(candidate_skills) 24 | candidate_score = float(len(common_skills)) / job_skill_count 25 | return candidate_score * 100 26 | 27 | 28 | def get_candidate_score_wrapper(args: tuple) -> float: 29 | """ 30 | A wrapper function to de-structure the tuple of arguments 31 | for multiprocessing.Pool.map() 32 | 33 | :param args: Tuple of arguments for the wrapped function 34 | :return: Result of the wrapped function 35 | """ 36 | return get_candidate_score(*args) 37 | 38 | 39 | def sort_candidates( 40 | job_desc_text: str, 41 | candidates_df: pd.DataFrame 42 | ) -> pd.DataFrame: 43 | """ 44 | This function compares the skills of a number of candidates 45 | against the skills required of a given job description 46 | 47 | :param job_desc_text: Job description text 48 | :param candidates_df: DataFrame containing candidate details and skills 49 | :return: DataFrame with candidates sorted as per their match 50 | with the given job description 51 | """ 52 | 53 | # Get the list of required skills from the Job description 54 | # and convert them to a set 55 | nlp = spacy.load("en_core_web_sm") 56 | doc = nlp(job_desc_text) 57 | job_skills = set([ 58 | skill.lower() for skill in extract_skills(doc, doc.noun_chunks) 59 | ]) 60 | job_skill_count = len(job_skills) 61 | 62 | # Get the candidate skills from the dataframe and create 63 | # a set of skills for each candidate 64 | candidates_skills = candidates_df["Skills"].values.tolist() 65 | candidates_skills = [ 66 | set([ 67 | skill.strip().lower() for skill in skill_list.split(",") 68 | ]) 69 | for skill_list in candidates_skills 70 | ] 71 | 72 | # Use multiprocessing to evaluate multiple candidates for 73 | # a given job in parallel 74 | num_executors = cpu_count() 75 | processing_data = [ 76 | (job_skill_count, job_skills, person_skills) 77 | for person_skills in candidates_skills 78 | ] 79 | with Pool(num_executors) as process_pool: 80 | candidates_df["Score"] = process_pool.map(get_candidate_score_wrapper, processing_data) 81 | 82 | return candidates_df 83 | 84 | 85 | if __name__ == '__main__': 86 | # Read candidate details 87 | df = pd.read_csv("resumes.csv", usecols=["Email", "Skills"]) 88 | 89 | try: 90 | with open("sample_job_description.txt", "r") as fp: 91 | job_description = fp.read() 92 | except FileNotFoundError: 93 | job_description = None 94 | 95 | if job_description: 96 | ranked_df = sort_candidates(job_description, df) 97 | # Sort candidates in descending order of score 98 | ranked_df.sort_values(by="Score", ascending=False, inplace=True) 99 | ranked_df.to_csv("ranked.csv", index=False) 100 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | attrs==19.1.0 2 | blis==0.2.4 3 | certifi==2019.6.16 4 | chardet==3.0.4 5 | cymem==2.0.2 6 | docx2txt==0.7 7 | idna==2.8 8 | jsonschema==3.0.1 9 | murmurhash==1.0.2 10 | nltk==3.4.5 11 | numpy==1.16.4 12 | pandas==0.24.2 13 | pdfminer.six==20181108 14 | plac==0.9.6 15 | preshed==2.0.1 16 | pycryptodome==3.8.2 17 | pyrsistent==0.15.2 18 | python-dateutil==2.8.0 19 | pytz==2019.1 20 | requests==2.22.0 21 | six==1.12.0 22 | sortedcontainers==2.1.0 23 | spacy==2.1.4 24 | srsly==0.0.7 25 | textract==1.6.1 26 | thinc==7.0.4 27 | tqdm==4.32.2 28 | urllib3==1.25.3 29 | wasabi==0.2.2 -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | from os import path 3 | 4 | here = path.abspath(path.dirname(__file__)) 5 | 6 | setup( 7 | name='pyresparser', 8 | version='1.0.6', 9 | description='A simple resume parser used for extracting information from resumes', 10 | long_description=open('README.rst').read(), 11 | url='https://github.com/OmkarPathak/pyresparser', 12 | author='Omkar Pathak', 13 | author_email='omkarpathak27@gmail.com', 14 | license='GPL-3.0', 15 | include_package_data=True, 16 | classifiers=[ 17 | 'Intended Audience :: Developers', 18 | 'Topic :: Software Development :: Libraries', 19 | 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', 20 | 'Programming Language :: Python :: 3', 21 | 'Programming Language :: Python :: 3.3', 22 | 'Programming Language :: Python :: 3.4', 23 | 'Programming Language :: Python :: 3.5', 24 | 'Programming Language :: Python :: 3.6', 25 | 'Programming Language :: Python :: 3.7', 26 | ], 27 | packages=find_packages(), 28 | install_requires=[ 29 | 'attrs>=19.1.0', 30 | 'blis>=0.2.4', 31 | 'certifi>=2019.6.16', 32 | 'chardet>=3.0.4', 33 | 'cymem>=2.0.2', 34 | 'docx2txt>=0.7', 35 | 'idna>=2.8', 36 | 'jsonschema>=3.0.1', 37 | 'nltk>=3.4.3', 38 | 'numpy>=1.16.4', 39 | 'pandas>=0.24.2', 40 | 'pdfminer.six>=20181108', 41 | 'preshed>=2.0.1', 42 | 'pycryptodome>=3.8.2', 43 | 'pyrsistent>=0.15.2', 44 | 'python-dateutil>=2.8.0', 45 | 'pytz>=2019.1', 46 | 'requests>=2.22.0', 47 | 'six>=1.12.0', 48 | 'sortedcontainers>=2.1.0', 49 | 'spacy>=2.1.4', 50 | 'srsly>=0.0.7', 51 | 'thinc>=7.0.4', 52 | 'tqdm>=4.32.2', 53 | 'urllib3>=1.25.3', 54 | 'wasabi>=0.2.2' 55 | ], 56 | zip_safe=False, 57 | entry_points = { 58 | 'console_scripts': ['pyresparser=pyresparser.command_line:main'], 59 | } 60 | ) -------------------------------------------------------------------------------- /test_name.py: -------------------------------------------------------------------------------- 1 | import os 2 | import argparse 3 | from pprint import pprint 4 | import io 5 | import multiprocessing as mp 6 | import urllib 7 | from urllib.request import Request, urlopen 8 | from pyresparser import ResumeParser 9 | 10 | def get_remote_data(): 11 | try: 12 | remote_file = 'https://www.omkarpathak.in/downloads/OmkarResume.pdf' 13 | print('Extracting data from: {}'.format(remote_file)) 14 | req = Request(remote_file, headers={'User-Agent': 'Mozilla/5.0'}) 15 | webpage = urlopen(req).read() 16 | _file = io.BytesIO(webpage) 17 | _file.name = remote_file.split('/')[-1] 18 | resume_parser = ResumeParser(_file) 19 | return [resume_parser.get_extracted_data()] 20 | except urllib.error.HTTPError: 21 | return 'File not found. Please provide correct URL for resume file.' 22 | 23 | def get_local_data(): 24 | data = ResumeParser('OmkarResume.pdf').get_extracted_data() 25 | return data 26 | 27 | def test_remote_name(): 28 | data = get_remote_data() 29 | assert 'Omkar Pathak' == data[0]['name'] 30 | 31 | def test_remote_phone_number(): 32 | data = get_remote_data() 33 | assert '8087996634' == data[0]['mobile_number'] 34 | 35 | def test_local_name(): 36 | data = get_local_data() 37 | assert 'Omkar Pathak' == data['name'] 38 | 39 | def test_local_phone_number(): 40 | data = get_local_data() 41 | assert '8087996634' == data['mobile_number'] 42 | --------------------------------------------------------------------------------