eliza.php
author Dan
Sat, 10 Jan 2009 14:12:36 -0500
changeset 50 45164bc2567a
parent 8 0acb8d9a3194
permissions -rw-r--r--
Whoops, debug message.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     1
<?php
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     2
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     3
/**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     4
 * Implementation of ELIZA in PHP. Ported from Javascript by Dan Fuhry
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     5
 * Chat Bot by George Dunlop, www.peccavi.com
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     6
 * May be used/modified if credit line is retained
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     7
 * @author George Dunlop <http://www.peccavi.com/>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     8
 * @author Dan Fuhry <dan@enanocms.org>
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
     9
 * @copyright (c) 1997-2008 George Dunlop. All rights reserved, portions copyright (C) 2008 Dan Fuhry.
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    10
 */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    11
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    12
class Psychotherapist
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    13
{
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    14
  private $maxKey = 36;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    15
  private $keyNotFound = 0;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    16
  private $keyword = array();
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    17
  private $maxresponses = 116;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    18
  private $response = array();
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    19
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    20
  private $maxConj = 19;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    21
  private $max2ndConj = 7;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    22
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    23
  private $conj1 = Array();
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    24
  private $conj2 = Array();
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    25
  private $conj3 = Array();
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    26
  private $conj4 = Array();
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    27
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    28
  private $punct = Array(".", ",", "!", "?", ":", ";", "&", '"', "@", "#", "(", ")" );
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    29
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    30
  /**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    31
   * Constructor.
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    32
   */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    33
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    34
  public function __construct()
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    35
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    36
    $this->keyNotFound = $this->maxKey - 1;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    37
    $this->keyword = $this->create_array($this->maxKey);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    38
    $this->response = $this->create_array($this->maxresponses);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    39
    $this->conj1 = $this->create_array($this->maxConj);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    40
    $this->conj2 = $this->create_array($this->maxConj);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    41
    $this->conj3 = $this->create_array($this->max2ndConj);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    42
    $this->conj4 = $this->create_array($this->max2ndConj);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    43
    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    44
    $this->table_setup();
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    45
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    46
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    47
  /**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    48
   * Replacement for str_replace that provides more options.
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    49
   * if type == 0 straight string replacement
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    50
   * if type == 1 assumes padded strings and replaces whole words only
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    51
   * if type == 2 non case sensitive assumes padded strings to compare whole word only
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    52
   * if type == 3 non case sensitive straight string replacement
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    53
   * @param string Haystack
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    54
   * @param string Needle
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    55
   * @param string Replacement
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    56
   * @param int Mode - defaults to 0
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    57
   */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    58
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    59
  private function replaceStr($strng, $substr1, $substr2, $type = 0)
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    60
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    61
    if ( $type == 0 )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    62
    {  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    63
      return str_replace($substr1, $substr2, $strng);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    64
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    65
    else if ( $type == 1 )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    66
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    67
      return str_replace(" $substr1 ", " $substr2 ", $strng);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    68
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    69
    else if ( $type == 2 || $type == 3 )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    70
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    71
      if ( $type == 2 )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    72
      {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    73
        $substr1 = " $substr1 ";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    74
        $substr2 = " $substr2 ";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    75
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    76
      return preg_replace('/' . preg_quote($substr1) . '/i', $substr2, $strng);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    77
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    78
    else
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    79
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    80
      throw new Exception("Invalid parameter");
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    81
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    82
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    83
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    84
  /**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    85
   * Function to pad a string. head, tail & punctuation
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    86
   * @param string
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    87
   * @return string
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    88
   */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    89
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    90
  private function padString($strng)
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    91
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    92
    $punct =& $this->punct;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    93
    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    94
    $aString = " " . $strng . " ";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    95
    for ( $i = 0; $i < count($punct); $i++ )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    96
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    97
      $aString = $this->replaceStr( $aString, $punct[$i], " " . $punct[$i] . " ", 0 );
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    98
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
    99
    return $aString;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   100
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   101
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   102
  /**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   103
   * Function to strip padding
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   104
   */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   105
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   106
  private function unpadString($strng)
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   107
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   108
    $punct =& $this->punct;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   109
    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   110
    $aString = $strng;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   111
    $aString = $this->replaceStr( $aString, "  ", " ", 0 );         // compress spaces
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   112
    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   113
    $aString = trim($aString, ' ');
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   114
    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   115
    for ( $i = 0; $i < count($punct); $i++ )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   116
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   117
      $aString = $this->replaceStr( $aString, " " . $punct[$i], $punct[$i], 0 );
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   118
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   119
    return $aString;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   120
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   121
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   122
  /**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   123
   * Dress Input formatting i.e leading & trailing spaces and tail punctuation
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   124
   * @param string
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   125
   * @return string
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   126
   */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   127
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   128
  function strTrim($strng)
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   129
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   130
    static $ht = 0;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   131
    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   132
    if ( $ht == 0 )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   133
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   134
      $loc = 0;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   135
    }                                    // head clip
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   136
    else
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   137
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   138
      $loc = strlen($strng) - 1;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   139
    }                        // tail clip  ht = 1 
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   140
    if ( substr($strng, $loc, 1) == " " )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   141
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   142
      $aString = substr($strng, - ( $ht - 1 ), strlen($strng) - $ht);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   143
      $aString = $this->strTrim($aString);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   144
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   145
    else
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   146
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   147
      $flg = false;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   148
      for ( $i = 0; $i <= 5; $i++ )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   149
      {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   150
        $flg = $flg || ( substr($strng, $loc, 1) == $this->punct[$i]);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   151
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   152
      if ( $flg )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   153
      {    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   154
        $aString = substr($strng, - ( $ht - 1 ), strlen($strng) - $ht);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   155
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   156
      else
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   157
      {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   158
        $aString = $strng;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   159
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   160
      if ( $aString != $strng )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   161
      {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   162
        $aString = $this->strTrim($aString);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   163
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   164
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   165
    if ( $ht == 0 )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   166
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   167
      $ht = 1;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   168
      $aString = $this->strTrim($aString);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   169
    } 
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   170
    else
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   171
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   172
      $ht = 0;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   173
    }        
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   174
    return $aString;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   175
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   176
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   177
  /**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   178
   * adjust pronouns and verbs & such
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   179
   * @param string
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   180
   * @return string
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   181
   */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   182
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   183
  private function conjugate($sStrg)
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   184
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   185
    $sString = $sStrg;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   186
    for ( $i = 0; $i < $this->maxConj; $i++ )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   187
    {            // decompose
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   188
      $sString = $this->replaceStr( $sString, $this->conj1[$i], "#@&" . $i, 2 );
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   189
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   190
    for( $i = 0; $i < $this->maxConj; $i++ )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   191
    {            // recompose
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   192
      $sString = $this->replaceStr( $sString, "#@&" . $i, $this->conj2[$i], 2 );
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   193
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   194
    // post process the resulting string
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   195
    for( $i = 0; $i < $this->max2ndConj; $i++ )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   196
    {            // decompose
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   197
      $sString = $this->replaceStr( $sString, $this->conj3[$i], "#@&" . $i, 2 );
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   198
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   199
    for( $i = 0; $i < $this->max2ndConj; $i++ )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   200
    {            // recompose
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   201
      $sString = $this->replaceStr( $sString, "#@&" . $i, $this->conj4[$i], 2 );
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   202
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   203
    return $sString;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   204
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   205
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   206
  /**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   207
   * Build our response string
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   208
   * get a random choice of response based on the key
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   209
   * Then structure the response
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   210
   * @param string
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   211
   * @param int Key index
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   212
   * @return string
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   213
   */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   214
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   215
  function phrase( $sString, $keyidx )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   216
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   217
    $idxmin  = $this->keyword[$keyidx]->idx;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   218
    $idrange = $this->keyword[$keyidx]->end - $idxmin + 1;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   219
    while ( $pass < 5 )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   220
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   221
      $choice = $this->keyword[$keyidx]->idx + mt_rand(0, $idrange);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   222
      if ( $choice == $this->keyword[$keyidx]->last )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   223
      { 
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   224
        $pass++;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   225
        continue;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   226
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   227
      break;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   228
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   229
    $this->keyword[$keyidx]->last = $choice;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   230
    $rTemp = $this->response[$choice];
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   231
    $tempt = substr($rTemp, strlen($rTemp) - 1, 1);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   232
    if ( ( $tempt == "*" ) || ( $tempt == "@" ) )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   233
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   234
      $sTemp = $this->padString($sString);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   235
      $wTemp = strtoupper($sTemp);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   236
      $strpstr = intval(strpos($wTemp, " {$this->keyword[$keyidx]->key} "));
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   237
      
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   238
      $strpstr += strlen($this->keyword[$keyidx]->key) + 1;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   239
      $thisstr = $this->conjugate( substr($sTemp, $strpstr, strlen($sTemp)) );
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   240
      $thisstr = $this->strTrim( $this->unpadString($thisstr) );
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   241
      if( $tempt == "*" )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   242
      {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   243
        $sTemp = $this->replaceStr( $rTemp, "<*", " " . $thisstr . "?", 0 );
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   244
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   245
      else
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   246
      {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   247
        $sTemp = $this->replaceStr( $rTemp, "<@", " " . $thisstr . ".", 0 );
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   248
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   249
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   250
    else
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   251
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   252
      $sTemp = $rTemp;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   253
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   254
    return $sTemp;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   255
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   256
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   257
  /**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   258
   * returns array index of first key found
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   259
   * @param string
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   260
   */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   261
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   262
  private function testkey($wString)
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   263
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   264
    for ( $keyid = 0; $keyid < count($this->keyword); $keyid++ )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   265
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   266
      if ( strpos($wString, " {$this->keyword[$keyid]->key} ") !== false )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   267
      { 
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   268
        return $keyid;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   269
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   270
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   271
    return false;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   272
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   273
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   274
  /**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   275
   * 
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   276
   */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   277
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   278
  private function findkey($wString)
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   279
  { 
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   280
    $keyid = $this->testkey($wString);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   281
    if( !$keyid )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   282
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   283
      $keyid = $this->keyNotFound;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   284
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   285
    return $keyid;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   286
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   287
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   288
  /**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   289
   * Process a line from the user.
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   290
   * @param string User input
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   291
   * @return string AI output
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   292
   */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   293
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   294
  function listen($User)
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   295
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   296
    static $wTopic = "";                                            // Last worthy responce
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   297
    static $sTopic = "";                                            // Last worthy responce
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   298
    static $greet = false;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   299
    static $wPrevious = "";                                    // so we can check for repeats
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   300
    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   301
    $sInput = $User;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   302
    $sInput = $this->strTrim($sInput);                            // dress input formating
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   303
    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   304
    if ( $sInput != "" )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   305
    { 
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   306
      $wInput = $this->padString(strtoupper($sInput));    // Work copy
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   307
      $foundkey = $this->maxKey;                          // assume it's a repeat input
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   308
      if ( $wInput != $wPrevious )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   309
      {                       // check if user repeats himself
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   310
        $foundkey = $this->findkey($wInput);               // look for a keyword.
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   311
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   312
      if( $foundkey == $this->keyNotFound )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   313
      {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   314
        if( !$greet )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   315
        {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   316
          $greet = true;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   317
          return "Don't you ever say Hello?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   318
        }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   319
        else
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   320
        {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   321
          $wPrevious = $wInput;                      // save input to check repeats
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   322
          if (( strlen($sInput) < 10 ) && ( $wTopic != "" ) && ( $wTopic != $wPrevious ))
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   323
          {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   324
            $lTopic = $this->conjugate( $sTopic );
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   325
            $sTopic = "";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   326
            $wTopic = "";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   327
            return 'OK... "' + $lTopic + '". Tell me more.';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   328
          }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   329
          else
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   330
          {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   331
            if ( strlen($sInput) < 15 )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   332
            { 
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   333
              return "Tell me more..."; 
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   334
            }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   335
            else
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   336
            {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   337
              return $this->phrase( $sInput, $foundkey );
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   338
            }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   339
          }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   340
        }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   341
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   342
      else
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   343
      { 
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   344
        if ( strlen($sInput) > 12 )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   345
        {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   346
          $sTopic = $sInput;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   347
          $wTopic = $wInput;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   348
        }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   349
        $greet = true;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   350
        $wPrevious = $wInput;              // save input to check repeats
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   351
        return $this->phrase( $sInput, $foundkey );            // Get our response
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   352
      }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   353
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   354
    else
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   355
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   356
      return "I can't help if you will not chat with me!";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   357
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   358
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   359
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   360
  /**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   361
   * Creates an array of the specified length, and fills it with null values.
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   362
   * @param int Array size
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   363
   * @return array
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   364
   */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   365
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   366
  function create_array($len)
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   367
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   368
    $ret = array();
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   369
    for ( $i = 0; $i < $len; $i++ )
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   370
    {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   371
      $ret[] = null;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   372
    }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   373
    return $ret;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   374
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   375
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   376
  /**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   377
   * Sets up the tables of phrases, etc.
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   378
   */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   379
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   380
  private function table_setup()
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   381
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   382
    // build our data base here
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   383
							 
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   384
    $this->conj1[0]  = "are";           $this->conj2[0]  = "am";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   385
    $this->conj1[1]  = "am";            $this->conj2[1]  = "are";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   386
    $this->conj1[2]  = "were";          $this->conj2[2]  = "was";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   387
    $this->conj1[3]  = "was";           $this->conj2[3]  = "were";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   388
    $this->conj1[4]  = "I";             $this->conj2[4]  = "you";    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   389
    $this->conj1[5]  = "me";            $this->conj2[5]  = "you";    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   390
    $this->conj1[6]  = "you";           $this->conj2[6]  = "me";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   391
    $this->conj1[7]  = "my";            $this->conj2[7]  = "your";    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   392
    $this->conj1[8]  = "your";          $this->conj2[8]  = "my";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   393
    $this->conj1[9]  = "mine";          $this->conj2[9]  = "your's";    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   394
    $this->conj1[10] = "your's";        $this->conj2[10] = "mine";    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   395
    $this->conj1[11] = "I'm";           $this->conj2[11] = "you're";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   396
    $this->conj1[12] = "you're";        $this->conj2[12] = "I'm";    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   397
    $this->conj1[13] = "I've";          $this->conj2[13] = "you've";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   398
    $this->conj1[14] = "you've";        $this->conj2[14] = "I've";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   399
    $this->conj1[15] = "I'll";          $this->conj2[15] = "you'll";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   400
    $this->conj1[16] = "you'll";        $this->conj2[16] = "I'll";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   401
    $this->conj1[17] = "myself";        $this->conj2[17] = "yourself";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   402
    $this->conj1[18] = "yourself";      $this->conj2[18] = "myself";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   403
    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   404
    // array to post process correct our tenses of pronouns such as "I/me"
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   405
    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   406
    $this->conj3[0]  = "me am";         $this->conj4[0]  = "I am";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   407
    $this->conj3[1]  = "am me";         $this->conj4[1]  = "am I";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   408
    $this->conj3[2]  = "me can";        $this->conj4[2]  = "I can";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   409
    $this->conj3[3]  = "can me";        $this->conj4[3]  = "can I";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   410
    $this->conj3[4]  = "me have";       $this->conj4[4]  = "I have";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   411
    $this->conj3[5]  = "me will";       $this->conj4[5]  = "I will";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   412
    $this->conj3[6]  = "will me";       $this->conj4[6]  = "will I";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   413
    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   414
    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   415
    // Keywords
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   416
    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   417
    $this->keyword[ 0]=new Psychotherapist_Key( "CAN YOU",          1,  3);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   418
    $this->keyword[ 1]=new Psychotherapist_Key( "CAN I",            4,  5);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   419
    $this->keyword[ 2]=new Psychotherapist_Key( "YOU ARE",          6,  9);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   420
    $this->keyword[ 3]=new Psychotherapist_Key( "YOU'RE",           6,  9);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   421
    $this->keyword[ 4]=new Psychotherapist_Key( "I DON'T",          10, 13);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   422
    $this->keyword[ 5]=new Psychotherapist_Key( "I FEEL",           14, 16);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   423
    $this->keyword[ 6]=new Psychotherapist_Key( "WHY DON'T YOU", 17, 19);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   424
    $this->keyword[ 7]=new Psychotherapist_Key( "WHY CAN'T I",     20, 21);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   425
    $this->keyword[ 8]=new Psychotherapist_Key( "ARE YOU",          22, 24);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   426
    $this->keyword[ 9]=new Psychotherapist_Key( "I CAN'T",          25, 27);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   427
    $this->keyword[10]=new Psychotherapist_Key( "I AM",             28, 31);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   428
    $this->keyword[11]=new Psychotherapist_Key( "I'M",              28, 31);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   429
    $this->keyword[12]=new Psychotherapist_Key( "YOU",              32, 34);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   430
    $this->keyword[13]=new Psychotherapist_Key( "I WANT",           35, 39);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   431
    $this->keyword[14]=new Psychotherapist_Key( "WHAT",             40, 48);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   432
    $this->keyword[15]=new Psychotherapist_Key( "HOW",              40, 48);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   433
    $this->keyword[16]=new Psychotherapist_Key( "WHO",              40, 48);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   434
    $this->keyword[17]=new Psychotherapist_Key( "WHERE",            40, 48);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   435
    $this->keyword[18]=new Psychotherapist_Key( "WHEN",             40, 48);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   436
    $this->keyword[19]=new Psychotherapist_Key( "WHY",              40, 48);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   437
    $this->keyword[20]=new Psychotherapist_Key( "NAME",             49, 50);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   438
    $this->keyword[21]=new Psychotherapist_Key( "CAUSE",            51, 54);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   439
    $this->keyword[22]=new Psychotherapist_Key( "SORRY",            55, 58);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   440
    $this->keyword[23]=new Psychotherapist_Key( "DREAM",            59, 62);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   441
    $this->keyword[24]=new Psychotherapist_Key( "HELLO",            63, 63);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   442
    $this->keyword[25]=new Psychotherapist_Key( "HI",               63, 63);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   443
    $this->keyword[26]=new Psychotherapist_Key( "MAYBE",            64, 68);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   444
    $this->keyword[27]=new Psychotherapist_Key( "NO",               69, 73);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   445
    $this->keyword[28]=new Psychotherapist_Key( "YOUR",             74, 75);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   446
    $this->keyword[29]=new Psychotherapist_Key( "ALWAYS",           76, 79);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   447
    $this->keyword[30]=new Psychotherapist_Key( "THINK",            80, 82);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   448
    $this->keyword[31]=new Psychotherapist_Key( "ALIKE",            83, 89);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   449
    $this->keyword[32]=new Psychotherapist_Key( "YES",              90, 92);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   450
    $this->keyword[33]=new Psychotherapist_Key( "FRIEND",           93, 98);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   451
    $this->keyword[34]=new Psychotherapist_Key( "COMPUTER",         99, 105);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   452
    $this->keyword[35]=new Psychotherapist_Key( "NO KEY FOUND",     106, 112);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   453
    $this->keyword[36]=new Psychotherapist_Key( "REPEAT INPUT",     113, 116);
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   454
    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   455
    
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   456
    $this->response[  0]="ELIZA - PHP version ported from Javascript (George Dunlop) code by Dan Fuhry";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   457
    $this->response[  1]="Don't you believe that I can<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   458
    $this->response[  2]="Perhaps you would like to be able to<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   459
    $this->response[  3]="You want me to be able to<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   460
    $this->response[  4]="Perhaps you don't want to<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   461
    $this->response[  5]="Do you want to be able to<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   462
    $this->response[  6]="What makes you think I am<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   463
    $this->response[  7]="Does it please you to believe I am<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   464
    $this->response[  8]="Perhaps you would like to be<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   465
    $this->response[  9]="Do you sometimes wish you were<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   466
    $this->response[ 10]="Don't you really<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   467
    $this->response[ 11]="Why don't you<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   468
    $this->response[ 12]="Do you wish to be able to<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   469
    $this->response[ 13]="Does that trouble you?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   470
    $this->response[ 14]="Tell me more about such feelings.";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   471
    $this->response[ 15]="Do you often feel<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   472
    $this->response[ 16]="Do you enjoy feeling<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   473
    $this->response[ 17]="Do you really believe I don't<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   474
    $this->response[ 18]="Perhaps in good time I will<@";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   475
    $this->response[ 19]="Do you want me to<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   476
    $this->response[ 20]="Do you think you should be able to<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   477
    $this->response[ 21]="Why can't you<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   478
    $this->response[ 22]="Why are you interested in whether or not I am<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   479
    $this->response[ 23]="Would you prefer if I were not<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   480
    $this->response[ 24]="Perhaps in your fantasies I am<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   481
    $this->response[ 25]="How do you know you can't<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   482
    $this->response[ 26]="Have you tried?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   483
    $this->response[ 27]="Perhaps you can now<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   484
    $this->response[ 28]="Did you come to me because you are<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   485
    $this->response[ 29]="How long have you been<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   486
    $this->response[ 30]="Do you believe it is normal to be<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   487
    $this->response[ 31]="Do you enjoy being<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   488
    $this->response[ 32]="We were discussing you, not me.";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   489
    $this->response[ 33]="Oh... <*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   490
    $this->response[ 34]="You're not really talking about me, are you?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   491
    $this->response[ 35]="What would it mean to you if you got<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   492
    $this->response[ 36]="Why do you want<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   493
    $this->response[ 37]="Suppose you got<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   494
    $this->response[ 38]="What if you never got<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   495
    $this->response[ 39]="I sometimes also want<@";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   496
    $this->response[ 40]="Why do you ask?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   497
    $this->response[ 41]="Does that question interest you?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   498
    $this->response[ 42]="What answer would please you the most?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   499
    $this->response[ 43]="What do you think?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   500
    $this->response[ 44]="Are such questions on your mind often?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   501
    $this->response[ 45]="What is it that you really want to know?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   502
    $this->response[ 46]="Have you asked anyone else?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   503
    $this->response[ 47]="Have you asked such questions before?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   504
    $this->response[ 48]="What else comes to mind when you ask that?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   505
    $this->response[ 49]="Names don't interest me.";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   506
    $this->response[ 50]="I don't care about names, please go on.";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   507
    $this->response[ 51]="Is that the real reason?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   508
    $this->response[ 52]="Don't any other reasons come to mind?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   509
    $this->response[ 53]="Does that reason explain anything else?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   510
    $this->response[ 54]="What other reasons might there be?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   511
    $this->response[ 55]="Please don't apologise!";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   512
    $this->response[ 56]="Apologies are not necessary.";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   513
    $this->response[ 57]="What feelings do you have when you apologise?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   514
    $this->response[ 58]="Don't be so defensive!";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   515
    $this->response[ 59]="What does that dream suggest to you?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   516
    $this->response[ 60]="Do you dream often?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   517
    $this->response[ 61]="What persons appear in your dreams?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   518
    $this->response[ 62]="Are you disturbed by your dreams?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   519
    $this->response[ 63]="How are you today.. What would you like to discuss?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   520
    $this->response[ 64]="You don't seem quite certain.";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   521
    $this->response[ 65]="Why the uncertain tone?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   522
    $this->response[ 66]="Can't you be more positive?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   523
    $this->response[ 67]="You aren't sure?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   524
    $this->response[ 68]="Don't you know?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   525
    $this->response[ 69]="Are you saying no just to be negative?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   526
    $this->response[ 70]="You are being a bit negative.";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   527
    $this->response[ 71]="Why not?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   528
    $this->response[ 72]="Are you sure?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   529
    $this->response[ 73]="Why no?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   530
    $this->response[ 74]="Why are you concerned about my<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   531
    $this->response[ 75]="What about your own<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   532
    $this->response[ 76]="Can you think of a specific example?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   533
    $this->response[ 77]="When?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   534
    $this->response[ 78]="What are you thinking of?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   535
    $this->response[ 79]="Really, always?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   536
    $this->response[ 80]="Do you really think so?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   537
    $this->response[ 81]="But you are not sure you<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   538
    $this->response[ 82]="Do you doubt you<*";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   539
    $this->response[ 83]="In what way?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   540
    $this->response[ 84]="What resemblence do you see?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   541
    $this->response[ 85]="What does the similarity suggest to you?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   542
    $this->response[ 86]="What other connections do you see?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   543
    $this->response[ 87]="Could there really be some connection?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   544
    $this->response[ 88]="How?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   545
    $this->response[ 89]="You seem quite positive.";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   546
    $this->response[ 90]="Are you Sure?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   547
    $this->response[ 91]="I see.";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   548
    $this->response[ 92]="I understand.";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   549
    $this->response[ 93]="Why do you bring up the topic of friends?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   550
    $this->response[ 94]="Do your friends worry you?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   551
    $this->response[ 95]="Do your friends pick on you?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   552
    $this->response[ 96]="Are you sure you have any friends?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   553
    $this->response[ 97]="Do you impose on your friends?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   554
    $this->response[ 98]="Perhaps your love for friends worries you.";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   555
    $this->response[ 99]="Do computers worry you?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   556
    $this->response[100]="Are you talking about me in particular?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   557
    $this->response[101]="Are you frightened by machines?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   558
    $this->response[102]="Why do you mention computers?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   559
    $this->response[103]="What do you think machines have to do with your problems?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   560
    $this->response[104]="Don't you think computers can help people?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   561
    $this->response[105]="What is it about machines that worries you?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   562
    $this->response[106]="Say, do you have any psychological problems?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   563
    $this->response[107]="What does that suggest to you?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   564
    $this->response[108]="I see.";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   565
    $this->response[109]="I'm not sure I understand you fully.";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   566
    $this->response[110]="Come, come, elucidate your thoughts.";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   567
    $this->response[111]="Can you elaborate on that?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   568
    $this->response[112]="That is quite interesting.";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   569
    $this->response[113]="Why did you repeat yourself?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   570
    $this->response[114]="Do you expect a different answer by repeating yourself?";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   571
    $this->response[115]="Come, come, elucidate your thoughts.";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   572
    $this->response[116]="Please don't repeat yourself!";
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   573
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   574
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   575
}
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   576
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   577
/**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   578
 * Keyword class
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   579
 */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   580
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   581
class Psychotherapist_Key
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   582
{
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   583
  /**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   584
   * Phrase to match
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   585
   * @var string
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   586
   */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   587
   
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   588
  public $key = '';
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   589
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   590
  /**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   591
   * First response to use
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   592
   * @var int
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   593
   */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   594
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   595
  public $idx = 0;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   596
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   597
  /**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   598
   * Last response to use
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   599
   * @var int
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   600
   */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   601
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   602
  public $end = 0;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   603
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   604
  /**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   605
   * Response last used time
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   606
   * @var int
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   607
   */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   608
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   609
  public $last = 0;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   610
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   611
  /**
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   612
   * Constructor.
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   613
   * @param string Key
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   614
   * @param int Index
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   615
   * @param int End
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   616
   */
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   617
  
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   618
  public function __construct($key, $idx, $end)
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   619
  {
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   620
    $this->key = $key;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   621
    $this->idx = $idx;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   622
    $this->end = $end;
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   623
  }
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   624
}
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   625
0acb8d9a3194 Welcome, modularization and stats.
Dan
parents:
diff changeset
   626