AWS Builder 文章

用提示词优先的产品设计,为 AWS Manila Community Day 构建 Tagalog 学习应用

本文说明如何把每一条提示词都当作产品决策,为 AWS Manila Community Day 创建一个 Tagalog 学习应用。目标不只是翻译。这个应用应帮助初学者礼貌地问候他人、提问、感谢志愿者、管理等待时间,并更有信心与 Manila 云技术社区建立连接。

Tagalog 学习应用文章系列

English 繁體中文 简体中文

本文说明如何把每一条提示词都当作产品决策,为 AWS Manila Community Day 创建一个 Tagalog 学习应用。目标不只是翻译。这个应用应帮助初学者礼貌地问候他人、提问、感谢志愿者、管理等待时间,并更有信心与 Manila 云技术社区建立连接。

免责声明

用途:这个静态应用是用于语言练习和开发者分享的教育原型。它帮助学习者为 AWS Manila Community Day 准备礼貌的 Tagalog 短语。

非商业用途:本项目没有付费功能、广告、注册要求或商业目的。它面向学习、实验和社区准备。

不作保证:生成的语言内容可能包含错误。Tagalog 翻译、语法说明、发音指南和文化注释在投入生产使用前,应由母语者检查。

范围:这个应用不是 AWS 官方产品,也不是官方翻译工具,更不能替代真人语言教学。它是一个包含实用学习内容的技术 demo。

社区尊重:应用应避免刻板印象,并谨慎讲解礼貌用语。像 poopokayoninyo 这样的词,应解释为表达尊重的工具,而不是装饰。


Demo

Kita tayo mamaya sa susunod na session.

语法拆解

  • Kita:在这个句子中可以表示“回头见”。
  • tayo:包容式的“我们”,表示你和我一起。
  • mamaya:表示“稍后”。
  • sa:根据语境可表示“在”“到”“向”或“为了”等含义。
  • susunod:表示“下一个”或“将跟随”。
  • session:英文活动词,在技术活动中的 Filipino-English 里很自然。

发音指南

可以按词逐个读作:
kee-tah tah-yoh mah-mah-yah sah soo-soo-nohd nah sehs-see-seeohn.

  • Kita: kee-tah.
  • tayo: tah-yoh.
  • mamaya: mah-mah-yah.
  • susunod: soo-soo-nohd.
  • session: sehs-see-seeohn.
    保持 Tagalog 元音稳定:a 类似 ah,i 类似 ee,o 类似 oh。

内容快照

自然 Tagalog:Kita tayo mamaya sa susunod na session.
礼貌 Tagalog:Kita tayo mamaya sa susunod na session po.
额外示例 1:Sa registration desk, sige: Kita tayo mamaya sa susunod na session.
额外示例 2:Pag may kausap na volunteer, kita tayo mamaya sa susunod na session.
额外示例 3:Ayos, kita tayo mamaya sa susunod na session.

目录

第 1 部分:从学习契约开始

第一部分说明如何把宽泛的语言学习想法转换成稳定的产品契约:句子类别、英文输入、自然 Tagalog、礼貌 Tagalog、友好的 Filipino-English、轻松玩笑式 Filipino-English、语法、示例、发音和文化语境。

第 2 部分:把 Demo 句子作为产品锚点

这一部分说明为什么 demo 短语应指导应用设计。像 Magpahinga muna tayo sa lilimUmupo ka sandali kung nahihilo kaPaki-check po kung pumasok ang bayad 这样的短语,会成为检验语气、礼貌程度和真实活动实用性的测试用例。

第 3 部分:构建能生成实用卡片的提示词

这一部分提供一条完整提示词,用于生成新的句子卡片。提示词要求 AI 区分正式、自然、礼貌、友好和轻松玩笑式输出,而不是把它们混在一个令人困惑的答案里。

第 4 部分:面向技术分享的开发技能

这一部分把应用转化为技术分享主题,涵盖 schema 设计、静态渲染、响应式布局、提示词版本管理、QA 检查和 demo 驱动迭代。

第 5 部分:给构建者的现场笔记

这一部分给出可复用于未来社区工具的实践经验:契约优先的内容、语气安全的语言生成、移动端优先审查,以及提示词压缩。


第 1 部分:从学习契约开始

目标

构建一个适合初学者的 Tagalog 学习应用,帮助学习者为 AWS Manila Community Day 做准备。应用应帮助学习者礼貌地与组织者、演讲嘉宾、志愿者、场馆工作人员和第一次见面的人交流。

