The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Acme::Affinity - Compute the affinity between two people

VERSION

version 0.0114

SYNOPSIS

  use Acme::Affinity;

  # Please see the documentation for the contents of these values
  my %arguments = (questions => [], importance => {}, me => [], you => []);

  my $affinity = Acme::Affinity->new(%arguments);

  my $score = $affinity->score;

DESCRIPTION

An Acme::Affinity object computes the relationship affinity between two people based on a common list of questions, answers and their weighted importance.

ATTRIBUTES

questions

This is a list of hash references with question keys and answer array references.

Example:

  [
    { 'how messy are you' => [ 'very messy', 'average', 'very organized' ] },
    { 'do you like to be the center of attention' => [ 'yes', 'no' ] },
  ]

importance

This is a hash reference with importance level keys and weight values.

Default:

  {
    'irrelevant'         => 0,
    'a little important' => 1,
    'somewhat important' => 10,
    'very important'     => 50,
    'mandatory'          => 250,
  }

me

This is an array reference triple of question responses, desired responses and importance levels of person A for each of the given questions.

Example:

  #   Person A           Person B           Importance
  [ [ 'very organized',  'very organized',  'very important' ],
    [ 'no',              'no',              'a little important' ], ]

So person A ("me") considers him or herself to be "very organized", desires a "very organized" person, and this is "very important" to them.

Person A also does not need to be the "center of attention", desires the same type of person, but this is only "a little important."

you

This is an array reference triple of question responses, desired responses and importance levels of person B for each of the given questions.

Example:

  #   Person B           Person A    Importance
  [ [ 'very organized',  'average',  'a little important' ],
    [ 'yes',             'no',       'somewhat important' ], ]

Person B considers him or herself to be "very organized", but only desires someone who is "average", and this is only "a little important" to them.

Person B likes to be the "center of attention", desires someone who does not, and this is "somewhat important."

METHODS

new

  my $affinity = Acme::Affinity->new(
    questions  => \@questions,
    importance => \%importance,
    me         => \@me,
    you        => \@you,
  );

Create a new Acme::Affinity object.

score

  my $score = $affinity->score;

Compute the affinity score for the two given people.

SEE ALSO

The eg/* and t/01-methods.t programs in this distribution.

Moo

Math::BigRat

https://www.youtube.com/watch?v=m9PiPlRuy6E

AUTHOR

Gene Boggs <gene@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2022 by Gene Boggs.

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