Book Engine Rewriting Books
Complete code: Full_Article_Code
This article, born from curiosity, explores AI's potential in literature, emphasizing the utmost respect for Intellectual Property Rights. It is not an endeavor to supplant authors or belittle their talents but rather to add a unique dimension to existing works.
Ethical Considerations:
This initiative aims to inspire creative and respectful use of AI in literature, allowing readers to experience familiar stories in new, imaginative ways while firmly upholding the principles of intellectual property rights.
I'm directing you to these articles for a fundamental reason: they lay the groundwork for the concept of reimagining existing books using AI, a natural extension of ideas presented in my earlier articles. Here's a structured outline of the process:
This process is surprisingly straightforward, almost deceptively so. Its simplicity underscores the immense potential of AI in transforming literature. However, I must stress the ethical implications:
The provided code is a basic template, an inspiration for the more technologically adept and a potential magnet for investment. It is essential to use it responsibly and innovatively, always with a deep respect for the original works and their creators.
Link to the 'new' I Robot: I Robot Variant 2 14 2023 JZ
Remark about this first 'new' book version:
The final product of our AI-assisted literary adventure is, let's say, a work in progress. It's akin to a rough diamond, brimming with potential yet in need of some fine-tuning. The core of this endeavor lies not just in the code itself, but in the art of conversation with our AI companion.
So, embark on this journey with a spirit of exploration. It’s not just about creating a ‘new’ book; it’s about charting unknown territories of narrative possibilities. Where will your creativity take you? Will it cling to the familiar shores of the storyline, or will it sail into the uncharted waters of whimsical, AI-generated storytelling? The choice, and the adventure, is yours.
Original book for comparison: Original I Robot from Isaac Asimov
The process of generating a unique rendition of a book using this program is both fascinating and straightforward, with the potential for varied outcomes. Here's a breakdown:
Operational Details:
Cost Implications:
Ethical Considerations and Scope:
Intellectual Property Respect:
The goal of this endeavor is to inspire and educate in the realm of coding, highlighting the innovative possibilities of AI in literature while underscoring the importance of ethical and respectful use of such technologies. Happy coding!
// "book"
// Book.txt must be present in root (content of book to be 'rewritten')
// chapter.txt will be written
else if (args[0] != null && args[0].Equals("book"))
{
string appPath = AppDomain.CurrentDomain.BaseDirectory;
string filePath = "Book.txt"; // Replace with your file path
string theFile = appPath + filePath;
List<string> newBook = new List<string>();
List<string> oldBook = new List<string>();
string chapterTitlesPath = "ChapterTitles.txt";
string theChapters = appPath + chapterTitlesPath;
List<string> sTitles = File.ReadAllLines(theChapters).ToList();
string ChapterPath = "chapter.txt"; // Replace with your file path
try
{
List<string> lines = GlobalMethods.ReadAndSplitTextFromFile(filePath);
int cLines = 0;
string memory = "";
// Print the lines
foreach (string line in lines)
{
Console.WriteLine($"{line}");
// Define a regular expression pattern to match double empty lines
string pattern = @"\n\s*\n";
// Replace double empty lines with a single empty line
string result = Regex.Replace(line, pattern, "\n\n");
// Replace double carriage returns with a single carriage return
string result2 = Regex.Replace(result, pattern, "\r\n");
oldBook.Add(result2);
// Define a regular expression pattern to match double carriage returns
pattern = "\r\n\r\n";
bool nameExists = false;
foreach (string title in sTitles)
{
if (line.Trim().Contains(title))
{
nameExists = true;
break;
}
}
if (nameExists)
{
string rr = line;
newBook.Add(RemoveNonLettersForBook(rr));
GlobalMethods.AppendTextToFile(appPath + ChapterPath, "********************************************************************************************\n");
GlobalMethods.AppendTextToFile(appPath + ChapterPath, rr);
GlobalMethods.AppendTextToFile(appPath + ChapterPath, "********************************************************************************************\n");
}
else
{
string rr = await GetChatGPTExtraSmallToken("Rephrase the sentence with added literary " +
"depth and finesse, ensuring it constantly tantalizes the reader's senses. " +
"Infuse it with an extra layer of intelligence that heightens the suspense." +
", and if it has a dialog, make the dialog more exciting and thought provoking and as a " +
"continuation of " + memory + " and return dialogs between quotation marks:" + RemoveNonLetters(line) + "\n");
//string rr = await GetChatGPTExtraSmallToken("Take the exact meaning of the lines but enrich the language. " +
// "Use the previous part or the story as foundation to build upon further " + memory + ". " +
// "Do not repeat conversations already present in the past lines " + memory + "." +
// "Name characters as they have a dialog and it make sense to do so based upon existing ones in " + memory + "." +
// "Return dialogs between quotation marks:" + RemoveNonLetters(line) + "\n");
newBook.Add(RemoveNonLettersForBook(rr));
GlobalMethods.AppendTextToFile(appPath + ChapterPath, rr);
cLines++;
}
try
{
// Build up some memory
if (cLines >= 5)
{
memory = "";
//memory += lines[cLines - 9];
//memory += lines[cLines - 8];
//memory += lines[cLines - 7];
//memory += lines[cLines - 6];
//memory += lines[cLines - 5];
//memory += lines[cLines - 4];
memory += lines[cLines - 3];
memory += lines[cLines - 2];
memory += lines[cLines - 1];
memory += lines[cLines];
}
}
catch (Exception e) { }
}
}
catch (FileNotFoundException)
{
Console.WriteLine("File not found.");
}
catch (IOException)
{
Console.WriteLine("An error occurred while reading the file.");
}
Console.WriteLine("**************************************************************************");
foreach (var item in newBook)
{
Console.WriteLine(item);
}
}