提示词

第一条真正有用的提示词不应只要求“做一个翻译应用”,而应定义产品契约。

创建一个用于准备 AWS Manila Community Day 的 Tagalog 学习应用。

用户输入一个英文句子。
返回一张句子卡片,包含:
- 背景语境
- 英文输入
- 自然 Tagalog
- 礼貌 Tagalog
- 友好的 Filipino-English
- 轻松玩笑式 Filipino-English
- 语气
- 文化语境
- 语法拆解
- 常见语境和惯用法
- 额外示例
- 发音指南
- 相关的情感、诗意、礼貌和实用句型

规则:
- 使用简单的简体中文解释。
- 先给出自然 Tagalog。
- 在适合时使用带有 po、opo、kayo 或 ninyo 的礼貌 Tagalog。
- 将轻松玩笑式 Filipino-English 与正确的正式 Tagalog 分开。
- 覆盖 AWS Manila Community Day 场景:问候、介绍、问路、工作坊、志愿者、等待时间和礼貌告别。
- 包含初学者可以在活动现场大声说出来的示例。

结果

这个应用就不只是词典了。它会变成一个形态稳定的句子卡片生成器,可由同一个前端渲染。一张卡片可以用多种语气展示同一句话,同时不会让学习者混淆。

提示

  • 先定义句子卡片 schema,再设计界面。
  • 保持每个字段足够短,便于移动端阅读。
  • 将礼貌版本放在自然版本附近,方便对照。
  • 只把轻松玩笑式 Filipino-English 作为明确标注的非正式风格。
  • 将发音和文化语境视为一等学习内容。

Demo 示例

最新 HTML 内容在文章卡片中使用实用且不重复的示例:

Tagalog:Magpahinga muna tayo sa lilim.
中文:先让我们在阴凉处休息一下。

Tagalog:Umupo ka sandali kung nahihilo ka.
中文:如果你觉得头晕,就坐一会儿。

Tagalog:Paki-check po kung pumasok ang bayad.
中文:请检查款项是否已经到账。

这些示例很小,但能证明当前产品方向。它们覆盖健康建议、朋友关照、市场对话、付款确认,以及 Manila 日常沟通中的安全表达。


第 2 部分:把 Demo 句子作为产品锚点

目标

使用真实 demo 短语来测试应用是否能教授实用、礼貌且具备文化意识的沟通方式。

提示词

使用以下 demo 短语作为锚点示例:
1. Magpahinga muna tayo sa lilim. / 先让我们在阴凉处休息一下。
2. Umupo ka sandali kung nahihilo ka. / 如果你觉得头晕,就坐一会儿。
3. Paki-check po kung pumasok ang bayad. / 请检查款项是否已经到账。

对每个短语说明:
- 在 AWS Manila Community Day 的什么场景使用
- 为什么礼貌形式很重要
- 哪些词体现尊重
- 如何用友好随意的风格表达
- 如何避免在正式场景使用轻松玩笑式版本

结果

应用因此获得清晰的行为测试。如果它能解释好这三个短语,就能支持健康指引、朋友关照、购物互动、付款确认和 Manila 日常沟通。

提示

  • 在生成数百张卡片前,先选定锚点短语。
  • 将每个锚点短语作为 UI 测试用例。
  • 检查礼貌标记是否出现在正确位置。
  • 检查解释是否适合初学者。
  • 检查轻松玩笑式版本没有被呈现为正式 Tagalog。

从锚点短语得到的产品行为

1. 健康休息

自然 Tagalog:Magpahinga muna tayo sa lilim.
礼貌 Tagalog:Magpahinga muna tayo sa lilim.
使用场景:当某人疲惫或过热时,建议在阴凉处短暂休息。
技术说明:应用可以将其标记为 category = health_safety,tone = caring。

2. 头晕关照

自然 Tagalog:Umupo ka sandali kung nahihilo ka.
礼貌 Tagalog:Umupo po kayo sandali kung nahihilo kayo.
使用场景:建议感到头晕的人坐一会儿。
技术说明:应用可以将其标记为 category = health_advice,pattern = ____ kung ____。

3. 付款确认

自然 Tagalog:Paki-check kung pumasok ang bayad.
礼貌 Tagalog:Paki-check po kung pumasok ang bayad.
轻松玩笑式 Filipino-English:Payment check muna, all right.
使用场景:礼貌地请对方确认款项是否到账。
技术说明:应用可以将其标记为 category = payment_check,tone = polite_request。

第 3 部分:构建能生成实用卡片的提示词

