about summary refs log tree commit diff stats
path: root/data/maps
Commit message (Expand)AuthorAgeFilesLines
* [Data] Fixed some stuff for worldport shuffleStar Rauchenberger2025-09-227-9/+9
* [Data] Annotate shuffleable portsStar Rauchenberger2025-09-21144-141/+420
* [Data] Logic error with Wrath RoomStar Rauchenberger2025-09-191-0/+6
* [Data] Rename SMILE locationsStar Rauchenberger2025-09-191-0/+5
* [Data] Renamed some doors with compass directionsStar Rauchenberger2025-09-198-46/+46
* [Data] Roof -> Orchestra RoomStar Rauchenberger2025-09-191-0/+6
* Added strict purple/cyan ending optionsStar Rauchenberger2025-09-192-0/+2
* [Data] Rename TURN check near Shop EntranceStar Rauchenberger2025-09-161-1/+1
* [Data] Daedalus - C Keyholder should be in East AreaStar Rauchenberger2025-09-161-1/+1
* [Data] the_ancient:THIS was missing a symbolStar Rauchenberger2025-09-151-0/+1
* [Data] Added the hidden EYE panel in the anti collectable roomStar Rauchenberger2025-09-132-5/+9
* Add anti-collectable locationStar Rauchenberger2025-09-132-1/+6
* [Data] Fixed Control Center Red Door receiverStar Rauchenberger2025-09-121-1/+1
* [Data] Made Welcome Back middle door in daed vanillaStar Rauchenberger2025-09-121-2/+2
* Added gallery painting shuffleStar Rauchenberger2025-09-121-17/+17
* [Client] Fixed The Great - Colorful EntranceStar Rauchenberger2025-09-121-1/+0
* [Data] Added missing connection in Outside HouseStar Rauchenberger2025-09-121-0/+5
* [Data] Added Theo Panels checkStar Rauchenberger2025-09-121-0/+10
* [Data] Hotel checkered door fixesStar Rauchenberger2025-09-111-40/+7
* [Data] Renamed Sticks and Stones locationStar Rauchenberger2025-09-111-0/+1
* [Data] Added Lime Hexes locationStar Rauchenberger2025-09-111-0/+11
* [Data] Allow WALL solution to the_entry!OPENStar Rauchenberger2025-09-111-1/+3
* [Data] Fixed connection target required door logic bugsStar Rauchenberger2025-09-1114-37/+69
* [Data] Fixed darkroom/colorful connectionStar Rauchenberger2025-09-113-6/+12
* [Data] Fixed Purple NE Vestibules location nameStar Rauchenberger2025-09-111-1/+0
* [Data] Daed roof access to F KeyholderStar Rauchenberger2025-09-111-0/+6
* Added symbol shuffleStar Rauchenberger2025-09-093-1/+9
* Made sure the apworld unit tests passStar Rauchenberger2025-09-081-1/+1
* [Data] Tweak owl logicStar Rauchenberger2025-09-082-10/+35
* Added lavender cubes logicStar Rauchenberger2025-09-086-9/+26
* [Data] the_great/BYE is behind a "cyan door"Star Rauchenberger2025-09-082-0/+7
* Add cyan door behavior optionStar Rauchenberger2025-09-086-4/+17
* Added door groupsStar Rauchenberger2025-09-075-8/+4
* [Data] Renamed some locationsStar Rauchenberger2025-09-075-0/+7
* [Data] Replaced Symbolic Entrance with single doorStar Rauchenberger2025-09-051-25/+18
* Added option for Daedalus roof access logicStar Rauchenberger2025-09-032-0/+316
* Added keyholder sanityStar Rauchenberger2025-09-0223-0/+26
* [Data] Question Room What proxies were mislabeledStar Rauchenberger2025-09-011-5/+5
* [Data] Fixed Rainbow Rooms logicStar Rauchenberger2025-09-011-18/+19
* [Data] Some more double letters fixesStar Rauchenberger2025-09-014-1/+9
* [Data] Couple of renamesStar Rauchenberger2025-08-313-2/+3
* Handled cyan doorsStar Rauchenberger2025-08-318-16/+16
* [Data] Small tweaksStar Rauchenberger2025-08-317-22/+30
* [Data] Small tweaksStar Rauchenberger2025-08-306-2/+11
* [Data] Bad logic in the_owl due to missing warpStar Rauchenberger2025-08-305-22/+23
* Changed how door location names are formattedStar Rauchenberger2025-08-30480-472/+380
* [Data] Made proxies with the same answer as the panel explicitStar Rauchenberger2025-08-3021-36/+42
* [Data] Added logic for Tenacious Color PaintingStar Rauchenberger2025-08-302-1/+9
* [Data] S1 Door is not a location anymoreStar Rauchenberger2025-08-291-3/+1
* [Data] Fix castle stairs (again)Star Rauchenberger2025-08-291-2/+2
href='#n335'>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
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756


































































































































































































































































































































































































                                                                                                            
                                    

                                                            



                                                      



                                    
                                 
                                                              
                                                   









                                                                  
                                                                          

                                           
                                                                        

                                               
                                                                                 











































































































































































































                                                                                                               
                                                                 














































































































                                                                                                                         
                                                                               




















                                              
#include "sentence.h"
#include <algorithm>
#include <list>
#include <set>

