generate_jsonl.js 30.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736
const fs = require('fs');
const path = require('path');

const outDir = '/Users/yibo/Documents/LemonAI/lemonboss/system/templates/trend-scout-global/train/digest';

function writeJSONL(filepath, records) {
  const lines = records.map(r => JSON.stringify(r)).join('\n') + '\n';
  fs.writeFileSync(filepath, lines, 'utf8');
}

const train = [
  {
    input: {
      raw_html_title: "TikTok Creative Center - Trending Hashtags in France",
      raw_entry: {
        trend_name: "#vertical drama",
        posts: "49.6B",
        growth: "+224%"
      },
      source_url: "https://ads.tiktok.com/business/en-US/solutions/tiktok-for-business/creative-center"
    },
    expected_output: {
      trend_id: "tsgl_001",
      platform: "TikTok",
      region: "FR",
      content_type: "hashtag",
      name: "#vertical drama",
      rank: 1,
      views_or_posts: 49637530074,
      growth_7d: 2.24,
      related_hashtags: ["#vertical drama", "#vampire love", "#strong female lead"],
      source_url: "https://ads.tiktok.com/business/en-US/solutions/tiktok-for-business/creative-center",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 100,
    grader_hints: "Verify platform maps to TikTok, region FR, content_type hashtag, growth parsed from percentage to float."
  },
  {
    input: {
      api_response: {
        items: [
          { id: "yt_abc123", snippet: { title: "Werewolf Mate - Episode 1 | Short Drama", channelTitle: "DramaBox", categoryId: "42" }, statistics: { viewCount: "45068436722", likeCount: "1200000" } }
        ]
      },
      source_url: "https://www.googleapis.com/youtube/v3/videos"
    },
    expected_output: {
      trend_id: "tsgl_002",
      platform: "YouTube",
      region: "CA",
      content_type: "video",
      name: "#werewolf mate",
      rank: 2,
      views_or_posts: 45068436722,
      growth_7d: 1.40,
      related_hashtags: ["#vertical drama", "#dramabox", "#short drama"],
      source_url: "https://youtube.com/trend/2",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 100,
    grader_hints: "Map YouTube Data API response to YouTube platform; extract video title and derive hashtag/theme."
  },
  {
    input: {
      api_response: {
        data: [
          { id: "tw_987654", text: "Just watched the latest #mafia romance on ReelShort and I'm hooked! #billionaire romance #vampire love", public_metrics: { like_count: 3400, retweet_count: 890 }, created_at: "2026-04-12T18:30:00Z" }
        ]
      },
      source_url: "https://api.twitter.com/2/tweets/search/recent"
    },
    expected_output: {
      trend_id: "tsgl_003",
      platform: "X",
      region: "US",
      content_type: "hashtag",
      name: "#mafia romance",
      rank: 3,
      views_or_posts: 4290,
      growth_7d: 1.75,
      related_hashtags: ["#billionaire romance", "#vampire love"],
      source_url: "https://api.twitter.com/2/tweets/search/recent",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 9, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 98,
    grader_hints: "Extract dominant hashtag and engagement metrics from X API tweet object."
  },
  {
    input: {
      scraped_cards: [
        { title: "Contract Marriage - A Second Chance", tag: "Trending in Mexico" }
      ],
      source_url: "https://www.reelshort.com/"
    },
    expected_output: {
      trend_id: "tsgl_004",
      platform: "ReelShort",
      region: "MX",
      content_type: "hashtag",
      name: "#contract marriage",
      rank: 4,
      views_or_posts: 549202761,
      growth_7d: 2.58,
      related_hashtags: ["#strong female lead", "#vampire love", "#interactive story"],
      source_url: "https://www.reelshort.com/",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 9, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 98,
    grader_hints: "Scraped ReelShort card does not provide native view count; agent must synthesize from seed context or mark unknown if hallucination is detected."
  },
  {
    input: {
      raw_entry: {
        name: "#strong female lead",
        posts: "24.8B",
        growth: "+194%",
        related: "#revenge, #billionaire romance, #interactive story"
      },
      source_url: "https://instagram.com/explore/tags/strongfemalelead"
    },
    expected_output: {
      trend_id: "tsgl_005",
      platform: "Instagram",
      region: "UK",
      content_type: "hashtag",
      name: "#strong female lead",
      rank: 5,
      views_or_posts: 24832704979,
      growth_7d: 1.94,
      related_hashtags: ["#revenge", "#billionaire romance", "#interactive story"],
      source_url: "https://instagram.com/explore/tags/strongfemalelead",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 100,
    grader_hints: "Instagram scraped tag page mapped to Instagram platform; parse comma-separated related hashtags into array."
  },
  {
    input: {
      raw_entry: {
        term: "short drama",
        geo: "US",
        timeline: [
          { date: "2026-04-06", value: 45 },
          { date: "2026-04-13", value: 92 }
        ]
      },
      source_url: "https://trends.google.com/trends/explore?geo=US&q=short+drama"
    },
    expected_output: {
      trend_id: "tsgl_006",
      platform: "Google Trends",
      region: "US",
      content_type: "search_term",
      name: "short drama",
      rank: 6,
      views_or_posts: 92,
      growth_7d: 2.04,
      related_hashtags: ["#short drama", "#vertical drama", "#interactive story"],
      source_url: "https://trends.google.com/trends/explore?geo=US&q=short+drama",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 100,
    grader_hints: "Compute growth_7d from Google Trends timeline (92/45 ≈ 2.04) and map search term to content_type search_term."
  },
  {
    input: {
      raw_entry: {
        pin_title: "Billionaire Romance Aesthetic",
        saves: "11.9B",
        growth: "+139%"
      },
      source_url: "https://pinterest.com/trend/25"
    },
    expected_output: {
      trend_id: "tsgl_007",
      platform: "Pinterest",
      region: "UK",
      content_type: "hashtag",
      name: "#billionaire romance",
      rank: 7,
      views_or_posts: 11918710562,
      growth_7d: 1.39,
      related_hashtags: ["#mafia romance", "#billionaire romance", "#second chance"],
      source_url: "https://pinterest.com/trend/25",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 100,
    grader_hints: "Pinterest pin mapped correctly; parse saves string to numeric views_or_posts."
  },
  {
    input: {
      raw_entry: {
        creator: "@dramaqueen_ph",
        caption: "Her revenge was sweeter than expected #revenge #verticaldrama #vampirelove",
        views: "21.5B",
        audio: "Original Sound - DramaQueen"
      },
      source_url: "https://tiktok.com/trend/6"
    },
    expected_output: {
      trend_id: "tsgl_008",
      platform: "TikTok",
      region: "PH",
      content_type: "video",
      name: "#strong female lead",
      rank: 8,
      views_or_posts: 21590111379,
      growth_7d: 1.06,
      related_hashtags: ["#interactive story", "#contract marriage", "#dramabox"],
      source_url: "https://tiktok.com/trend/6",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 9, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 98,
    grader_hints: "Extract dominant theme from caption hashtags; note that #verticaldrama should be normalized to #vertical drama if agent chooses to normalize."
  },
  {
    input: {
      api_response: {
        items: [
          { id: "yt_ep2", snippet: { title: "Second Chance with the Billionaire CEO | Vertical Drama", channelTitle: "Shorts King" }, statistics: { viewCount: "9560543647" } }
        ]
      },
      source_url: "https://www.googleapis.com/youtube/v3/videos"
    },
    expected_output: {
      trend_id: "tsgl_009",
      platform: "YouTube",
      region: "UK",
      content_type: "hashtag",
      name: "#second chance",
      rank: 9,
      views_or_posts: 9560543647,
      growth_7d: 3.46,
      related_hashtags: ["#second chance", "#vertical drama", "#revenge"],
      source_url: "https://youtube.com/trend/7",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 100,
    grader_hints: "YouTube video title contains both 'Second Chance' and 'Vertical Drama'; agent should choose the dominant IP theme for name."
  },
  {
    input: {
      raw_entry: {
        tweet_text: "#short drama threads are taking over my timeline #mafia romance #billionaire romance #vampire love",
        likes: 39278,
        retweets: 1622,
        impressions: 11657542039
      },
      source_url: "https://x.com/trend/24"
    },
    expected_output: {
      trend_id: "tsgl_010",
      platform: "X",
      region: "US",
      content_type: "hashtag",
      name: "#short drama",
      rank: 10,
      views_or_posts: 39278162212,
      growth_7d: 2.15,
      related_hashtags: ["#mafia romance", "#billionaire romance", "#vampire love"],
      source_url: "https://x.com/trend/24",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 100,
    grader_hints: "X text with multiple hashtags; agent extracts primary and related hashtags correctly."
  },
  {
    input: {
      raw_entry: {
        board_name: "Interactive Story Ideas",
        pins: 13213480577,
        weekly_growth: "+292%"
      },
      source_url: "https://pinterest.com/trend/30"
    },
    expected_output: {
      trend_id: "tsgl_011",
      platform: "Pinterest",
      region: "DE",
      content_type: "effect",
      name: "#interactive story",
      rank: 11,
      views_or_posts: 13213480577,
      growth_7d: 2.92,
      related_hashtags: ["#interactive story", "#second chance", "#strong female lead"],
      source_url: "https://pinterest.com/trend/30",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 100,
    grader_hints: "Pinterest board data mapped to effect/content_type depending on agent classification; accept either if consistent."
  },
  {
    input: {
      raw_html: "<div class='trend-item'><span class='trend-name'>#dramabox</span><span class='trend-posts'>35.0B</span><span class='trend-growth'>+97%</span></div>",
      source_url: "https://ads.tiktok.com/business/en-US/solutions/tiktok-for-business/creative-center"
    },
    expected_output: {
      trend_id: "tsgl_012",
      platform: "TikTok",
      region: "FR",
      content_type: "hashtag",
      name: "#dramabox",
      rank: 12,
      views_or_posts: 35050752458,
      growth_7d: 0.97,
      related_hashtags: ["#strong female lead", "#interactive story", "#vampire love"],
      source_url: "https://ads.tiktok.com/business/en-US/solutions/tiktok-for-business/creative-center",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 9, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 98,
    grader_hints: "Growth parsed from +97% yields 0.97 (plateau signal). Ensure agent does not mis-parse as 97.0."
  },
  {
    input: {
      raw_entry: {
        video_id: "ig_058",
        caption: "She came back for #revenge and nothing could stop her #vertical drama #vampire love",
        view_count: "11.4B",
        effect_used: "Dramatic Zoom"
      },
      source_url: "https://instagram.com/trend/58"
    },
    expected_output: {
      trend_id: "tsgl_013",
      platform: "Instagram",
      region: "IN",
      content_type: "effect",
      name: "#revenge",
      rank: 13,
      views_or_posts: 11463266640,
      growth_7d: 2.96,
      related_hashtags: ["#revenge", "#vertical drama", "#vampire love"],
      source_url: "https://instagram.com/trend/58",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 100,
    grader_hints: "Instagram Reels entry with explicit effect_used; agent should classify content_type as effect."
  },
  {
    input: {
      raw_entry: {
        title: "Mafia Romance - A Dark Love Story",
        channel: "Dreame Official",
        reads: 2064599747,
        weekly_change: "+110%"
      },
      source_url: "https://www.dreame.com/ranking"
    },
    expected_output: {
      trend_id: "tsgl_014",
      platform: "Dreame",
      region: "MX",
      content_type: "hashtag",
      name: "#mafia romance",
      rank: 14,
      views_or_posts: 2064599747,
      growth_7d: 1.10,
      related_hashtags: ["#billionaire romance", "#short drama", "#vampire love"],
      source_url: "https://www.dreame.com/ranking",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 100,
    grader_hints: "Third-party web novel platform mapped to Dreame platform; extract reads as views_or_posts."
  },
  {
    input: {
      raw_entry: {
        query: "#billionaire romance OR #vertical drama OR #interactive story -is:retweet",
        tweets: [
          { text: "The new #interactive story on ReelShort has 10 endings!", like_count: 540 },
          { text: "Obsessed with this #billionaire romance arc", like_count: 890 }
        ]
      },
      source_url: "https://api.twitter.com/2/tweets/search/recent"
    },
    expected_output: {
      trend_id: "tsgl_015",
      platform: "X",
      region: "UK",
      content_type: "video",
      name: "#interactive story",
      rank: 15,
      views_or_posts: 40629690668,
      growth_7d: 1.02,
      related_hashtags: ["#interactive story", "#second chance", "#mafia romance"],
      source_url: "https://api.twitter.com/2/tweets/search/recent",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 9, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 98,
    grader_hints: "Multi-tweet X search result; primary trend selection may vary slightly if based on engagement."
  },
  {
    input: {
      raw_entry: {
        trend_name: "#short drama",
        views: "15.8B",
        growth: "+337%",
        region_hint: "Brazil"
      },
      source_url: "https://tiktok.com/trend/16"
    },
    expected_output: {
      trend_id: "tsgl_016",
      platform: "TikTok",
      region: "BR",
      content_type: "hashtag",
      name: "#short drama",
      rank: 16,
      views_or_posts: 15860256070,
      growth_7d: 3.37,
      related_hashtags: ["#second chance", "#revenge", "#mafia romance"],
      source_url: "https://tiktok.com/trend/16",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 100,
    grader_hints: "Region inferred from 'Brazil' text hint mapped to BR."
  },
  {
    input: {
      raw_entry: {
        title: "Strong Female Lead Playlist",
        tracks: 15,
        monthly_listeners: 9576100091
      },
      source_url: "https://open.spotify.com/playlist/strongfemalelead"
    },
    expected_output: {
      trend_id: "tsgl_017",
      platform: "Spotify",
      region: "PH",
      content_type: "audio",
      name: "#strong female lead",
      rank: 17,
      views_or_posts: 9576100091,
      growth_7d: 1.75,
      related_hashtags: ["#revenge", "#vertical drama", "#strong female lead"],
      source_url: "https://open.spotify.com/playlist/strongfemalelead",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 100,
    grader_hints: "Spotify playlist mapped as audio platform; monthly listeners become views_or_posts."
  }
];

const test = [
  {
    input: {
      raw_entry: {
        trend_name: "#strong female lead",
        posts: "1.3B",
        growth: "+24%",
        platform_hint: "日本版TikTok",
        region_hint: "Japan"
      },
      source_url: "https://ads.tiktok.com/business/ja-JP/solutions/tiktok-for-business/creative-center"
    },
    expected_output: {
      trend_id: "tsgl_test_01",
      platform: "TikTok",
      region: "JP",
      content_type: "hashtag",
      name: "#strong female lead",
      rank: 1,
      views_or_posts: 1300000000,
      growth_7d: 0.24,
      related_hashtags: [],
      source_url: "https://ads.tiktok.com/business/ja-JP/solutions/tiktok-for-business/creative-center",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 9, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 98,
    grader_hints: "Cross-language platform hint (日本版TikTok) must resolve to TikTok and region JP. Empty related_hashtags should produce [] not null."
  },
  {
    input: {
      raw_entry: {
        tweet_text: "Rumor says #vampire love is peaking again but there's no data",
        likes: 3,
        retweets: 0,
        verified_account: false
      },
      source_url: "https://x.com/unverified_user/status/999"
    },
    expected_output: {
      trend_id: "tsgl_test_02",
      platform: "X",
      region: "UNKNOWN",
      content_type: "hashtag",
      name: "#vampire love",
      rank: 99,
      views_or_posts: 3,
      growth_7d: 0.00,
      related_hashtags: [],
      source_url: "https://x.com/unverified_user/status/999",
      crawl_time: "2026-04-13T02:40:00Z",
      confidence: "low"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 8, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 97,
    grader_hints: "Low-confidence source from unverified account with near-zero engagement must be flagged (confidence: low). Region unknown should default to UNKNOWN."
  },
  {
    input: {
      raw_entries: [
        { platform: "TikTok", region: "US", name: "#contract marriage", views: "24.5B", growth: "+298%", source_url: "https://tiktok.com/trend/32", crawl_time: "2026-04-10T00:00:00Z" },
        { platform: "YouTube", region: "US", name: "#contract marriage", views: "24.5B", growth: "+105%", source_url: "https://youtube.com/trend/32", crawl_time: "2026-04-13T02:40:00Z" }
      ]
    },
    expected_output: {
      trend_id: "tsgl_test_03",
      platform: "YouTube",
      region: "US",
      content_type: "hashtag",
      name: "#contract marriage",
      rank: 3,
      views_or_posts: 24563880969,
      growth_7d: 1.05,
      related_hashtags: ["#werewolf mate", "#contract marriage", "#revenge"],
      source_url: "https://youtube.com/trend/32",
      crawl_time: "2026-04-13T02:40:00Z",
      note: "TikTok entry older (2026-04-10); prefer fresher YouTube data."
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 100,
    grader_hints: "Multi-platform conflicting data: agent should prefer the more recent crawl_time (YouTube) and not average conflicting growth rates blindly."
  },
  {
    input: {
      raw_entry: {
        video_title: "Amor de Vampiro - Episodio 1",
        views: "4.4B",
        platform: "YouTube Shorts",
        region: "Brasil"
      },
      source_url: "https://youtube.com/shorts/vampiro_br"
    },
    expected_output: {
      trend_id: "tsgl_test_04",
      platform: "YouTube",
      region: "BR",
      content_type: "video",
      name: "#vampire love",
      rank: 4,
      views_or_posts: 44435047819,
      growth_7d: 1.00,
      related_hashtags: ["#vertical drama", "#contract marriage", "#werewolf mate"],
      source_url: "https://youtube.com/shorts/vampiro_br",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 9, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 98,
    grader_hints: "Cross-language trend title (Spanish) must be mapped to canonical English theme #vampire love. Region 'Brasil' → BR."
  },
  {
    input: {
      raw_entry: {
        trend_name: "#werewolf mate",
        posts: null,
        growth: null,
        rank: null
      },
      source_url: "https://instagram.com/trend/18"
    },
    expected_output: {
      trend_id: "tsgl_test_05",
      platform: "Instagram",
      region: "PH",
      content_type: "effect",
      name: "#werewolf mate",
      rank: 18,
      views_or_posts: 3337528725,
      growth_7d: 1.00,
      related_hashtags: ["#interactive story", "#mafia romance", "#strong female lead"],
      source_url: "https://instagram.com/trend/18",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 9, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 9 },
    score: 97,
    grader_hints: "Missing raw metrics should be inferred from seed context or fallback to sensible defaults rather than left as null."
  },
  {
    input: {
      raw_entry: {
        tweet_text: "#interactive story apps are booming in India and Philippines",
        likes: 15200,
        retweets: 3400,
        created_at: "2026-04-01T12:00:00Z"
      },
      source_url: "https://x.com/trend/old_post"
    },
    expected_output: {
      trend_id: "tsgl_test_06",
      platform: "X",
      region: "IN",
      content_type: "hashtag",
      name: "#interactive story",
      rank: 6,
      views_or_posts: 18600,
      growth_7d: 0.00,
      related_hashtags: ["#interactive story"],
      source_url: "https://x.com/trend/old_post",
      crawl_time: "2026-04-13T02:40:00Z",
      stale_warning: true
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 8, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 97,
    grader_hints: "Timeliness boundary: post from 2026-04-01 vs crawl_time 2026-04-13. Agent should flag stale_warning and avoid forecasting stale growth as current breakout."
  },
  {
    input: {
      raw_entries: [
        { source: "TikTok", region: "DE", name: "#vertical drama", views: "1.0B", growth: "+272%", source_url: "https://tiktok.com/trend/61" },
        { source: "YouTube", region: "DE", name: "#vertical drama", views: "7.0B", growth: "+87%", source_url: "https://youtube.com/trend/12" }
      ]
    },
    expected_output: {
      trend_id: "tsgl_test_07",
      platform: "YouTube",
      region: "DE",
      content_type: "hashtag",
      name: "#vertical drama",
      rank: 7,
      views_or_posts: 7028291176,
      growth_7d: 0.87,
      related_hashtags: ["#dramabox", "#billionaire romance", "#revenge"],
      source_url: "https://youtube.com/trend/12",
      crawl_time: "2026-04-13T02:40:00Z",
      conflict_resolution: "Higher volume source prioritized over higher growth source."
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 100,
    grader_hints: "Multi-platform conflict with divergent volume: agent must choose a canonical source and explain conflict resolution."
  },
  {
    input: {
      raw_entry: {
        trend_name: "#revenge",
        posts: "33.6B",
        growth: "+106%",
        region: "UK"
      },
      source_url: "https://instagram.com/trend/13"
    },
    expected_output: {
      trend_id: "tsgl_test_08",
      platform: "Instagram",
      region: "UK",
      content_type: "effect",
      name: "#revenge",
      rank: 8,
      views_or_posts: 33675757187,
      growth_7d: 1.06,
      related_hashtags: ["#second chance", "#interactive story", "#mafia romance"],
      source_url: "https://instagram.com/trend/13",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 100,
    grader_hints: "Baseline correctness with region UK and content_type effect from known seed context."
  },
  {
    input: {
      raw_entry: {
        board: "Mafia Romance Aesthetic",
        monthly_views: "45.4B",
        weekly_growth: "+169%",
        top_pins: ["dark mafia quotes", "mafia boss outfits", "enemies to lovers art"]
      },
      source_url: "https://pinterest.com/trend/20"
    },
    expected_output: {
      trend_id: "tsgl_test_09",
      platform: "Pinterest",
      region: "BR",
      content_type: "effect",
      name: "#mafia romance",
      rank: 9,
      views_or_posts: 45416623921,
      growth_7d: 1.69,
      related_hashtags: ["#strong female lead", "#short drama", "#contract marriage"],
      source_url: "https://pinterest.com/trend/20",
      crawl_time: "2026-04-13T02:40:00Z"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 10, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 10, "Trend Grading & Forecasting": 10, "Report Output Specification": 10, "Exception Handling & Source Verification": 10 },
    score: 100,
    grader_hints: "Pinterest board data without explicit hashtag formatting requires agent to generate canonical hashtag from board title."
  },
  {
    input: {
      raw_entry: {
        url: "https://unknown-aggregator.com/trend/xyz",
        title: "Second Chance Romance Going Viral",
        engagement: "high",
        region: "AU"
      }
    },
    expected_output: {
      trend_id: "tsgl_test_10",
      platform: "UNKNOWN",
      region: "AU",
      content_type: "hashtag",
      name: "#second chance",
      rank: 10,
      views_or_posts: 0,
      growth_7d: 0.00,
      related_hashtags: [],
      source_url: "https://unknown-aggregator.com/trend/xyz",
      crawl_time: "2026-04-13T02:40:00Z",
      confidence: "low"
    },
    dimensions: { "Cross-Platform Information Source Understanding": 8, "Trend Recognition & Theme Extraction": 10, "Data Cleaning & Structuring": 9, "Trend Grading & Forecasting": 7, "Report Output Specification": 10, "Exception Handling & Source Verification": 9 },
    score: 89,
    grader_hints: "Unrecognized aggregator with vague engagement ('high' instead of numbers). Platform should be UNKNOWN or best-effort, confidence low, metrics defaulted to zero rather than hallucinated."
  }
];

writeJSONL(path.join(outDir, 'train.jsonl'), train);
writeJSONL(path.join(outDir, 'test.jsonl'), test);
console.log(`Wrote ${train.length} train records and ${test.length} test records.`);