目标

创建一条可重复使用的生成提示词,产出适合活动现场使用的卡片,而不是随机翻译。

提示词

你是一名 Tagalog 学习教练,正在帮助一位参加 AWS Manila Community Day 的初学者。

为以下类别创建 10 张句子卡片:工作坊问题。

每张卡片必须包含:
背景语境:
英文输入:
自然 Tagalog:
礼貌 Tagalog:
友好的 Filipino-English:
轻松玩笑式 Filipino-English:
语气:
文化语境:
语法拆解:
常见语境和惯用法:
额外示例:
发音指南:
相关的情感、诗意、礼貌和实用句型:

规则:
- 自然 Tagalog 必须出现在轻松玩笑式 Filipino-English 之前。
- 当表达尊重更稳妥时,使用 po、opo、kayo 和 ninyo。
- 包含实用的 AWS 活动词汇,如 workshop、session、demo、speaker、volunteer、registration、badge 和 venue。
- 说明句子是随意、礼貌、正式、轻松玩笑式,还是适合活动现场使用。
- 示例要足够短,便于移动端阅读。

结果

生成内容可以存储为 JSON 或 Markdown,并渲染到应用中。每个句子都变得可检查、可复用,也更容易改进。

提示

  • 生成内容时请求一个类别,而不是一次请求整个应用。
  • 限制每批生成数量,避免语气不一致。
  • 将提示词与生成内容放在一起,便于未来审查。
  • 如果应用公开发布,添加人工审查状态字段。
  • 保持提示词稳定,一次只改一个要求。

生成卡片示例

背景语境:
当某人在 Manila 日常健康或安全场景中感到头晕或疲惫时使用。

英文输入:
如果你觉得头晕,就坐一会儿。

自然 Tagalog:
Umupo ka sandali kung nahihilo ka.

礼貌 Tagalog:
Umupo po kayo sandali kung nahihilo kayo.

友好的 Filipino-English:
Sit muna po kung dizzy.

轻松玩笑式 Filipino-English:
Umupo muna, easy lang all right.

语气:
关怀、实用,并适合安全提醒场景。

文化语境:
面对保安、工作人员、司机、摊贩、长者和第一次见面的人时,使用礼貌版本。

语法拆解:
- Umupo:坐下
- sandali:一会儿
- kung:如果
- nahihilo:感到头晕
- po:礼貌标记

常见语境和惯用法:
当某人可能需要短暂休息时,可用于健康、天气、通勤、场馆或等待场景。

额外示例:
1. Magpahinga muna tayo sa lilim. / 先让我们在阴凉处休息一下。
2. Umupo ka sandali kung nahihilo ka. / 如果你觉得头晕,就坐一会儿。
3. Paki-check po kung pumasok ang bayad. / 请检查款项是否已经到账。

发音指南:
oo-MOO-poh kah sahn-DAH-lee koong nah-hee-HEE-loh kah.

相关句型:
用 ____ kung ____ 表达简单建议:Umupo ka kung nahihilo ka, Magpahinga ka kung pagod ka.

第 4 部分:面向技术分享的开发技能

目标

将应用构建过程转化为一场对开发者、学生、云技术构建者和社区志愿者有用的技术分享 session。

技术架构

/tagalog-learning-app
  /content
    greetings.json
    directions.json
    workshops.json
    volunteers-time.json
  /public
    index.html
    article.html
    app.js
    styles.css
  /prompts
    sentence-card-generator.md
    qa-checklist.md

数据契约

{
  "category": "health_safety_money",
  "title": "Manila Daily: Health, Safety, Weather, and Money",
  "cards": [
    {
      "id": "health-safety-001",
      "englishInput": "Sit for a moment if you feel dizzy.",
      "naturalTagalog": "Umupo ka sandali kung nahihilo ka.",
      "politeTagalog": "Umupo po kayo sandali kung nahihilo kayo.",
      "friendlyFilipinoEnglish": "Sit muna po kung dizzy.",
      "playfulFilipinoEnglish": "Umupo muna, easy lang all right.",
      "tone": "caring, practical, health-and-safety-ready",
      "culturalContext": "Use the polite version with guards, staff, drivers, vendors, elders, and first-time contacts.",
      "grammar": [
        { "term": "Umupo", "meaning": "sit down" },
        { "term": "sandali", "meaning": "for a moment" },
        { "term": "nahihilo", "meaning": "feeling dizzy" },
        { "term": "po", "meaning": "politeness marker" }
      ]
    }
  ]
}

