The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Bot::Backbone::Service::Fact::Predicate - Keep track of statements of equivalence and the like

VERSION

version 0.142250

SYNOPSIS

    # in the bot configuration
    service predicate => (
        service         => 'Fact::Predicate',
        accepted_copula => [ qw( is says ) ],
    );

    # In chat:
    alice> Zathras says "Can not run out of time, there is infinite time. You
    are finite, Zathras is finite. This is wrong tool. No. No. Not good. No.
    No. Never use this."
    alice> Zathras?
    bot> Zathras says "Can not run out of time, there is infinite time. You
    are finite, Zathras is finite. This is wrong tool. No. No. Not good. No.
    No. Never use this."

DESCRIPTION

With this service configured, the bot will monitor the chat and whenever it encounters a statement that appears to be in the correct predicate nominative form, it will memorize that fact. Later one, if a question is issued for the memorize fact, the bot will return a memorized response for it. It can memorize multiple responses for the same fact, in which case, it returns any one of them at random.

DISPATCHER

!randomfact

This command will cause the bot to pick one of it's memorized facts and return it.

All Chats

All other chats are memorized to see if they appear to be of the form:

    <subject> <copula> <predicate>

In those cases, the fact is memorized.

At the same time, it checks to see if any chat message matches a known subject. If it does, the bot will return the original statement of the fact.

ATTRIBUTES

accepted_copula

This is a list of acceptable copula. A "copula" is a connecting word in a sentence connecting a subject and complement. Depending on context, there are a lot of words that can be found in a statement of equivalence, but the default just includes these words:

    is isn't are aren't

You can also put other words that aren't strictly words that define predicate nominative equivalence, such as "says" or "smells like" or whatever. Every time these words appear in a statement within a chat, though, it will be memorized.

copula_re

This is a regular expression that is usually built from the "accepted_copula". It is used to identify and split chats that contain a statement of the form the bot is looking for.

METHODS

load_schema

Used by the Bot::Backbone::Service::Role::Storage to setup the fact_predicates table.

store_fact

This is a helper function that saves a subject/predicate fact.

recall_fact

This is a helper used to retrieve a subject/predicate fact.

memorize_and_recall

This is the method used to monitor all chats for facts to memorize or recall.

random_fact

This implements the !randomfact command.

initialize

No op.

AUTHOR

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Qubling Software LLC.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.