Skip to main content
. 2024 Dec 20;26(12):1114. doi: 10.3390/e26121114
Algorithm 1 Prompt generation process.
  •   1:

    Input: Stories from input file

  •   2:

    Output: Processed stories with generated prompts

  •   3:

    Text Extraction:

  •   4:

    Extract key details from each story;

  •   5:

    Tokenization: Split text into words, remove stopwords;

  •   6:

    Frequency Analysis: Identify common words and themes;

  •   7:

    Character Extraction: Use regex to find capitalized names;

  •   8:

    Sentence Extraction: Extract first and last sentences;

  •   9:

    Prompt Generation:

  • 10:

    Use extracted elements to create prompts;

  • 11:

    Random Sampling: Select up to 5 themes and 3 character names;

  • 12:

    Template Usage: Apply various storytelling templates;

  • 13:

    Implementation:

  • 14:

    Read stories from input file (various text formats);

  • 15:

    Generate unique prompts for each story;

  • 16:

    Append prompts to story objects;

  • 17:

    Save updated stories to output file in JSON format;

  • 18:

    Create final dataset with titles and prompts in new JSON file;