渲染逻辑

function renderCard(card) {
  return `
    <article class="sentence-card">
      <h2>${card.englishInput}</h2>
      <p><strong>Natural Tagalog:</strong> ${card.naturalTagalog}</p>
      <p><strong>Polite Tagalog:</strong> ${card.politeTagalog}</p>
      <p><strong>Friendly Filipino-English:</strong> ${card.friendlyFilipinoEnglish}</p>
      <p><strong>Playful Filipino-English:</strong> ${card.playfulFilipinoEnglish}</p>
      <p><strong>Tone:</strong> ${card.tone}</p>
    </article>
  `;
}

实现

附件展示了提示词优先的产品设计如何变成静态 HTML 生成流水线。它定义了文章元数据、句子卡片数据集、扩展规则、发音辅助、语法拆解逻辑、示例生成、卡片渲染、响应式 CSS、文章页面写入、索引页面写入、ZIP 打包和二次一致性检查。

from pathlib import Path
import html
import zipfile
import textwrap
import re
import json
import os

out_dir = Path(".")

# Article metadata with 20-word summaries
# checked by simple whitespace count in code comments/log output.
articles = [
    {
        "id": 1,
        "slug": "community-greetings-introductions",
        "title": "Community Day: Greetings and Respectful Introductions",
        "category": "Community Day",
        "summary": (
            "Practice polite greetings, names, beginner phrases, and warm introductions "
            "for meeting speakers, volunteers, students, and builders in Manila confidently."
        ),
    },
    {
        "id": 2,
        "slug": "community-directions-registration",
        "title": "Community Day: Directions, Venue, and Registration",
        "category": "Community Day",
        "summary": (
            "Learn useful venue phrases for registration, rooms, seats, restrooms, exits, "
            "queues, badges, and polite help requests during the event."
        ),
    },
    {
        "id": 3,
        "slug": "community-workshops-learning",
        "title": "Manila Daily: Health, Safety, Weather, and Money",
        "category": "Community Day",
        "summary": (
            "Ask workshop questions, request repeats, discuss demos, serverless ideas, "
            "AI solutions, cloud labs, and learning goals with respectful Tagalog."
        ),
    },
    {
        "id": 4,
        "slug": "community-networking-belonging",
        "title": "Community Day: Networking, Connect, and Belong",
        "category": "Community Day",
        "summary": (
            "Use friendly phrases to connect with developers, students, leaders, and peers "
            "while expressing excitement, humility, gratitude, and belonging."
        ),
    },
    {
        "id": 5,
        "slug": "community-volunteers-time-goodbye",
        "title": "Community Day: Volunteers, Waiting, Time, and Goodbye",
        "category": "Community Day",
        "summary": (
            "Thank volunteers, manage waiting time, apologize politely, coordinate arrivals, "
            "say goodbye warmly, and respect schedules with practical phrases."
        ),
    },
    {
        "id": 6,
        "slug": "friendship-one-question-one-answer",
        "title": "Friendship Tagalog: One Question, One Gentle Answer",
        "category": "Friendship",
        "summary": (
            "Practice original friendship questions about sincerity, answers, hope, courage, "
            "and honest feelings without copying any copyrighted song lyrics."
        ),
    },
    {
        "id": 7,
        "slug": "friendship-friends-only-feelings",
        "title": "Friendship Tagalog: Friends Only Feelings",
        "category": "Friendship",
        "summary": (
            "Learn gentle phrases about friendship, uncertainty, hope, boundaries, and "
            "emotional clarity using respectful, soft, beginner-friendly Tagalog patterns."
        ),
    },
    {
        "id": 8,
        "slug": "friendship-you-are-my-beloved",
        "title": "Friendship Tagalog: You Are My Beloved",
        "category": "Friendship",
        "summary": (
            "Explore original poetic devotion phrases about care, affection, trust, support, "
            "and choosing someone with warm but simple Tagalog."
        ),
    },
    {
        "id": 9,
        "slug": "friendship-honest-heart-deep-feelings",
        "title": "Friendship Tagalog: Honest Heart and Deep Feelings",
        "category": "Friendship",
        "summary": (
            "Build vocabulary for truthful emotions, nervous hearts, sincere admiration, "
            "quiet longing, and careful confession in natural polite Tagalog."
        ),
    },
    {
        "id": 10,
        "slug": "friendship-distance-hope-promises",
        "title": "Friendship Tagalog: Distance, Hope, and Promises",
        "category": "Friendship",
        "summary": (
            "Practice original phrases about distance, waiting, promises, north and south, "
            "hope, patience, and love that remains steady."
        ),
    },
]

