From 50c0487fb351d5933df69d07deb22c8b35320cfb Mon Sep 17 00:00:00 2001 From: Kirill456Z Date: Thu, 19 Dec 2024 14:51:04 +0100 Subject: [PATCH 1/4] story_check_table_rendering --- src/story/Question_1.ipynb | 54 +++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/src/story/Question_1.ipynb b/src/story/Question_1.ipynb index e4c5a2c..bdeea15 100644 --- a/src/story/Question_1.ipynb +++ b/src/story/Question_1.ipynb @@ -6,11 +6,63 @@ "source": [ "# Question 1" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "What Are the Most Common Character Archetypes in Movies?\n", + "What are the most prevalent character archetypes found in films, and how can we define and clusterize them based on existing papers and our own research? Identifying these archetypes involves exploring recurring character types and their roles within various plots." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Selection of archetype categories\n", + "\n", + "The identification of prominent movie archetypes turned out to be a challenging task. A popular way to analyse archetypes in related literature is with a help of the website [Tv tropes](https://tvtropes.org/), which constitutes a large collection of archetypes gathered by tv viewers. We found that the majority of the archetypes presented on the web site are extremely specific and can be applied only to a handful of examples (see [A Chat with Satan](https://tvtropes.org/pmwiki/pmwiki.php/Main/AChatWithSatan), [The Drunken Sailor](https://tvtropes.org/pmwiki/pmwiki.php/Main/TheDrunkenSailor), [Mock Millionaire](https://tvtropes.org/pmwiki/pmwiki.php/Main/MockMillionaire)). Such specific tropes limit the amount of available data, rendering the search of correlation much harder and making the insights less impactful. In our analysis we wanted to see a broader picture.Therefore it was necessary to devise a set of broad and popular archetypes. As a basis, a [list of archetypal tropes](https://tvtropes.org/pmwiki/pmwiki.php/Main/ArchetypalCharacter) was taken from the TV tropes website. Based on this list we tried to join some archetypes into more general categories. As a result, the following list of archetypes has emerged:\n", + "\n", + "##### Devised Archetypes\n", + "|Archetype | Description | Example 1 | Example 2 | Example 3|\n", + "|---|---|---|---|---|\n", + "|Love Interest / Romantic Partner|A character involved in a romantic relationship with a main figure, influencing emotional arcs and sometimes motivating heroic action.|\"Rose DeWitt Bukater\" in \"Titanic\"|\"Elizabeth Swann\" in \"Pirates of the Caribbean\"|\"Rachel Dawes\" in \"Batman Begins\"|\n", + "|Caregiver / Healer|Provides nurture, comfort, or medical/spiritual healing; supports others’ well-being and stability.|\"Dr. Ellen Ripley\" in \"Aliens\"|\"Samwise Gamgee\" in \"The Lord of the Rings\"|\"Molly Weasley\" in \"Harry Potter series\"|\n", + "|Mentor / Wise Guide|Provides knowledge, training, or insight to help the hero or others grow and succeed.|\"Ms. Honey\" in \"Matilda\"|\"Mr. Miyagi\" in \"The Karate Kid\"|\"Obi-Wan Kenobi\" in \"Star Wars: A New Hope\"|\n", + "|Intellectual / Creative (Scholar/Artist/Inventor)|Values knowledge, innovation, or art; provides crucial insights, cultural depth, problem-solving, or visionary ideas.|\"Steve Jobs\" in \"Steve Jobs\"|\"Leonardo da Vinci\" in \"The Da Vinci Code\"|\"Ada Lovelace\" in \"The Imitation Game\"|\n", + "|Ruler / Politician|Holds formal power or influence; shapes policies, alliances, and social orders, whether for good or ill.|\"President Franklin D. Roosevelt\" in \"Hyde Park on Hudson\"|\"Selina Meyer\" in \"Veep\"|\"Duncan Idaho\" in \"Dune\"|\n", + "|Sidekick / Loyal Companion|A supportive ally, assisting the hero, offering loyalty, encouragement, and sometimes comic or emotional relief.|\"Ron Weasley\" in \"Harry Potter and the Philosopher's Stone\"|\"Dr. John Watson\" in \"Sherlock Holmes: A Game of Shadows\"|\"Robin\" in \"Batman: The Movie\"|\n", + "|Warrior / Vigilante|Skilled in combat and physical confrontation; may enforce justice or defend others, sometimes outside legal boundaries.|\"Batman\" in \"The Dark Knight\"|\"John Wick\" in \"John Wick\"|\"The Bride\" in \"Kill Bill\"|\n", + "|Rogue / Trickster / Con Artist|A cunning, rule-bending manipulator who achieves goals through deception, charm, or clever schemes.|\"Frank Abagnale Jr.\" in \"Catch Me If You Can (2002)\"|\"Irving Rosenfeld\" in \"American Hustle (2013)\"|\"Lawrence Jamieson\" in \"Dirty Rotten Scoundrels (1988)\"|\n", + "|Mystic / Seer|Offers spiritual guidance, foresight, or mystical understanding, often steering characters with visions or cryptic wisdom.|\"The Oracle\" in \"The Matrix\"|\"Yoda\" in \"The Empire Strikes Back\"|\"Galadriel\" in \"The Lord of the Rings: The Fellowship of the Ring\"|\n", + "|Outsider / Loner|Operates on the fringe of society, often misunderstood or self-isolated, bringing a unique perspective.|\"Edward Scissorhands\" in \"Edward Scissorhands\"|\"Rick Deckard\" in \"Blade Runner\"|\"Chuck Noland\" in \"Cast Away\"|\n", + "|Innocent / Vulnerable|Naive, inexperienced, or in need of guidance; prompts protection or mentoring, and highlights moral stakes.|\"Daniel LaRusso\" in \"The Karate Kid\"|\"Charlie Bucket\" in \"Willy Wonka & the Chocolate Factory\"|\"Newt\" in \"Aliens\"|\n", + "|Other|Doesn't align with any of the proposed archetype categories|\"George McFly\" in \"Back to the Future\"|\"Victor\" in \"John Wick\"|\"Mayor\" in \"Ghostbusters\"|\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] } ], "metadata": { + "kernelspec": { + "display_name": ".venv", + "language": "python", + "name": "python3" + }, "language_info": { - "name": "python" + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.8" } }, "nbformat": 4, From be5e9aa84097c29ea6381695522441e69d9b2403 Mon Sep 17 00:00:00 2001 From: Kirill456Z Date: Thu, 19 Dec 2024 15:40:18 +0100 Subject: [PATCH 2/4] story - limit the size of the table --- src/story/Question_1.ipynb | 105 +++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/src/story/Question_1.ipynb b/src/story/Question_1.ipynb index bdeea15..c3e5237 100644 --- a/src/story/Question_1.ipynb +++ b/src/story/Question_1.ipynb @@ -40,6 +40,111 @@ "|Other|Doesn't align with any of the proposed archetype categories|\"George McFly\" in \"Back to the Future\"|\"Victor\" in \"John Wick\"|\"Mayor\" in \"Ghostbusters\"|\n" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
ArchetypeDescriptionExample 1Example 2Example 3
Love Interest / Romantic PartnerA character involved in a romantic relationship with a main figure, influencing emotional arcs and sometimes motivating heroic action.\"Rose DeWitt Bukater\" in \"Titanic\"\"Elizabeth Swann\" in \"Pirates of the Caribbean\"\"Rachel Dawes\" in \"Batman Begins\"
Caregiver / HealerProvides nurture, comfort, or medical/spiritual healing; supports others’ well-being and stability.\"Dr. Ellen Ripley\" in \"Aliens\"\"Samwise Gamgee\" in \"The Lord of the Rings\"\"Molly Weasley\" in \"Harry Potter series\"
Mentor / Wise GuideProvides knowledge, training, or insight to help the hero or others grow and succeed.\"Ms. Honey\" in \"Matilda\"\"Mr. Miyagi\" in \"The Karate Kid\"\"Obi-Wan Kenobi\" in \"Star Wars: A New Hope\"
Intellectual / Creative (Scholar/Artist/Inventor)Values knowledge, innovation, or art; provides crucial insights, cultural depth, problem-solving, or visionary ideas.\"Steve Jobs\" in \"Steve Jobs\"\"Leonardo da Vinci\" in \"The Da Vinci Code\"\"Ada Lovelace\" in \"The Imitation Game\"
Ruler / PoliticianHolds formal power or influence; shapes policies, alliances, and social orders, whether for good or ill.\"President Franklin D. Roosevelt\" in \"Hyde Park on Hudson\"\"Selina Meyer\" in \"Veep\"\"Duncan Idaho\" in \"Dune\"
Sidekick / Loyal CompanionA supportive ally, assisting the hero, offering loyalty, encouragement, and sometimes comic or emotional relief.\"Ron Weasley\" in \"Harry Potter and the Philosopher's Stone\"\"Dr. John Watson\" in \"Sherlock Holmes: A Game of Shadows\"\"Robin\" in \"Batman: The Movie\"
Warrior / VigilanteSkilled in combat and physical confrontation; may enforce justice or defend others, sometimes outside legal boundaries.\"Batman\" in \"The Dark Knight\"\"John Wick\" in \"John Wick\"\"The Bride\" in \"Kill Bill\"
Rogue / Trickster / Con ArtistA cunning, rule-bending manipulator who achieves goals through deception, charm, or clever schemes.\"Frank Abagnale Jr.\" in \"Catch Me If You Can (2002)\"\"Irving Rosenfeld\" in \"American Hustle (2013)\"\"Lawrence Jamieson\" in \"Dirty Rotten Scoundrels (1988)\"
Mystic / SeerOffers spiritual guidance, foresight, or mystical understanding, often steering characters with visions or cryptic wisdom.\"The Oracle\" in \"The Matrix\"\"Yoda\" in \"The Empire Strikes Back\"\"Galadriel\" in \"The Lord of the Rings: The Fellowship of the Ring\"
Outsider / LonerOperates on the fringe of society, often misunderstood or self-isolated, bringing a unique perspective.\"Edward Scissorhands\" in \"Edward Scissorhands\"\"Rick Deckard\" in \"Blade Runner\"\"Chuck Noland\" in \"Cast Away\"
Innocent / VulnerableNaive, inexperienced, or in need of guidance; prompts protection or mentoring, and highlights moral stakes.\"Daniel LaRusso\" in \"The Karate Kid\"\"Charlie Bucket\" in \"Willy Wonka & the Chocolate Factory\"\"Newt\" in \"Aliens\"
OtherDoesn't align with any of the proposed archetype categories\"George McFly\" in \"Back to the Future\"\"Victor\" in \"John Wick\"\"Mayor\" in \"Ghostbusters\"
\n", + "
" + ] + }, { "cell_type": "markdown", "metadata": {}, From 0ae6bea11e0d1bd93c0a6f228b74bc2a9aecc009 Mon Sep 17 00:00:00 2001 From: Aleksandr Dremov Date: Thu, 19 Dec 2024 15:50:53 +0100 Subject: [PATCH 3/4] Update render.py (#15) --- pages/render.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/pages/render.py b/pages/render.py index f1cd89d..d999b7e 100644 --- a/pages/render.py +++ b/pages/render.py @@ -38,6 +38,13 @@ def overflowing_div(content): "" ) +def raw_context(content): + return ( + '\n{% raw %}\n
\n' + + content + + '\n
\n{% endraw %}\n' + ) + def render(cell): match cell['cell_type']: @@ -71,7 +78,7 @@ def render_code(cell): if "text/html" in data: output_text += ( '\n' + - overflowing_div(''.join(data["text/html"])) + + raw_context(overflowing_div(''.join(data["text/html"]))) + '\n' ) elif "text/plain" in data: @@ -90,7 +97,18 @@ def render_code(cell): ) elif output['output_type'] == 'display_data': data = output['data'] - if "image/png" in data: + print(data.keys(), "text/html" in data, file=sys.stderr) + if "text/html" in data: + output_text += ( + raw_context(''.join( + filter( + lambda x: len(x.strip()) > 0, + data["text/html"] + ) + ) + ) + ) + elif "image/png" in data: output_text += ( f'\n{\n' ) @@ -109,7 +127,7 @@ def render_code(cell): def render_markdown(cell): return ( "\n" + - escape(''.join(cell['source'])) + + ''.join(cell['source']) + "\n" ) From e7f46f2490147c76ee698e687ecf7244d4d883ed Mon Sep 17 00:00:00 2001 From: Aleksandr Dremov Date: Thu, 19 Dec 2024 19:31:45 +0100 Subject: [PATCH 4/4] Update render.py --- pages/render.py | 50 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/pages/render.py b/pages/render.py index d999b7e..126092e 100644 --- a/pages/render.py +++ b/pages/render.py @@ -2,6 +2,15 @@ import sys import textwrap from html import escape +import base64 +import os +import glob + +IMAGES_DIR = os.path.join( + os.path.dirname(__file__), + "assets", + "img", +) def is_cell_valid(cell): @@ -55,6 +64,28 @@ def render(cell): assert False, f"unknown type {cell['cell_type'] = }" +def save_png_and_get_name(base64_image): + imname = "generated_" + str(hash(base64_image)) + ".png" + path = os.path.join( + IMAGES_DIR, + imname + ) + with open(path, "wb") as fh: + fh.write(base64.b64decode(base64_image.encode())) + return imname + + +def save_svg_and_get_name(svg_code): + imname = "generated_" + str(hash(svg_code)) + ".svg" + path = os.path.join( + IMAGES_DIR, + imname + ) + with open(path, "w") as fh: + fh.write(svg_code) + return imname + + def render_code(cell): template = """\
code @@ -97,7 +128,6 @@ def render_code(cell): ) elif output['output_type'] == 'display_data': data = output['data'] - print(data.keys(), "text/html" in data, file=sys.stderr) if "text/html" in data: output_text += ( raw_context(''.join( @@ -108,9 +138,17 @@ def render_code(cell): ) ) ) + elif "image/svg+xml" in data: + output_text += ( + '\n{\n' + ) elif "image/png" in data: output_text += ( - f'\n{\n' + '\n{\n' ) else: assert False, f"unknown format: {data.keys() = }" @@ -145,8 +183,16 @@ def render_markdown(cell): mathjax: true --- +{% assign im_path = site.baseurl | append: "/assets/img/" %} + """ +for hgx in ( + glob.glob(os.path.join(IMAGES_DIR, "generated*.png")) + + glob.glob(os.path.join(IMAGES_DIR, "generated*.svg")) +): + os.remove(hgx) + for cell in merge_cells(notebook["cells"]): result_markdown += render(cell)