genbooks

package
v0.0.0-...-127c1ca Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package genbooks is an example application of genstory for generating book titles.

Index

Constants

View Source
const (
	// This will write down a randomly-selected form of knowledge the adventurer
	// is aware of, to be learned by future readers. Most commonly this will be
	// musical, poetic, and dance forms the adventurer knows or composed.
	// This can also include scientific research the adventurer has learned,
	// and necromancer adventurers can spread the secrets of life and death by
	// writing manuals about them.
	BookTypeManual = iota
	// General writing about a specific site, generally described as "concerning"
	// that town, dark pit, etc. without going into detail.
	BookTypeGuide
	// In-depth writing about a particular site, group, or civilization. This will
	// be presented as multiple chapters, each chapter relating to a historical
	// event related to the writing's subject. It teaches histfigs about the group.
	BookTypeChronicle
	// Generic prose, typically described as having no particular subject.
	BookTypeShortStory
	// Generic prose, typically described as having no particular subject.
	BookTypeNovel
	// Teaches about a person and several events happening to that person, each of
	// which is represented as a separate chapter.
	//
	// Requires Historian's biography topic.
	BookTypeBiography
	// Teaches about the author and several events happening to the author, each of
	// which is represented as a separate chapter.
	//
	// Requires Historian's autobiography topic.
	BookTypeAutobiography
	// Writes a new poem, like the Musical Composition writes a musical composition
	//
	// Requires knowing any poetry forms.
	BookTypePoem
	// Generic prose, typically described as having no particular subject
	BookTypePlay
	// Generic prose, typically described as having no particular subject. These
	// often have no title.
	BookTypeLetter
	// Might be writing about events, people, places or values.
	BookTypeEssay
	// Concerns and teaches a value
	//
	// Requires the Philosopher's dialectic reasoning topic.
	BookTypeDialog
	// Writes new songs. This functions similarly to composing new songs, with the
	// added benefit of writing it down for others to learn. However, unlike normal
	// composition, you do not get to select which musical form to base the song on.
	//
	// Requires knowing any musical forms.
	BookTypeMusicalComposition
	// Writes a new dance, like the Musical Composition.
	//
	// Requires knowing any dance forms.
	BookTypeChoreography
	// Concerns (and teaches about) two historical figures, may emphasize a value too.
	//
	// Requires Historian's comparative biography topic.
	BookTypeComparativeBiography
	// Concerns a list of historical figures
	//
	// Requires Historian's biographic dictionary topic.
	BookTypeBiographicDictionary
	// Concerns the lineage of a specific historical figure. Does not mention anyone
	// besides the main figure.
	//
	// Requires Historian's genealogy topic.
	BookTypeGenealogy
	// Teaches about several notable historical objects in a world, so artifacts,
	// sites, people.
	//
	// Requires Historian's encyclopedia topic.
	BookTypeEncyclopedia
	// Teaches about a culture, and several events happening to that entity.
	//
	// Requires Historian's cultural history topic.
	BookTypeCulturalHistory
	// Teaches about two cultures/groups and may emphasize a value too
	//
	// Requires Historian's cultural comparison topic.
	BookTypeCulturalComparison
	// Teaches an event. Description suggests the work in question is an exploration
	// of what would have happened had this event not played out as it did.
	// May emphasize a value.
	//
	// Requires Historian's alternate history topic.
	BookTypeAlternateHistory
	// Concerns the history of an engineering topic, teaches the topic in question.
	//
	// Requires Historian's treatise on technological advancement topic.
	BookTypeTreatiseOnTechnologicalAdvancement
	// Concerns and teaches about a language.
	//
	// Requires Philosopher's dictionary topic.
	BookTypeDictionary
	// Nothing at the moment, but can be a 'good resource of information' or
	// 'badly compiled'.
	//
	// Requires Astronomer's star chart topic.
	BookTypeStarChart
	// Nothing at the moment, but can be a 'good resource of information' or
	// 'badly compiled'.
	//
	// Requires one of the Astronomer's star catalogue topics.
	BookTypeStarCatalogue
	// This is regarding, and teaches about, a region.
	//
	// Requires Geographer's atlas topic.
	BookTypeAtlas
	// This is a holy book, and teaches about a religion.
	//
	// Requires Cleric's theology topic.
	BookTypeTheology
	// This is a sacred text, and teaches about a religion.
	//
	// Requires Cleric's scripture topic.
	BookTypeScripture
	// This is a legal text, and describes a legal system.
	//
	// Requires Clerks's law topic.
	BookTypeLaw
)

NOTE: These categories are based on https://dwarffortresswiki.org/index.php/DF2014:Book

