Skip to content

Commit cd11ce2

Browse files
committed
Linting
1 parent 4ab93c7 commit cd11ce2

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

llm_quiz_generator/main.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| - Add your API key directly to line 38: API_KEY = "your_groq_api_key_here", or |
1010
| - Create a .env file in the same directory, and add GROQ_API_KEY=your_groq_api_key_here. |
1111
| |
12-
| 3. Place all your PDFs in a folder named ''Source'' in the same directory as this script. |
12+
| 3. Place all your PDFs in a folder named 'Source' in the same directory as this script. |
1313
| |
1414
| 4. Run the script: |
1515
| python quiz_generator.py |
@@ -23,7 +23,6 @@
2323
num_questions = 5
2424

2525

26-
2726
import os
2827
from PyPDF2 import PdfReader
2928
from datetime import datetime
@@ -40,11 +39,11 @@
4039

4140

4241
def extract_text_from_pdfs():
43-
print(f"Extracting text from PDF files in the folder: '{'Source'}'...")
42+
print(f"Extracting text from PDF files in the folder: 'Source'...")
4443
all_text = []
4544

46-
if len(os.listdir('Source')) == 0:
47-
print("Source Folder Empty!")
45+
if not os.path.exists('Source') or not os.listdir('Source'):
46+
print("Folder 'Source' is empty or not found!")
4847
print("Process exiting...")
4948
exit(0)
5049

@@ -58,8 +57,6 @@ def extract_text_from_pdfs():
5857
print("Text extraction completed.")
5958
return " ".join(all_text)
6059

61-
62-
6360
def generate_unique_mcq(text, num_questions=5):
6461
print(f"Splitting text into chunks and creating embeddings for LLM processing...")
6562
text_splitter = CharacterTextSplitter(
@@ -95,8 +92,6 @@ def generate_unique_mcq(text, num_questions=5):
9592
print("MCQ generation completed.")
9693
return quiz
9794

98-
99-
10095
def save_mcq_to_file(quiz, file_name="generated_mcq_quiz.txt"):
10196
output_folder = "Generated_Quizes"
10297

@@ -115,13 +110,11 @@ def save_mcq_to_file(quiz, file_name="generated_mcq_quiz.txt"):
115110

116111
print(f"MCQ Quiz saved to {file_path}")
117112

118-
119-
120113
if __name__ == "__main__":
121114
if not os.path.exists('Source'):
122-
print(f"Folder '{'Source'}' not found.")
115+
print(f"Folder 'Source' not found.")
123116
else:
124-
print(f"Folder '{'Source'}' found. Starting process...")
117+
print(f"Folder 'Source' found. Starting process...")
125118
text = extract_text_from_pdfs()
126119
print("Text extracted from PDFs.")
127120

0 commit comments

Comments
 (0)