sentence::sentence(
  const verbly::database& database,
  std::mt19937& rng) :
    database_(database),
    rng_(rng)
{
}

std::string sentence::generate() const
{
  // Generate the form that the title should take.
  verbly::token form;
  std::set<std::string> synrestrs {"infinitive_phrase", "bare", "subjectless"};
  std::set<std::string> secondSyn {"participle_phrase", "subjectless"};
  std::set<std::string> adjSyn {"adjective_phrase"};

  if (std::bernoulli_distribution(1.0/6.0)(rng_))
  {
    form << "not";
  }

  if (std::bernoulli_distribution(1.0/6.0)(rng_))
  {
    form << "be";
    form << adjSyn;
  } else {
    if (std::bernoulli_distribution(1.0/6.0)(rng_))
    {
      form << "get";
      synrestrs.insert("experiencer");
      synrestrs.insert("past_participle");
    }

    form << synrestrs;
  }

  if (std::bernoulli_distribution(1.0/5.0)(rng_))
  {
    if (std::bernoulli_distribution(1.0/4.0)(rng_))
    {
      form << "without";
    } else {
      form << "while";
    }

    form << secondSyn;
  }

  // Attempt to compile the form, restarting if a bad word is generated.
  std::set<std::string> badWords = {"raped"};

  verbly::token tok = form;
  std::list<std::string> words;
  for (;;)
  {
    // Compile the form.
    while (!tok.isComplete())
    {
      visit(tok);
    }

    std::string compiled = tok.compile();
    words = verbly::split<std::list<std::string>>(compiled, " ");

    // Ensure that there are no bad words in the output.
    if (!std::any_of(std::begin(words), std::end(words), [&badWords] (const std::string& word) {
      std::string canonWord;

      for (char ch : word)
      {
        if (std::isalpha(ch))
        {
          canonWord.push_back(std::tolower(ch));
        }
      }

      return (badWords.count(canonWord) == 1);
    })) {
      break;
    } else {
      std::cout << "Bad word generated." << std::endl;
    }
  }

  // Put the form into title case.
  for (std::string& word : words)
  {
    if ((word[0] == '"') && (word.length() > 1))
    {
      word[1] = std::toupper(word[1]);
    } else {
      word[0] = std::toupper(word[0]);
    }
  }

  return verbly::implode(std::begin(words), std::end(words), " ");
}

