Skip to content

Commit 7673477

Browse files
authored
Added other Malfuzat Versions
1 parent 8975332 commit 7673477

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Controllers/HomeController.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ namespace MalfuzatExplorer.Controllers
99
{
1010
public class HomeController : Controller
1111
{
12-
private string pdfPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "Malfuzat", "Malfuzat-1.pdf");
13-
12+
private string[] pdfFiles = new string[]
13+
{
14+
Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "Malfuzat", "Malfuzat-1.pdf"),
15+
Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "Malfuzat", "Malfuzat-2.pdf"),
16+
Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "Malfuzat", "Malfuzat-3.pdf"),
17+
Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "Malfuzat", "Malfuzat-4.pdf")
18+
};
1419

1520
public IActionResult Index()
1621
{
@@ -55,6 +60,8 @@ public async Task<List<string>> SearchPdfForQueryAsync(string query)
5560
List<string> results = new List<string>();
5661
try
5762
{
63+
foreach (var pdfPath in pdfFiles)
64+
{
5865
if (!System.IO.File.Exists(pdfPath))
5966
{
6067
throw new FileNotFoundException("PDF file not found.");
@@ -70,12 +77,12 @@ public async Task<List<string>> SearchPdfForQueryAsync(string query)
7077
string pageText = PdfTextExtractor.GetTextFromPage(document.GetPage(i));
7178
if (pageText.Contains(query, StringComparison.OrdinalIgnoreCase))
7279
{
73-
string result = $"Found on leaf {i}: " + await GetContextAroundQueryAsync(pageText, query);
74-
75-
results.Add(result);
80+
string result = $"Found in {Path.GetFileNameWithoutExtension(pdfPath)} on leaf {i}: " + await GetContextAroundQueryAsync(pageText, query);
81+
results.Add(result);
7682
}
7783
}
7884
}
85+
}
7986
}
8087
catch (Exception ex)
8188
{

0 commit comments

Comments
 (0)