community_sets = {
    1: [
        (
            "I am happy to meet you today.",
            "Masaya akong makilala ka ngayon.",
            "Masaya po akong makilala kayo ngayon.",
            "Happy to meet you today, kumusta!",
            "Masaya akong makilala ka ngayon, all right.",
            "warm, polite, event-ready",
        ),
        (
            "Hello, I am learning Tagalog.",
            "Kumusta, nag-aaral ako ng Tagalog.",
            "Kumusta po, nag-aaral po ako ng Tagalog.",
            "Hello po, learning Tagalog ako.",
            "Kumusta, learning Tagalog na ako, all right.",
            "friendly, beginner-friendly",
        ),
        (
            "My name is Martinez.",
            "Ako si Martinez.",
            "Ako po si Martinez.",
            "Hi po, ako si Martinez.",
            "Ako si Martinez, ready na ako all right.",
            "simple introduction",
        ),
        (
            "This is my first time in Manila.",
            "First time ko sa Manila.",
            "First time ko po sa Manila.",
            "First time ko po sa Manila, excited ako.",
            "First time ko sa Manila, all right amazed.",
            "personal, excited",
        ),
        (
            "I want to greet everyone politely.",
            "Gusto kong bumati sa lahat nang magalang.",
            "Gusto ko pong bumati sa lahat nang magalang.",
            "Gusto ko pong mag-greet sa lahat.",
            "Gusto kong mag-greet sa lahat, polite mode all right.",
            "respectful, practical",
        ),
        (
            "Good morning, everyone.",
            "Magandang umaga sa lahat.",
            "Magandang umaga po sa inyong lahat.",
            "Good morning po sa lahat.",
            "Magandang umaga, ready na tayo all right.",
            "formal greeting",
        ),
        (
            "May I sit here?",
            "Puwede ba akong umupo dito?",
            "Puwede po ba akong umupo dito?",
            "Can I sit here po?",
            "Puwede ba akong umupo dito, all right?",
            "polite request",
        ),
        (
            "I am a beginner, so please speak slowly.",
            "Baguhan ako, kaya pakibagalan.",
            "Baguhan po ako, kaya pakibagalan po.",
            "Beginner po ako, slow lang please.",
            "Beginner ako, slow lang all right please.",
            "humble, practical",
        ),
        (
            "I am excited to join Manila Community Day.",
            "Excited akong sumali sa Manila Community Day.",
            "Excited po akong sumali sa Manila Community Day.",
            "Excited po ako for Manila Community Day.",
            "Excited na ako sa Community Day, all right.",
            "excited, event-ready",
        ),
        (
            "Thank you for welcoming me.",
            "Salamat sa pagtanggap sa akin.",
            "Salamat po sa pagtanggap sa akin.",
            "Thank you po for welcoming me.",
            "Salamat sa welcome, belong na ako all right.",
            "grateful, emotional",
        ),
    ],
    2: [
        (
            "Where is the registration area?",
            "Saan ang registration area?",
            "Saan po ang registration area?",
            "Saan po ang registration area, please?",
            "Saan ang registration area, ready na ako all right.",
            "polite direction",
        ),
        (
            "Where is the workshop room?",
            "Saan ang workshop room?",
            "Saan po ang workshop room?",
            "Saan po ang workshop room, please?",
            "Saan ang workshop room, workshop mode all right.",
            "practical, event-ready",
        ),
        (
            "Could you point me to the entrance?",
            "Puwede mo ba akong ituro sa entrance?",
            "Puwede po ba ninyo akong ituro sa entrance?",
            "Pa-point po sa entrance?",
            "Point me sa entrance, lost na ako all right.",
            "polite help request",
        ),
        (
            "Is this the correct line?",
            "Tamang pila ba ito?",
            "Tamang pila po ba ito?",
            "Correct line po ba ito?",
            "Tamang pila ba ito, checking all right.",
            "queue, practical",
        ),
        (
            "Where can I get my badge?",
            "Saan ko makukuha ang badge ko?",
            "Saan ko po makukuha ang badge ko?",
            "Saan po badge pickup?",
            "Saan badge ko, excited na all right.",
            "registration, polite",
        ),
        (
            "Is there a seat available here?",
            "May bakanteng upuan ba dito?",
            "May bakanteng upuan po ba dito?",
            "May seat po ba dito?",
            "May seat ba dito, sit na ako all right.",
            "polite, seating",
        ),
        (
            "Where is the restroom?",
            "Saan ang restroom?",
            "Saan po ang restroom?",
            "Saan po ang CR?",
            "Saan ang CR, quick lang all right.",
            "practical direction",
        ),
        (
            "What time does the next session start?",
            "Anong oras magsisimula ang susunod na session?",
            "Anong oras po magsisimula ang susunod na session?",
            "What time po next session?",
            "Next session what time, all right.",
            "time, event-ready",
        ),
        (
            "Please wait for me for a few minutes.",
            "Hintayin mo ako ng ilang minuto.",
            "Hintayin n’yo po ako ng ilang minuto.",
            "Wait me for a few minutes po.",
            "Hintayin mo ako, papunta na ako all right.",
            "waiting, coordination",
        ),
        (
            "Please check if the payment arrived.",
            "Paki-check kung pumasok ang bayad sa venue.",
            "Paki-check po kung pumasok ang bayad sa venue.",
            "Payment received po ba?",
            "Paki-check kung pumasok ang bayad sa venue, all right.",
            "payment check",
        ),
    ],
}