verbly::filter sentence::parseSelrestrs(
  verbly::selrestr selrestr) const
{
  switch (selrestr.getType())
  {
    case verbly::selrestr::type::empty:
    {
      return {};
    }

    case verbly::selrestr::type::singleton:
    {
      verbly::filter result;

      if (selrestr.getRestriction() == "concrete")
      {
        result = (verbly::notion::wnid == 100001930); // physical entity
      } else if (selrestr.getRestriction() == "time")
      {
        result = (verbly::notion::wnid == 100028270); // time
      } else if (selrestr.getRestriction() == "state")
      {
        result = (verbly::notion::wnid == 100024720); // state
      } else if (selrestr.getRestriction() == "abstract")
      {
        result = (verbly::notion::wnid == 100002137); // abstract entity
      } else if (selrestr.getRestriction() == "scalar")
      {
        result = (verbly::notion::wnid == 103835412); // number
      } else if (selrestr.getRestriction() == "currency")
      {
        result = (verbly::notion::wnid == 105050379); // currency
      } else if (selrestr.getRestriction() == "location")
      {
        result = (verbly::notion::wnid == 100027167); // location
      } else if (selrestr.getRestriction() == "organization")
      {
        result = (verbly::notion::wnid == 100237078); // organization
      } else if (selrestr.getRestriction() == "int_control")
      {
        result = (verbly::notion::wnid == 100007347); // causal agent
      } else if (selrestr.getRestriction() == "natural")
      {
        result = (verbly::notion::wnid == 100019128); // natural object
      } else if (selrestr.getRestriction() == "phys_obj")
      {
        result = (verbly::notion::wnid == 100002684); // physical object
      } else if (selrestr.getRestriction() == "solid")
      {
        result = (verbly::notion::wnid == 113860793); // solid
      } else if (selrestr.getRestriction() == "shape")
      {
        result = (verbly::notion::wnid == 100027807); // shape
      } else if (selrestr.getRestriction() == "substance")
      {
        result = (verbly::notion::wnid == 100019613); // substance
      } else if (selrestr.getRestriction() == "idea")
      {
        result = (verbly::notion::wnid == 105803379); // idea
      } else if (selrestr.getRestriction() == "sound")
      {
        result = (verbly::notion::wnid == 107111047); // sound
      } else if (selrestr.getRestriction() == "communication")
      {
        result = (verbly::notion::wnid == 100033020); // communication
      } else if (selrestr.getRestriction() == "region")
      {
        result = (verbly::notion::wnid == 105221895); // region
      } else if (selrestr.getRestriction() == "place")
      {
        result = (verbly::notion::wnid == 100586262); // place
      } else if (selrestr.getRestriction() == "machine")
      {
        result = (verbly::notion::wnid == 102958343); // machine
      } else if (selrestr.getRestriction() == "animate")
      {
        result = (verbly::notion::wnid == 100004258); // animate thing
      } else if (selrestr.getRestriction() == "plant")
      {
        result = (verbly::notion::wnid == 103956922); // plant
      } else if (selrestr.getRestriction() == "comestible")
      {
        result = (verbly::notion::wnid == 100021265); // food
      } else if (selrestr.getRestriction() == "artifact")
      {
        result = (verbly::notion::wnid == 100021939); // artifact
      } else if (selrestr.getRestriction() == "vehicle")
      {
        result = (verbly::notion::wnid == 104524313); // vehicle
      } else if (selrestr.getRestriction() == "human")
      {
        result = (verbly::notion::wnid == 100007846); // person
      } else if (selrestr.getRestriction() == "animal")
      {
        result = (verbly::notion::wnid == 100015388); // animal
      } else if (selrestr.getRestriction() == "body_part")
      {
        result = (verbly::notion::wnid == 105220461); // body part
      } else if (selrestr.getRestriction() == "garment")
      {
        result = (verbly::notion::wnid == 103051540); // clothing
      } else if (selrestr.getRestriction() == "tool")
      {
        result = (verbly::notion::wnid == 104451818); // tool
      } else {
        return {};
      }

      std::cout << selrestr.getRestriction() << " (" << selrestr.getPos() << ")" << std::endl;

      if (selrestr.getPos())
      {
        return (verbly::notion::fullHypernyms %= result);
      } else {
        return !(verbly::notion::fullHypernyms %= result);
      }
    }

    case verbly::selrestr::type::group:
    {
      std::cout << "or: " << selrestr.getOrlogic() << std::endl;
      verbly::filter ret(selrestr.getOrlogic());

      for (const verbly::selrestr& child : selrestr)
      {
        ret += parseSelrestrs(child);
      }

      return ret;
    }
  }
}