View Source
const (
	// Examples: The Tower, The Tree, Bronzemurdered, Likot Ubendeb, Animal Behaviours
	// Notably, these may or may not be plural and/or have an article. Name is directly related to the content of the book.
	TokenName = "[NAME]"
	// Examples: Tower, Tree, Bronzemurdered, Likot Ubendeb, Animal Behaviours
	// Notice that the inserted text may still be plural - limiting its usage. These likewise are related to the content of the book.
	// Examples: Despair, Roots, Scrolls, Wheel-and-axels
	TokenNoArtName = "[NO_ART_NAME]"
	// Examples: Despair, Roots, Scrolls, Wheel-and-axels
	// Again, may or may not be plural. These seem to have very little correlation to the book's topic. If it has any relationship to the content of the book, it could be words within the author's entity's vocabulary.
	TokenNoun = "[NOUN]"
	// Also seem to have little correlation to the book's topic. They are currently guessed to be from the civ, if not purely random.
	// Examples: Boyish, Inky, Angry, Bronzed
	TokenAdj = "[ADJ]"
	// Examples: The Age Of Legends, The Age Of Hill Titan and Dragon
	// These are pulled from the world's history, not from all possibilities.
	TokenAnyAge = "[ANY_AGE]"
	// Examples: He, She, We, They
	// It is believed it only generates subject pronouns (not "Us" or "Them"). Past tense makes this easy to use.
	TokenAnyPronoun = "[ANY_PRONOUN]"
	// Examples: His, Her, Our, Their
	TokenAnyPossessivePronoun = "[POSS_PRONOUN]"
	// Examples: The Fool Laughs, The Day Can Say It In The End, It Foretells Afterwards, The Day Mourns
	// Due to the wide variety, this is pretty hard to use.
	TokenPhrase = "[PHRASE]"
	// Examples: Riverwood, Paris, Eridu, The Great Library
	// Place names are pulled from the world's history, not from all possibilities.
	TokenPlace = "[PLACE]"
	// Examples: Exploring, discussing, understanding, learning, discovering,
	TokenVerb = "[VERB]"
	// Examples: Death, life, fire, fate...
	TokenGenitiveNoun = "[GENITIVE_NOUN]"
	// Examples: children, adults, toddlers, elders, babies, teenagers, youths, infants, adolescents, juve
	TokenReaderAge = "[READER_AGE]"
)

Variables

View Source
var BookArtTitles = []string{
	"[NAME]",
	"[PHRASE]",
	"[ADJ] [NO_ART_NAME]",
	"The [ADJ] [NO_ART_NAME]",
	"[NAME] [ADJ]",
	"[NAME] and the [NOUN]",
	"[NAME] and the [ADJ] [NOUN]",
	"The [NOUN] and [NAME]",
	"The [ADJ] [NOUN] and [NAME]",
	"[NAME]: [PHRASE]",
	"It Must Have Been [NAME]",
	"My Friend [NAME]",
	"The Birth of [NAME]",
	"The Sun Sets on [NAME]",
	"We See [NAME]",
	"[NAME] Ever Onward",
	"[NAME] and Nothing More",
	"And [ANY_PRONOUN] Sang '[NAME]!'",
}

NOTE: This is based on "book_art.txt" from Dwarf Fortress.

View Source
var BookInstructionTitles = []string{}/* 155 elements not displayed */

NOTE: This is based on "book_instruction.txt" from Dwarf Fortress.