# Expand each 10 base sentences to 40 by making contextual variants.
community_contexts = [
    ("at the morning registration", "sa morning registration"),
    ("before the workshop starts", "bago magsimula ang workshop"),
    ("while meeting a volunteer", "habang may nakikilalang volunteer"),
    ("after the session", "pagkatapos ng session"),
]

friendship_contexts = [
    ("when speaking softly", "kapag marahang nagsasalita"),
    ("while waiting for an answer", "habang naghihintay ng sagot"),
    ("in a sincere message", "sa isang tapat na mensahe"),
    ("with a careful heart", "nang may maingat na puso"),
]


def expand(base, article_id):
    contexts = community_contexts if article_id <= 5 else friendship_contexts
    cards = []

    for i, b in enumerate(base):
        for j, (enctx, tlctx) in enumerate(contexts):
            eng, nat, pol, friendly, playful, tone = b

            # Keep sentence clear; add context in background,
            # not necessarily append to every translation.
            cards.append(
                {
                    "num": len(cards) + 1,
                    "background": (
                        f"Use this sentence {enctx}. It helps connect emotion, culture, "
                        "politeness, and practical communication."
                    ),
                    "english": eng,
                    "natural": nat,
                    "polite": pol,
                    "friendly": friendly,
                    "playful": playful,
                    "tone": tone,
                    "context_en": enctx,
                    "context_tl": tlctx,
                }
            )

    return cards[:40]


for a in articles:
    base = community_sets.get(a["id"]) or friendship_sets.get(a["id"])
    a["cards"] = expand(base, a["id"])


# Simple pronunciation generation for consistent guides.
pron_map = {
    "Kumusta": "koo-MOOS-tah",
    "Salamat": "sah-LAH-maht",
    "Puwede": "PWEH-deh",
    "Saan": "SAH-ahn",
    "Ako": "AH-koh",
    "po": "poh",
    "kayo": "KAH-yoh",
    "ninyo": "NEEN-yoh",
    "n’yo": "nyoh",
    "Gusto": "GOOS-toh",
    "Excited": "ek-SAI-ted",
    "Nandito": "nahn-DEE-toh",
    "Papunta": "pah-POON-tah",
    "Hintayin": "hin-tah-YEEN",
    "Pasensya": "pah-SEN-shah",
    "Mahalaga": "mah-hah-LAH-gah",
    "Sasamahan": "sah-sah-MAH-hahn",
    "Kahit": "kah-HEET",
    "Manila": "mah-NEE-lah",
    "Tagalog": "tah-GAH-log",
    "magtanong": "mag-tah-NONG",
    "pakiulit": "pah-kee-OO-lit",
}


def pronunciation(tl):
    # Provide a compact guide using known phrase starts, plus simple fallback.
    for k, v in pron_map.items():
        if tl.startswith(k) or f" {k}" in tl:
            # Highlight first relevant chunk and add readable text.
            return (
                f"Say it slowly and clearly. Start with: {v}. Keep 'po' soft, "
                "and stress the capital syllables in this guide."
            )

    return (
        "Read each vowel clearly: a as ah, e as eh, i as ee, o as oh, u as oo. "
        "Keep the final syllable clear."
    )


def breakdown(card):
    e = card["english"].lower()
    nat = card["natural"]
    items = []

    def add(tag, meaning):
        items.append((tag, meaning))

    if "thank" in e or "salamat" in nat.lower():
        add("Salamat", "thank you; a core gratitude word")
        add(
            "po",
            "politeness marker used with elders, speakers, organizers, volunteers, or new people",
        )
        add("sa", "for, in, at, or to depending on context")

    elif "where" in e or nat.lower().startswith("saan"):
        add("Saan", "where; asks for a place or direction")
        add("po", "polite marker for respectful questions")
        add("ang", "focus marker before the place or thing being asked about")

    elif "may i" in e or "could" in e or "please" in e:
        add("Puwede / Paki-", "may, can, or please; softens a request")
        add("po", "polite marker")
        add("ba", "question marker used in yes/no questions")

    elif "wait" in e or "way" in e or "late" in e:
        add(
            "Hintayin / Papunta / Pasensya",
            "waiting, on-the-way, and apology words for coordination",
        )
        add("na", "now or all right; often shows change of state")
        add("po", "polite marker")

    elif any(
        w in e
        for w in [
            "heart",
            "love",
            "feel",
            "answer",
            "friends",
            "hope",
            "promise",
            "dear",
            "admire",
        ]
    ):
        add("puso / damdamin", "heart or feelings; emotional vocabulary")
        add("sana", "hope or wish; makes the sentence gentle")
        add(
            "po / kayo / ninyo",
            "respectful forms when the tone should stay careful and polite",
        )

    elif "excited" in e:
        add("Excited ako", "I am excited; common Filipino-English expression")
        add("-ng / akong", "linker form connecting I am to the next action")
        add("sumali / matuto", "to join or to learn")

    else:
        add("Ako / ko", "I or my; marks the speaker")
        add("ka / kayo", "you; kayo is polite or plural")
        add("po", "polite marker used for respect")

    return items[:3]


def examples(card, article_id):
    if article_id <= 5:
        return [
            ("Magpahinga muna tayo sa lilim.", "Let us rest in the shade first."),
            ("Umupo ka sandali kung nahihilo ka.", "Sit for a moment if you feel dizzy."),
            ("Paki-check po kung pumasok ang bayad.", "Please check if the payment came in."),
        ]

    return [
        ("Sana maintindihan mo ako.", "I hope you understand me."),
        ("Makikinig po ako nang may respeto.", "I will listen with respect."),
        ("Tapat ang damdamin ko, all right.", "My feeling is sincere all right."),
    ]


def sentence_card_html(card, article):
    bds = "".join(
        f"<li><strong>{html.escape(k)}:</strong> {html.escape(v)}</li>"
        for k, v in breakdown(card)
    )

    exs = "".join(
        (
            f"<li><strong>Tagalog:</strong> {html.escape(tl)}<br>"
            f"<strong>English:</strong> {html.escape(en)}</li>"
        )
        for tl, en in examples(card, article["id"])
    )

    related = (
        "Event pattern: use the polite version first with speakers, organizers, "
        "volunteers, and people you meet for the first time. Casual and playful styles "
        "are better with peers after rapport."
        if article["id"] <= 5
        else (
            "Emotional pattern: keep the sentence gentle, avoid pressure, and use sana, "
            "po, kayo, or ninyo when respect and careful tone matter."
        )
    )

    return f"""
    <article class="sentence-card" id="sentence-{card['num']}">
      <h3>Sentence {card['num']}</h3>
      <dl class="template">
        <dt>Background context:</dt><dd>{html.escape(card['background'])}</dd>
        <dt>English Input:</dt><dd>{html.escape(card['english'])}</dd>
        <dt>Natural Tagalog:</dt><dd lang="tl">{html.escape(card['natural'])}</dd>
        <dt>Polite Tagalog:</dt><dd lang="tl">{html.escape(card['polite'])}</dd>
        <dt>Friendly Filipino-English:</dt><dd>{html.escape(card['friendly'])}</dd>
        <dt>playful Filipino-English:</dt><dd>{html.escape(card['playful'])}</dd>
        <dt>Tone:</dt><dd>{html.escape(card['tone'])}</dd>
        <dt>Cultural Context:</dt><dd>Use the polite form with elders, speakers, organizers, volunteers, venue staff, and first-time contacts. Use casual speech with friends or peers when the situation feels relaxed.</dd>
        <dt>Grammatical Breakdown:</dt><dd><ul>{bds}</ul></dd>
        <dt>Common Context and Idiomatic Use:</dt><dd>This phrase is useful for {html.escape(card['context_en'])}. It teaches both correct Tagalog and a safe respectful option.</dd>
        <dt>Extra Examples:</dt><dd><ol>{exs}</ol></dd>
        <dt>Pronunciation Guide:</dt><dd>{html.escape(pronunciation(card['polite']))}</dd>
        <dt>Related understand emotional, poetic, polite, and practical sentence patterns:</dt><dd>{html.escape(related)}</dd>
      </dl>
    </article>"""

