Created
February 23, 2024 13:59
-
-
Save bjoerntx/4960d9c217389d85a4458fe0e4c1d488 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string question = "Is contracting with other partners an option?"; | |
//string question = "How will disputes be dealt with?"; | |
//string question = "Can the agreement be changed or modified?"; | |
string pdfPath = "Sample PDFs/SampleContract-Shuttle.pdf"; | |
// load the PDF file | |
byte[] pdfDocument = File.ReadAllBytes(pdfPath); | |
// split the PDF document into chunks | |
var chunks = DocumentProcessing.Chunk(pdfDocument, 2500, 50); | |
Console.WriteLine($"{chunks.Count.ToString()} chunks generated from: {pdfPath}"); | |
// get the keywords | |
List<string> generatedKeywords = GPTHelper.GetKeywords(question, 20); | |
// find the matches | |
var matches = DocumentProcessing.FindMatches(chunks, generatedKeywords).ToList().First(); | |
// print the matches | |
Console.WriteLine($"The question: \"{question}\" was found in chunk {matches.Key}."); | |
// print the answer | |
Console.WriteLine("\r\n********\r\n" + GPTHelper.GetAnswer(chunks[matches.Key], question)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment