Source for file add.inc.php

Documentation is available at add.inc.php

  1. <?php
  2.  
  3. /*
  4. Program E
  5. Copyright 2002, Paul Rydell
  6. This file is part of Program E.
  7. Program E is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. Program E is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Program E; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21.  
  22.  
  23.  
  24. /**
  25. * This is an edited copy of insertmysentence() in the botloaderfuncs.php.
  26. */
  27. function insertAnnesentence($mybigsentence, $botid)
  28. {
  29. $selectbot = $botid;
  30.  
  31. $sentencepart="";
  32.  
  33. $annesID = findmainnode($botid);
  34. /*
  35. OLD:
  36.  
  37. $parent=-$selectbot;
  38. */
  39.  
  40. // START NEW:
  41. $newstarted=0;
  42. if($annesID != ""){
  43. $parent = $annesID;
  44. } else {
  45. $parent=-$selectbot;
  46. }
  47. // END NEW
  48.  
  49. //Parse into invidividual words
  50. //Use split
  51. $allwords=split(" ",$mybigsentence);
  52. $qadd="";
  53. for ($x=0;$x<sizeof($allwords)+1;$x++){
  54.  
  55. // Last word in context
  56. $lwic=0;
  57.  
  58. if ($x==sizeof($allwords)){
  59. $word="";
  60. }
  61. else {
  62. $word=$allwords[$x];
  63. }
  64. if (strtoupper($word)=="<INPUT>"){
  65. $sentencepart="INPUT";
  66. } elseif (strtoupper($word)=="<THAT>"){
  67. $sentencepart="THAT";
  68. } elseif (strtoupper($word)=="<TOPIC>"){
  69. $sentencepart="TOPIC";
  70. }
  71. // Find out if it is the last word in its context
  72. if ($x==(sizeof($allwords)-1)){
  73. $lwic=1;
  74. }
  75. // Prevent some warnings by checking this first.
  76. elseif (($x+1) >= (sizeof($allwords))){
  77. }
  78. elseif ((strtoupper($allwords[$x+1])=="<THAT>") || (strtoupper($allwords[$x+1])=="<TOPIC>")){
  79. $lwic=1;
  80. }
  81. if (($word!="*")&&($word!="_")){
  82.  
  83. if ($newstarted!=1){
  84. $wordid=findwordid($word,$parent);
  85. }
  86. if (($wordid!=0) && ($newstarted!=1)){
  87. $parent=$wordid;
  88. }
  89. else {
  90. $newstarted=1;
  91.  
  92. $sword=addslashes($word);
  93. $qadd="($selectbot, null,'$sword',2,$parent,$lwic)";
  94.  
  95. $parent = insertwordpattern($qadd);
  96.  
  97.  
  98. }
  99. }
  100. elseif (($word=="*")||($word=="_")){
  101.  
  102. if ($newstarted!=1){
  103. $wordid=findwordidstar($word,$parent);
  104. }
  105. if (($wordid!=0) && ($newstarted!=1)){
  106. $parent=$wordid;
  107. }
  108. else {
  109. $newstarted=1;
  110.  
  111. if ($word=="*"){
  112. $val=3;
  113. }
  114. elseif ($word=="_"){
  115. $val=1;
  116. }
  117.  
  118. $qadd="($selectbot, null,null,$val,$parent,$lwic)";
  119.  
  120. $parent = insertwordpattern($qadd);
  121.  
  122.  
  123. }
  124. }
  125. }
  126.  
  127. return $parent;
  128.  
  129. }
  130.  
  131.  
  132. ?>

Documentation generated on Tue, 11 Jan 2005 18:40:57 +0100 by phpDocumentor 1.3.0RC3