View Source
var BookTitleAge = []string{
	"the age of steam",
	"the age of the forgotten",
	"the age of the gods",
	"the age of the machine",
}
View Source
var BookTitleHandbookSubtitles = []string{
	"the ultimate guide",
	"the complete guide",
	"the definitive guide",
	"the ultimate handbook",
	"the complete handbook",
	"the definitive handbook",
	"the ultimate reference",
	"the complete reference",
	"the definitive reference",
	"the ultimate manual",
	"the complete manual",
	"the definitive manual",
	"the ultimate book",
	"the complete book",
	"the definitive book",
}
View Source
var BookTitleNouns = []string{
	"death",
	"life",
	"fire",
	"fate",
	"love",
	"hope",
	"despair",
	"roots",
	"scrolls",
	"wheel-and-axels",
	"nuts-and-bolts",
}
View Source
var BookTitlePhrases = []string{
	"the fool laughs",
	"the day can say it in the end",
	"it smells afterwards",
	"the day mourns",
	"all and none",
	"the day is born",
	"been there, done that",
	"funny enough for a tragedy",
}
View Source
var BookTitlePlaces = []string{
	"cities",
	"villages",
	"towns",
	"hamlets",
	"city-states",
	"kingdoms",
	"empires",
	"nations",
	"countrys",
	"continents",
	"worlds",
	"universes",
	"pits",
}
View Source
var BookTitlePossessivePronouns = []string{
	"his",
	"her",
	"its",
	"their",
}
View Source
var BookTitlePronouns = []string{
	"he",
	"she",
	"it",
	"they",
}
View Source
var BookTitleReaderAge = []string{
	"children",
	"adults",
	"beginners",
	"experts",
	"everyone",
	"kids",
	"teens",
	"toddlers",
	"elders",
	"babies",
	"teenagers",
	"youths",
	"infants",
	"adolescents",
	"juveniles",
	"youngsters",
}
View Source
var BookTitleVerbs = []string{
	"exploring",
	"discussing",
	"understanding",
	"learning",
	"discovering",
	"searching",
	"seeking",
	"finding",
	"creating",
}
View Source
var BookVariantTitles = []string{
	"[NAME]",
	"[NAME]: [PHRASE]",
	"[NAME] and [NOUN]",
	"[NAME] and the [ADJ] [NOUN]",
	"[NOUN] and [NAME]",
	"The [ADJ] [NOUN] and [NAME]",
	"The [ADJ] [NOUN] of [NAME]",
	"[ADJ] [PLACE]",
	"[ADJ] [PLACE] and [NAME]",
	"[ADJ] [PLACE] and the [NOUN]",
	"[ADJ] [PLACE] and the [ADJ] [NOUN]",
	"[ADJ] [PLACE] of the [NOUN]",
	"[ADJ] [PLACE] of the [ADJ] [NOUN]",
	"[ADJ] [NOUN] of [PLACE]",
	"[VERB] [NAME]",
	"[VERB] [PLACE] and [NAME]",
	"[VERB] [PLACE] and the [NOUN]",
	"[VERB] [PLACE] and the [ADJ] [NOUN]",
	"[VERB] [PLACE] of the [NOUN]",
	"[VERB] [PLACE] of the [ADJ] [NOUN]",
	"[VERB] [NOUN] of [PLACE]",
	"[VERB] [NOUN] of [NAME]",
	"[VERB] [NOUN] of [ADJ] [PLACE]",
	"The [GENITIVE_NOUN] of [NAME]",
	"The [GENITIVE_NOUN] of [PLACE]",
	"The [GENITIVE_NOUN] of [ADJ] [PLACE]",
	"The [GENITIVE_NOUN] of [ADJ] [NOUN]",
	"The [GENITIVE_NOUN] of [ADJ] [NOUN] in [PLACE]",
	"The [GENITIVE_NOUN] of [ADJ] [NOUN] with [NAME]",
	"The [GENITIVE_NOUN] of [ADJ] [NOUN] in [ADJ] [PLACE]",
	"The [GENITIVE_NOUN] of [READER_AGE]",
	"[VERB] [NOUN] of [READER_AGE]",
	"[VERB] [NOUN] for [READER_AGE]",
	"[VERB] [NOUN] of [ADJ] [NOUN] for [READER_AGE]",
	"[NOUN] for [READER_AGE]",
	"[READER_AGE] and [NOUN]",
	"[POSS_PRONOUN] [NOUN]",
	"[POSS_PRONOUN] [ADJ] [NOUN]",
}

BookVariantTitles is a list of very flexible book titles.

View Source
var DefaultTitleTokenIsMandatory = map[string]bool{
	TokenName:      true,
	TokenNoArtName: true,
	TokenNoun:      true,
	TokenAnyAge:    true,
}

DefaultTitleTokenIsMandatory is a map of title tokens to whether or not they need to be provided for generating the title. Optional tokens are replaced with a random representation. Example: "[NAME] and the [NOUN]" will always have to be provided, but [ADJ] might be chosen randomly from a list of adjectives.

DefaultTitleTokenPool is a map of title tokens to a list of possible replacements.

DefaultTitleTokens is a list of all default title tokens.

Functions

func GenerateTitle

func GenerateTitle(provided []genstory.TokenReplacement, titles []string) (*genstory.Generated, error)

GenerateTitle generates a text from the provided tokens and a list of possible templates.

  • The provided tokens are used to replace the tokens in the possible templates.
  • If a token is not provided and optional, it is replaced with a random value.
  • If a token is not provided and not optional, all templates that require that token are excluded.

TODO: Also return the selected template, and the individual replacements, so that the caller can use them for the description or the generation of content.

func NewSimpleTitleConfig

func NewSimpleTitleConfig(templates []string) *genstory.TextConfig

NewSimpleTitleConfig returns a simple title configuration.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL