GithubHelp home page GithubHelp logo

erykdarnowski / ts-test-extractor Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 46 KB

Simple script for extracting questions, answers and so on from test PDFs (for a subject called TS I have at uni) to a more usable format.

License: MIT License

Python 100.00%
pdf pdf-conversion pdf-converter pdf-extractor pdf-json pdf-txt

ts-test-extractor's People

Watchers

 avatar  avatar  avatar

ts-test-extractor's Issues

Implement proper fix for Polish diacritics in text extraction

Description

The currently implemented quick & dirty fix, doesn't fully resolve the issue and in fact introduces a new one (when a word starts with a diacritic, it gets combined with the word previous to it).

The proposed solution is a switch from PyPDF2 to using fitz from PyMuPDF.
Another thing is the need for encoding="utf-8" when writing the out.txt file on Windows.

Fix JSON file encoding on Windows

Description

Add the encoding parameter when writing the JSON file, like was done before:
...('ts.json', 'w') as... -> ...('ts.json', 'w', encoding='utf-8')...

Update `README.md`

TODO

  • Info about input files + included example + that they should be numbered
  • Run instructions
  • That the regex patterns and formatting fixes are really specific so this repo won't be really usefull cause it was made with a really specific usecase in mind (it will most likely be only usefull as inspiration).

Implement data extraction with regex patterns

TODO

*Make sure each expression gets 171 matches

  • Add clean up
    • Titles: /(\s\n){0,2}(^Test\sz\s.*?)(\s\n){2,}/gms (replace)
  • Add extraction
    • Tasks: /(^[0-9]{1,}\.\n?\s?)(?![0-9])(.*?)(?=\n?\s\n[A-Z]\.)/gms (G2)
    • Answers (A, B, C): /(^[A-Z]\..*?)(?=\s\n?Odp\.)/gms (G1)
    • Correct answers: /(?<=^Odp\.)(.*?)([A-Z])(?=\.?)/gm (G2)
    • Answer expls.: /(^Odp\.(\:|\s)\s?[A-Z])(\.?\s+\n?)(.*?)(?=((^[0-9]{1,}\.\n?\s?)(?![0-9]))|(\s\n){3})/gms (G4)

Resources

Check that tasks, answers etc. are correctly joined / aligned

Description

Basically compare the output JSON file of the script with the PDFs to make sure that the tasks, answers, correct answers and so on are correctly grouped / joined / aligned. In addition could also look for formatting stuff to fix that was missed previously.

Fix lack of PDF filenames sorting

Description

After messing around with the PDF files, I've noticed that when they get found by glob they don't have to be in order.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.