Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/core/IndexerMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import utils.TfIdfCalculator;

import java.io.File;
import java.io.IOException;
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import is unused and should be removed. The code catches generic Exception rather than IOException specifically.

Copilot uses AI. Check for mistakes.
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -45,7 +46,7 @@ public static void main(String[] args) {

// 3. Indexing Process
System.out.println("Indexing books...");
List<Book> allBooks = loader.loadBooks();
List<Book> allBooks = loader.loadBooksFromSource(BOOK_RES);
if (allBooks.isEmpty()) {
System.err.println("❌ Critical Error: No books loaded. Check book.json path.");
return;
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/storage/BookLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ public BookLoader(String resourcePath) {
this.resourcePath = resourcePath;
}

// Add a new method specifically for the Indexer
public List<Book> loadBooksFromSource(String path) {
ObjectMapper mapper = new ObjectMapper();
try {
// Reads directly from the project folder, ignoring AppData
return mapper.readValue(new File("src/main/resources" + path), new TypeReference<List<Book>>() {});
Comment on lines +25 to +27
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded path "src/main/resources" may cause issues when running from a JAR or in different environments. Consider making this configurable or using a more robust resource loading approach that works consistently across different runtime contexts.

Suggested change
try {
// Reads directly from the project folder, ignoring AppData
return mapper.readValue(new File("src/main/resources" + path), new TypeReference<List<Book>>() {});
// Load from classpath so this works both in development and from a packaged JAR
try (InputStream inputStream = getClass().getResourceAsStream(path)) {
if (inputStream == null) {
// Resource not found on classpath
return Collections.emptyList();
}
return mapper.readValue(inputStream, new TypeReference<List<Book>>() {});

Copilot uses AI. Check for mistakes.
} catch (IOException e) {
e.printStackTrace();
return Collections.emptyList();
}
}

public List<Book> loadBooks() {
ObjectMapper mapper = new ObjectMapper();
Expand Down
78 changes: 77 additions & 1 deletion src/main/resources/data/book.json
Original file line number Diff line number Diff line change
Expand Up @@ -3321,6 +3321,82 @@
"rating": "4.6",
"coverUrl": "https://m.media-amazon.com/images/S/compressed.photo.goodreads.com/books/1348971620i/9637420.jpg",
"downLink": "https://dl.icdst.org/pdfs/files4/f5087fa30778ccd742790526c0d6be83.pdf"
},
{
"bookId": 208,
"title": "Computer Organization and Architecture: Designing for Performance",
"author": "William Stallings",
"description": "A comprehensive textbook on computer organization and architecture, covering processor design, memory hierarchy, I/O systems, instruction sets, and performance optimization principles. It provides both theoretical foundations and practical examples for students and professionals in computer science and engineering.",
"progLang": "Assembly",
"category": "Computer Science",
"tag": [
"Computer Organization",
"Computer Architecture",
"William Stallings",
"Processor Design",
"Memory Hierarchy",
"Assembly",
"I/O Systems"
],
"rating": "4.1",
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rating field should be a numeric value, not a string. The Book domain model expects a float type for the rating field. Change "4.1" to 4.1 (without quotes) to match the data type used in most other book entries.

Suggested change
"rating": "4.1",
"rating": 4.1,

Copilot uses AI. Check for mistakes.
"coverUrl": "https://m.media-amazon.com/images/I/713+cg1BJwL._SL1500_.jpg",
"downLink": "https://os.ecci.ucr.ac.cr/ci0114/material/Stallings/Computer-Organization-Architecture-11th.pdf"
},
{
"bookId": 209,
"title": "Introduction to Computer Theory",
"author": "Daniel I. A. Cohen",
"description": "A foundational textbook covering the mathematical theory of computation, including automata, formal languages, Turing machines, and computability.",
"progLang": "English",
"category": "Computer Science",
"tag": [
"Computer Theory",
"Automata",
"Formal Languages",
"Turing Machine",
"Computation",
"Computer Science"
],
"rating": "4.3",
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rating field should be a numeric value, not a string. The Book domain model expects a float type for the rating field. Change "4.3" to 4.3 (without quotes) to match the data type used in most other book entries.

Suggested change
"rating": "4.3",
"rating": 4.3,

Copilot uses AI. Check for mistakes.
"coverUrl": "https://www.ketabton.com/book-cover/1495/large.jpg",
"downLink": "https://pakistandasti.wordpress.com/wp-content/uploads/2013/11/introduction-to-computer-theory-by-cohen-copy.pdf"
},
{
"bookId": 210,
"title": "Assembly Language Programming and Organization of the IBM PC",
"author": "Ytha Y. Yu, Charles Marut",
"description": "A comprehensive tutorial-style guide to assembly language programming on the IBM PC, covering microcomputer systems, representation of numbers and characters, instruction sets, memory and I/O organization, BIOS/DOS interrupts, graphics and keyboard programming, and advanced topics with practical examples and exercises.",
"progLang": "English",
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The progLang field should be "Assembly" rather than "English" since this book is specifically about assembly language programming for the IBM PC. This would be consistent with book 208 which also uses "Assembly" for assembly-related content.

Suggested change
"progLang": "English",
"progLang": "Assembly",

Copilot uses AI. Check for mistakes.
"category": "Computer Science",
"tag": [
"Assembly Language",
"IBM PC",
"8086 Microprocessor",
"Computer Organization",
"Machine Code",
"Low-Level Programming"
],
"rating": "4.5",
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rating field should be a numeric value, not a string. The Book domain model expects a float type for the rating field. Change "4.5" to 4.5 (without quotes) to match the data type used in most other book entries.

Suggested change
"rating": "4.5",
"rating": 4.5,

Copilot uses AI. Check for mistakes.
"coverUrl": "https://covers.openlibrary.org/b/isbn/0070726922-L.jpg",
"downLink": "https://pdos.csail.mit.edu/6.828/2010/readings/pcasm-book.pdf"
},
{
"bookId": 211,
"title": "Database System Concepts, 6th Edition",
"author": "Avi Silberschatz, Henry F. Korth, S. Sudarshan",
"description": "A foundational and widely used textbook on database management systems that covers core concepts such as relational databases, SQL, query processing and optimization, transactions, concurrency control, recovery, and advanced topics like distributed databases and data mining. It is designed for undergraduate and graduate courses in computer science and related fields.",
"progLang": "English",
"category": "Computer Science",
"tag": [
"Databases",
"Database Systems",
"SQL",
"Relational Model",
"Query Processing",
"Transaction Management"
],
"rating": "4.5",
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rating field should be a numeric value, not a string. The Book domain model expects a float type for the rating field. Change "4.5" to 4.5 (without quotes) to match the data type used in most other book entries.

Suggested change
"rating": "4.5",
"rating": 4.5,

Copilot uses AI. Check for mistakes.
"coverUrl": "https://covers.openlibrary.org/b/isbn/9780073523323-L.jpg",
"downLink": "https://people.vts.su.ac.rs/~peti/Baze%20podataka/Literatura/Silberschatz-Database%20System%20Concepts%206th%20ed.pdf"
}

]
Loading
Loading