Book Engine Rewriting Books
Book Engine rewriting existing books.

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.

  • Asimov's Influence: As a devoted fan of Isaac Asimov, I've often pondered the experience of reading his "Robot Series" and "Foundation" with a novel perspective.
  • AI-Driven Rewrite: The idea to use AI to reimagine "I, Robot" sprouted from this thought, envisioning a new twist to the classic.
  • Purpose of Rewriting: The goal is to employ AI to introduce diverse elements and variations to beloved themes, like those in Asimov's works, creating multiple renditions of these stories.
  • Extending to Other Authors: This concept can extend to the works of Stephen King and others, imagining infinite variations of their stories, which could be quite exhilarating.

Ethical Considerations:

  • Warning on Intellectual Property: Initially hesitant to share this concept publicly due to respect for intellectual property, I endorse its use under specific conditions: personal use, open-source sharing without commercial intent, and after obtaining necessary permissions.
  • Urgent Appeal for Ethical Use: This idea and its accompanying code are offered to the public, but with a stern caution against misusing it to infringe upon the intellectual property rights of others. My intent is to enhance AI utilization for everyone's benefit, provided it's done ethically.
  • Code Explanation: The code is straightforward and serves as an inspiration to explore book creation with AI. It's shared to stimulate innovative thinking and ethical application in this field.

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.

FAST Creating Book Engine

AI Book Engine Improved

Books at The Speed of Thought

AI Book Factory, A New Frontier

Book Factory Professional Book

Order book by Voice

Book Engine Game Engine

AI Holy Book Creator

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:

  • Starting Point: Open a file containing the plain text of a book, like "I, Robot."
  • Title Extraction: Extract all book titles into a List<string>.
  • Sequential Processing: Methodically read through each line of the original text.
  • Creating a New File: Set up a separate file to house the reimagined book.
  • Handling Titles: Directly transfer titles from the original to the new file.
  • AI-Enhanced Rewriting: Use AI to creatively rewrite each line from the original book.
  • Incorporating Rewritten Lines: Add these revised lines to the new book file.
  • Maintaining Coherence: Develop a memory mechanism to keep the narrative consistent.

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:

  • AI Model Implications: If AI models restrict such functionalities, it would undermine their utility and market viability, especially with the emergence of open-source models.
  • Intellectual Property Respect: It's imperative not to misuse this code to infringe upon others' intellectual property rights. The intent is to create new versions of beloved books for personal enjoyment.

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.

  • The Imperfect Masterpiece: Consider the output file as an initial draft, a canvas splashed with the first strokes of genius, yet yearning for refinement.
  • Tweaking the Tale: To elevate the narrative, one must be both a coder and a wordsmith, delicately adjusting the AI's linguistic inputs to add that extra zest to the story.
  • Foundation of Innovation: The fundamental concept here is not just rewriting but reimagining; it’s about weaving new threads into the old tapestry to create something unexpectedly brilliant.
  • Advanced Storytelling: Injecting variations into the AI’s responses is akin to planting seeds of creativity; some will sprout along the storyline, others might veer off into the wilds of fuzzy logic, where true creativity blossoms.

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:

  • Multiple Runs, Multiple Styles: Each execution of the program yields a distinct version of the 'new' book, with variations in style.
  • Customizable Commands: Altering AI commands results in even more uniquely styled versions of the book.
  • Imperfections and Potential: The output, while not flawless, serves as a starting point for further refinement.

Operational Details:

  • Initial Setup: The process begins with sourcing the text of the book, saving it as a file, and manually inputting titles into a List<string>.
  • Simplicity of Process: The simplicity of the procedure involves just loading the text and executing the program.

Cost Implications:

  • Time Investment: Approximately 45 minutes per book.
  • Monetary Cost: Around 4 dollars per book.

Ethical Considerations and Scope:

  • Wide Application Range: The program can be applied to various texts, including religious and cultural scriptures like the Bible, the Vedas, the Bhagavad Gita, the Quran, and others. This underscores the need for caution, cultural sensitivity, and ethical consideration.
  • Source Selection: For safer application, use texts from less restricted sources like archive.org , being mindful of what is permissible.

Intellectual Property Respect:

  • Educational Example: The book used here is solely for demonstration and educational purposes, with clear acknowledgments of intellectual property origins and creation methods.

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);
            }
           
        }        

要查看或添加评论,请登录