Skip to content

Commit

Permalink
switched to writing from scratch
Browse files Browse the repository at this point in the history
  • Loading branch information
jknoxdev committed Aug 22, 2023
1 parent 4156b30 commit 717fef0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
1 change: 1 addition & 0 deletions incubator/pdfqp.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def run(self):
break
else:
print("Invalid choice. Please choose again.")

# -------------------------------------------------------------------
# main
# -------------------------------------------------------------------
Expand Down
22 changes: 10 additions & 12 deletions pdfqp.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,21 @@ def extract_qa_from_pdf(self):
for page_num in range(num_pages):
page = pdf_reader.getPage(page_num)
text = page.extractText()

lines = text.split('\n')
for line in lines:
if line.startswith("QUESTION:"):
if current_question:
self.qa_data.append((current_question, current_answers))
current_question = line[10:].strip()
current_answers = {}
elif current_question and line.startswith("Answer:"):
current_answer_prefix = line[7:8]
current_answer = line[9:].strip()
current_answers[current_answer_prefix] = current_answer
elif current_answer_prefix and line.startswith(current_answer_prefix):
current_answer += " " + line.strip()

if current_question:
self.qa_data.append((current_question, current_answers))
current_question = line[10:].strip()
current_answers = {}
elif current_question and line.startswith("Answer:"):
current_answer_prefix = line[7:8]
current_answer = line[9:].strip()
current_answers[current_answer_prefix] = current_answer
elif current_answer_prefix and line.startswith(current_answer_prefix):
current_answer += " " + line.strip()
if current_question:
self.qa_data.append((current_question, current_answers))

def create_database(self):
conn = sqlite3.connect(self.database_name)
Expand Down

0 comments on commit 717fef0

Please sign in to comment.