开发技能

这里的开发技能,是设计一条可重复的内容流水线:提示词输入、结构化 schema、审查清单和静态渲染器。这样文章不仅适合语言学习,也适合作为技术分享材料。

分享角度

做技术分享时,不要把应用包装成“AI 魔法”。应把它呈现为一个有纪律的内容系统:

  • 提示词契约控制输出一致性。
  • JSON schema 控制渲染。
  • 静态 HTML 快速验证学习闭环。
  • 响应式设计让应用在手机上可用。
  • 人工审查保护文化准确性。

第 5 部分:给构建者的现场笔记

现场笔记 1:契约优先的内容

背景:如果每次输出的形态都不同,翻译应用很容易变得混乱。

目标:让每张句子卡片都可预测。

提示词:创建一张卡片,包含自然 Tagalog、礼貌 Tagalog、友好的 Filipino-English、轻松玩笑式 Filipino-English、语法、示例、发音和文化语境。

结果:UI 可以用同一个组件渲染每张卡片。

提示:

  • 使用一个 schema。
  • 保持字段名称稳定。
  • 将内容与设计分离。
  • 扩展前先审查一个类别。
  • 保存生成提示词。

现场笔记 2:把礼貌作为产品逻辑

背景:学习者需要知道什么时候使用 poopokayoninyo

目标:通过可见的替代表达来教授尊重。

提示词:当学习者面对长者、演讲嘉宾、组织者、志愿者、场馆工作人员或第一次见面的人时,始终包含礼貌版本。

结果:应用不只是翻译,还教授社交语境。

提示:

  • 将礼貌 Tagalog 放在自然 Tagalog 附近。
  • 解释哪些对象适合使用礼貌表达。
  • 避免在听起来自然度不足的地方过度使用礼貌标记。
  • 将随意表达和礼貌表达并排展示。
  • 添加语气标签。

现场笔记 3:轻松玩笑式风格需要边界

背景:Filipino-English 可以让应用更有趣,但学习者可能会把轻松玩笑式风格误认为正式 Tagalog。

目标:让应用保持有趣,同时避免学习者在正式语境中显得不合适。

提示词:将轻松玩笑式 Filipino-English 标记为非正式,并先展示自然 Tagalog。

结果:像 Payment check muna, all right 这样的轻松表达会成为随意选项,而不是默认的正式答案。

提示:

  • 清晰标注轻松玩笑式输出。
  • 与同龄人或熟悉的人使用,而不是面对正式演讲者使用。
  • 说明 na 有时可以承载类似“好了/已经”的语感。
  • 保持轻松示例简短。
  • 永远不要用轻松玩笑式版本替代自然版本。

现场笔记 4:移动端优先的卡片审查

背景:活动学习者通常会在场馆内用手机使用应用。

目标:让最有用的句子容易找到,也容易大声说出来。

提示词:在移动端先展示文章内容,再通过按钮展示文章列表。

结果:学习者会先阅读当前课程,再跳转到其他内容。

提示:

  • 保持标签简短。
  • 使用较大的点击区域。
  • 避免在卡片中放入密集段落。
  • 将发音放在短语附近。
  • 用单手测试。

现场笔记 5:Demo 驱动的 QA

背景:生成式应用可能看起来很完整,但仍无法满足真实活动用例。

目标:用三条 demo 短语测试应用。

提示词:用 Magpahinga muna tayo sa lilimUmupo ka sandali kung nahihilo kaPaki-check po kung pumasok ang bayad 验证每个类别。

结果:应用会始终贴近感谢表达、礼貌提问和到达协调等真实需求。

提示:

  • 将锚点短语作为回归测试。
  • 确认存在语法拆解。
  • 确认存在礼貌版本。
  • 确认轻松玩笑式版本已标注。
  • 确认示例适合活动现场使用。

结语反思

面向 AWS Manila Community Day 的 Tagalog 学习应用,是一个带有人文目的的小型技术项目。它帮助学习者以谦逊的姿态来到现场,提出更好的问题,感谢志愿者,并准备好融入社区。技术上的经验很简单:当提示词成为契约时,应用就更容易构建、审查和分享。