Speech — Balladeer 0.39.0

# Speech

The role of most of our literature is, it seems, to destroy the world.

– Jean Paul Gustave Ricoeur

## Modelling

In the previous sections we saw how a few simple principles provide the potential for an extremely detailed world model.

Python is such a powerful language. We could generate thousands of entities with which to populate our story. Perhaps we might automate the process in clever ways. Maybe ingest some real-world data sets and synthesize an analogue of our home town or city.

Would that be a good approach? I shouldn’t think so. It doesn’t really help tell your story.

If you forget to create an Entity for the knife which kills Caesar, what does it matter? During the scene of the murder, Brutus always comes up with one anyway. Whether it is mentioned in the script or not, that knife exists in the mind of the reader. It’s there when it needs to be, otherwise no dead Emperor.

It’s true that text adventures have a tradition of progressing the story via the manipulation of objects. But there are other ways, and Balladeer encourages you to try them.

Here are some suggestions for a good Entity:

- A newspaper which prints articles from a parallel reality.

- A kettle that whistles tunes.

- A statue which comes alive and murders people.

- A bulletproof car with the calm authority of an English Butler.

In other words; characters. And the primary medium for your characters is Speech.

## Markup

So we need a way of defining Speech. It’s more than a string of words. We want to remember who says the words and why. We want the words to have an effect on the story.

Enter SpeechMark.

Important

Please read the documentation for SpeechMark. Take a few minutes to become familiar with its syntax.

class balladeer.lite.speech.Speech

  This is a lightweight class for objects which represent marked-up speech.

      speech = Speech('''
      <STAFF.proposing#3> What will you have, sir? The special is fish today.
          1. Order the Beef Wellington
          2. Go for the Shepherd's Pie
          3. Try the Dover Sole
      ''')

  trim() → str

    Eliminates indentation and other leading whitespace. This method is used internally, so you won’t need to call it explicitly.

  property tags: str

    Render the markup as HTML5.

        >>> speech.tags

        <blockquote cite="&lt;STAFF.proposing#3&gt;">
        <cite data-role="STAFF" data-directives=".proposing" data-fragments="#3">STAFF</cite>
        <p>
         What will you have, sir? The special is fish today.
        </p>
        <ol>
        <li id="1"><p>
        Order the Beef Wellington
        </p></li>
        <li id="2"><p>
        Go for the Shepherd's Pie
        </p></li>
        <li id="3"><p>
        Try the Dover Sole
        </p></li>
        </ol>
        </blockquote>

  property lines: list[str]

    Render the markup into lines of plain text.

        >>> speech.lines
        ['STAFF', 'What will you have, sir? The special is fish today.', 'Order the Beef Wellington',
        "Go for the Shepherd's Pie", 'Try the Dover Sole']

  property words: list[str]

    Render the markup into constituent words.

        >>> speech.words
        ['STAFF', 'What', 'will', 'you', 'have,', 'sir?', 'The', 'special', 'is', 'fish', 'today.',
        'Order', 'the', 'Beef', 'Wellington', 'Go', 'for', 'the', "Shepherd's", 'Pie',
        'Try', 'the', 'Dover', 'Sole']