editor-app-v10 / analysis_config.py
gilzero's picture
Upload folder using huggingface_hub
cb1a5c9 verified
# filename: analysis_config.py
from log_config import get_logger
logger = get_logger('GetAnalysisPrompts')
def get_analysis_prompts(raw_text: str) -> dict:
"""
Generate analysis prompts for a given text.
Args:
raw_text (str): The text to analyze.
Returns:
dict: A dictionary containing prompts for various types of analysis.
"""
logger.info("Creating analysis prompts.")
prompt_template = (
"<prompt>\n"
" <task>{task} (output in Simplified Chinese):</task>\n"
" <text>{raw_text}</text>\n"
"{details}"
"</prompt>"
)
prompts = {
"Summary": prompt_template.format(
task="Provide a concise summary of this text",
raw_text=raw_text,
details=""
),
"Characters": prompt_template.format(
task="Analyze the characters in this text",
raw_text=raw_text,
details=(
" <details>\n"
" Provide a list of major characters with brief descriptions of their personality traits and roles in the story.\n"
" Try to identify relationships between characters (friends, enemies, family, etc.).\n"
" Comment on any significant character development or arcs.\n"
" </details>\n"
)
),
"Plot": prompt_template.format(
task="Analyze the plot structure of this text",
raw_text=raw_text,
details=(
" <details>\n"
" Try to identify key plot points (e.g., exposition, rising action, climax, falling action, resolution).\n"
" Outline the overall conflict or driving tension in the narrative.\n"
" </details>\n"
)
),
"Themes": prompt_template.format(
task="Discuss the main themes explored in this text",
raw_text=raw_text,
details=(
" <details>\n"
" Identify and analyze the central ideas, messages, or insights the author seems to be conveying through the story.\n"
" Consider how these themes are developed and their significance.\n"
" </details>\n"
)
),
"Techniques": prompt_template.format(
task="Analyze the writing techniques used in this text",
raw_text=raw_text,
details=(
" <details>\n"
" Look for notable examples of literary devices, narrative strategies, or stylistic choices the author employs.\n"
" Consider how these techniques contribute to the overall effect or meaning of the work.\n"
" </details>\n"
)
),
"Emotional Core": prompt_template.format(
task="Discuss the emotional core of this text",
raw_text=raw_text,
details=(
" <details>\n"
" Identify the primary emotions evoked by the story and how the author elicits these feelings in the reader.\n"
" Consider the emotional journey of the characters and the reader's empathetic response.\n"
" </details>\n"
)
),
"Narrative Perspective": prompt_template.format(
task="Analyze the narrative perspective used in this text",
raw_text=raw_text,
details=(
" <details>\n"
" Identify the point of view (e.g., first-person, third-person limited, omniscient) and consider how this perspective shapes the reader's understanding of events and characters.\n"
" </details>\n"
)
)
}
logger.info("Analysis prompts created successfully.")
return prompts
# file: analysis_config.py (end)