bool sentence::requiresSelrestr(
  std::string restriction,
  verbly::selrestr selrestr) const
{
  switch (selrestr.getType())
  {
    case verbly::selrestr::type::empty:
    {
      return false;
    }

    case verbly::selrestr::type::singleton:
    {
      if (selrestr.getRestriction() == restriction)
      {
        return selrestr.getPos();
      } else {
        return false;
      }
    }

    case verbly::selrestr::type::group:
    {
      if (selrestr.getOrlogic())
      {
        return std::all_of(std::begin(selrestr), std::end(selrestr), [=] (const verbly::selrestr& s) {
          return requiresSelrestr(restriction, s);
        });
      } else {
        return std::any_of(std::begin(selrestr), std::end(selrestr), [=] (const verbly::selrestr& s) {
          return requiresSelrestr(restriction, s);
        });
      }
    }
  }
}

verbly::word sentence::generateStandardNoun(
  std::string role,
  verbly::selrestr selrestrs) const
{
  std::geometric_distribution<int> tagdist(0.5); // 0.06
  std::vector<verbly::word> result;
  bool trySelection = true;

  while (result.empty())
  {
    verbly::filter condition =
      (verbly::notion::partOfSpeech == verbly::part_of_speech::noun)
      && (verbly::form::proper == false)
      //&& (verbly::form::complexity == 1)
     // && (verbly::word::tagCount >= tagdist(rng_)) // Favor more common words
      && (verbly::word::tagCount >= 1)
      && !(verbly::word::usageDomains %= (verbly::notion::wnid == 106718862)); // Blacklist ethnic slurs

    // Only use selection restrictions for a first attempt.
    if (trySelection)
    {
      verbly::filter selrestrCondition = parseSelrestrs(selrestrs).compact();

      if (selrestrCondition.getType() != verbly::filter::type::empty)
      {
        condition &= std::move(selrestrCondition);
      } else if (role == "Attribute")
      {
        condition &= (verbly::notion::fullHypernyms %= (verbly::notion::wnid == 100024264)); // attribute
      } else if (role == "Instrument")
      {
        condition &= (verbly::notion::fullHypernyms %= (verbly::notion::wnid == 104451818)); // tool
      } else if (role == "Agent")
      {
        condition &= (verbly::notion::fullHypernyms %= (verbly::notion::wnid == 100007347)); // causal agent
      }

      trySelection = false;
    } else {
      std::cout << "Selection failed" << std::endl;
    }

    result = database_.words(condition).all();
  }

  return result.front();
}

verbly::token sentence::generateStandardNounPhrase(
  const verbly::word& noun,
  std::string role,
  bool plural,
  bool definite) const
{
  verbly::token utter;
  verbly::word sounder = noun;
  verbly::word descript;

  if (std::bernoulli_distribution(1.0/8.0)(rng_))
  {
    std::geometric_distribution<int> tagdist(0.2);
    descript = database_.words(
      (verbly::word::tagCount >= tagdist(rng_))
      && (verbly::notion::partOfSpeech == verbly::part_of_speech::adjective)).first();

    sounder = descript;
  }

  if ((std::bernoulli_distribution(1.0/3.0)(rng_)) && (definite))
  {
    utter << "the";

    if (std::bernoulli_distribution(1.0/2.0)(rng_))
    {
      plural = true;
    }
  } else {
    if ((role != "Theme") && (role != "Attribute") && std::bernoulli_distribution(1.0/2.0)(rng_))
    {
      utter << "your";
    } else if (!plural) {
      if (sounder.getLemma().getBaseForm().startsWithVowelSound())
      {
        utter << "an";
      } else {
        utter << "a";
      }
    }
  }

  if (descript)
  {
    utter << descript;
  }

  if (plural && noun.getLemma().hasInflection(verbly::inflection::plural))
  {
    utter << verbly::token(noun, verbly::inflection::plural);
  } else {
    utter << noun;
  }

  return utter;
}

verbly::token sentence::generateClause(
  const verbly::token& it) const
{
  verbly::token utter;
  std::geometric_distribution<int> tagdist(0.07);
  std::vector<verbly::word> verbDataset;

  verbly::filter frameCondition =
    (verbly::frame::length >= 2)
    && (verbly::frame::parts(0) %= (
      (verbly::part::type == verbly::part_type::noun_phrase)
      && (verbly::part::role == "Agent"))
    && (verbly::frame::parts(1) %=
      (verbly::part::type == verbly::part_type::verb))
    && !(verbly::frame::parts() %= (
      verbly::part::synrestrs %= "adjp")));

  if (it.hasSynrestr("experiencer"))
  {
    frameCondition &=
      (verbly::frame::parts(2) %=
        (verbly::part::type == verbly::part_type::noun_phrase)
        && !(verbly::part::synrestrs %= "genitive")
        && ((verbly::part::role == "Patient")
          || (verbly::part::role == "Experiencer")));
  }

  verbly::filter verbCondition =
    (verbly::notion::partOfSpeech == verbly::part_of_speech::verb)
    && frameCondition;

  if (it.hasSynrestr("participle_phrase"))
  {
    verbCondition &= (verbly::lemma::forms(verbly::inflection::ing_form));
  } else if (it.hasSynrestr("progressive"))
  {
    verbCondition &= (verbly::lemma::forms(verbly::inflection::s_form));
  } else if (it.hasSynrestr("past_participle"))
  {
    verbCondition &= (verbly::lemma::forms(verbly::inflection::past_participle));
  }

  // Because of the tag distribution, it's possible (albeit extremely unlikely)
  // for the verb query to fail, so we loop until it succeeds.
  while (verbDataset.empty())
  {
    verbDataset = database_.words(
      verbCondition
      && (verbly::word::tagCount >= tagdist(rng_))
    ).all();
  }

  verbly::word verb = verbDataset.front();
  verbly::frame frame = database_.frames(frameCondition && verb).first();
  std::list<verbly::part> parts(std::begin(frame.getParts()), std::end(frame.getParts()));

  if (it.hasSynrestr("experiencer"))
  {
    // Ignore the direct object.
    parts.erase(std::next(parts.begin(), 2));
  }

  if (it.hasSynrestr("subjectless"))
  {
    // Ignore the subject.
    parts.pop_front();
  }

  for (const verbly::part& part : parts)
  {
    switch (part.getType())
    {
      case verbly::part_type::noun_phrase:
      {
        std::cout << "NP: ";
        for (auto& s : part.getNounSynrestrs())
        {
          std::cout << s << " ";
        }
        std::cout << std::endl;

        if (requiresSelrestr("currency", part.getNounSelrestrs()))
        {
          int lead = std::uniform_int_distribution<int>(1,9)(rng_);
          int tail = std::uniform_int_distribution<int>(0,6)(rng_);
          std::string tailStr(tail, '0');

          utter << ("$" + std::to_string(lead) + tailStr);
        } else if (part.nounHasSynrestr("adjp"))
        {
          utter << std::set<std::string>({"adjective_phrase"});
        } else if ((part.nounHasSynrestr("be_sc_ing"))
          || (part.nounHasSynrestr("ac_ing"))
          || (part.nounHasSynrestr("sc_ing"))
          || (part.nounHasSynrestr("np_omit_ing"))
          || (part.nounHasSynrestr("oc_ing")))
        {
          utter << std::set<std::string>({"participle_phrase", "subjectless"});
        } else if ((part.nounHasSynrestr("poss_ing"))
          || (part.nounHasSynrestr("possing"))
          || (part.nounHasSynrestr("pos_ing")))
        {
          utter << "your";
          utter << std::set<std::string>({"participle_phrase", "subjectless"});
        } else if (part.nounHasSynrestr("genitive"))
        {
          utter << "your";
        } else if (part.nounHasSynrestr("adv_loc"))
        {
          if (std::bernoulli_distribution(1.0/2.0)(rng_))
          {
            utter << "here";
          } else {
            utter << "there";
          }
        } else if (part.nounHasSynrestr("refl"))
        {
          utter << "yourself";
        } else if ((part.nounHasSynrestr("sc_to_inf"))
          || (part.nounHasSynrestr("ac_to_inf"))
          || (part.nounHasSynrestr("vc_to_inf"))
          || (part.nounHasSynrestr("rs_to_inf"))
          || (part.nounHasSynrestr("oc_to_inf")))
        {
          utter << std::set<std::string>({"infinitive_phrase", "subjectless"});
        } else if (part.nounHasSynrestr("oc_bare_inf"))
        {
          utter << std::set<std::string>({"infinitive_phrase", "bare", "subjectless"});
        } else if (part.nounHasSynrestr("wh_comp"))
        {
          utter << "whether";

          verbly::token sentence(std::set<std::string>({"progressive"}));
          utter << generateClause(sentence);
        } else if (part.nounHasSynrestr("that_comp"))
        {
          utter << "that";
          utter << "they";

          verbly::token sentence(std::set<std::string>({"subjectless"}));
          utter << generateClause(sentence);
        } else if (part.nounHasSynrestr("what_extract"))
        {
          utter << "what";

          verbly::token sentence(std::set<std::string>({"progressive", "experiencer"}));
          utter << generateClause(sentence);
        } else if (part.nounHasSynrestr("how_extract"))
        {
          utter << "how";

          verbly::token sentence(std::set<std::string>({"progressive"}));
          utter << generateClause(sentence);
        } else if (part.nounHasSynrestr("wh_inf"))
        {
          utter << "how";

          verbly::token sentence(std::set<std::string>({"infinitive_phrase", "subjectless"}));
          utter << generateClause(sentence);
        } else if (part.nounHasSynrestr("what_inf"))
        {
          utter << "what";

          verbly::token sentence(std::set<std::string>({"infinitive_phrase", "subjectless", "experiencer"}));
          utter << generateClause(sentence);
        } else if (part.nounHasSynrestr("wheth_inf"))
        {
          utter << "whether";

          verbly::token sentence(std::set<std::string>({"infinitive_phrase", "subjectless"}));
          utter << generateClause(sentence);
        } else if (part.nounHasSynrestr("quotation"))
        {
          verbly::token sentence(std::set<std::string>({"participle_phrase"}));
          while (!sentence.isComplete())
          {
            visit(sentence);
          }

          utter << ("\"" + sentence.compile() + "\"");
        } else {
          verbly::word noun = generateStandardNoun(part.getNounRole(), part.getNounSelrestrs());

          bool plural = part.nounHasSynrestr("plural");
          if (!plural)
          {
            plural = requiresSelrestr("plural", part.getNounSelrestrs());
          }

          utter << generateStandardNounPhrase(
            noun,
            part.getNounRole(),
            plural,
            part.nounHasSynrestr("definite"));

          if (part.nounHasSynrestr("acc_ing") || part.nounHasSynrestr("ac_ing"))
          {
            utter << std::set<std::string>({"participle_phrase", "subjectless"});
          }
        }

        break;
      }

      case verbly::part_type::verb:
      {
        std::cout << "V: " << verb.getBaseForm() << std::endl;

        if (it.hasSynrestr("progressive"))
        {
          utter << verbly::token(verb, verbly::inflection::s_form);
        } else if (it.hasSynrestr("past_participle"))
        {
          utter << verbly::token(verb, verbly::inflection::past_participle);
        } else if (it.hasSynrestr("infinitive_phrase"))
        {
          if (!it.hasSynrestr("bare"))
          {
            utter << "to";
          }

          utter << verb;
        } else if (it.hasSynrestr("participle_phrase"))
        {
          utter << verbly::token(verb, verbly::inflection::ing_form);
        } else {
          utter << verb;
        }

        break;
      }

      case verbly::part_type::preposition:
      {
        std::cout << "PREP" << std::endl;

        if (part.isPrepositionLiteral())
        {
          int choiceIndex = std::uniform_int_distribution<int>(0, part.getPrepositionChoices().size()-1)(rng_);
          utter << part.getPrepositionChoices()[choiceIndex];
        } else {
          verbly::filter pgf(true);
          for (const std::string& choice : part.getPrepositionChoices())
          {
            pgf += (verbly::notion::prepositionGroups == choice);
          }

          utter << database_.words(pgf && (verbly::notion::partOfSpeech == verbly::part_of_speech::preposition)).first();
        }

        break;
      }

      case verbly::part_type::adjective:
      {
        std::cout << "ADJ" << std::endl;

        utter << std::set<std::string>({"adjective_phrase"});

        break;
      }

      case verbly::part_type::adverb:
      {
        std::cout << "ADV" << std::endl;

        utter << std::set<std::string>({"adverb_phrase"});

        break;
      }

      case verbly::part_type::literal:
      {
        std::cout << "LIT" << std::endl;

        utter << part.getLiteralValue();

        break;
      }

      case verbly::part_type::invalid:
      {
        // Nope

        break;
      }
    }
  }

  if ((parts.size() == 1) && (std::bernoulli_distribution(1.0/4.0)(rng_)))
  {
    utter << std::set<std::string>({"adverb_phrase"});
  }

  return utter;
}

void sentence::visit(verbly::token& it) const
{
  switch (it.getType())
  {
    case verbly::token::type::utterance:
    {
      for (verbly::token& token : it)
      {
        if (!token.isComplete())
        {
          visit(token);

          break;
        }
      }

      break;
    }

    case verbly::token::type::fillin:
    {
      if (it.hasSynrestr("infinitive_phrase"))
      {
        it = generateClause(it);
      } else if (it.hasSynrestr("adjective_phrase"))
      {
        verbly::token phrase;

        if (std::bernoulli_distribution(1.0/6.0)(rng_))
        {
          phrase << std::set<std::string>({"adverb_phrase"});
        }

        if (std::bernoulli_distribution(1.0/4.0)(rng_))
        {
          phrase << std::set<std::string>({"participle_phrase", "subjectless"});
        } else {
          std::geometric_distribution<int> tagdist(0.2);
          phrase << database_.words(
            (verbly::word::tagCount >= tagdist(rng_))
            && (verbly::notion::partOfSpeech == verbly::part_of_speech::adjective)).first();
        }

        it = phrase;
      } else if (it.hasSynrestr("adverb_phrase"))
      {
        std::geometric_distribution<int> tagdist(1.0/23.0);

        it = database_.words(
          (verbly::notion::partOfSpeech == verbly::part_of_speech::adverb)
          && (verbly::word::tagCount >= tagdist(rng_))
          ).first();
      } else if (it.hasSynrestr("participle_phrase"))
      {
        if (std::bernoulli_distribution(1.0/2.0)(rng_))
        {
          it = verbly::token(
            database_.words(
              (verbly::notion::partOfSpeech == verbly::part_of_speech::verb)
              && (verbly::lemma::forms(verbly::inflection::ing_form))).first(),
            verbly::inflection::ing_form);
        } else {
          it = generateClause(it);
        }
      } else {
        it = "*the reality of the situation*";
      }

      break;
    }

    case verbly::token::type::word:
    case verbly::token::type::literal:
    case verbly::token::type::part:
    {
      // Nope

      break;
    }
  }
}