Documentation is available at add.inc.php
- <?php
- /*
- Program E
- Copyright 2002, Paul Rydell
- This file is part of Program E.
- Program E is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- Program E is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with Program E; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
- /**
- * This is an edited copy of insertmysentence() in the botloaderfuncs.php.
- */
- function insertAnnesentence($mybigsentence, $botid)
- {
- $selectbot = $botid;
- $sentencepart="";
- $annesID = findmainnode($botid);
- /*
- OLD:
- $parent=-$selectbot;
- */
- // START NEW:
- $newstarted=0;
- if($annesID != ""){
- $parent = $annesID;
- } else {
- $parent=-$selectbot;
- }
- // END NEW
- //Parse into invidividual words
- //Use split
- $allwords=split(" ",$mybigsentence);
- $qadd="";
- for ($x=0;$x<sizeof($allwords)+1;$x++){
- // Last word in context
- $lwic=0;
- if ($x==sizeof($allwords)){
- $word="";
- }
- else {
- $word=$allwords[$x];
- }
- if (strtoupper($word)=="<INPUT>"){
- $sentencepart="INPUT";
- } elseif (strtoupper($word)=="<THAT>"){
- $sentencepart="THAT";
- } elseif (strtoupper($word)=="<TOPIC>"){
- $sentencepart="TOPIC";
- }
- // Find out if it is the last word in its context
- if ($x==(sizeof($allwords)-1)){
- $lwic=1;
- }
- // Prevent some warnings by checking this first.
- elseif (($x+1) >= (sizeof($allwords))){
- }
- elseif ((strtoupper($allwords[$x+1])=="<THAT>") || (strtoupper($allwords[$x+1])=="<TOPIC>")){
- $lwic=1;
- }
- if (($word!="*")&&($word!="_")){
- if ($newstarted!=1){
- $wordid=findwordid($word,$parent);
- }
- if (($wordid!=0) && ($newstarted!=1)){
- $parent=$wordid;
- }
- else {
- $newstarted=1;
- $sword=addslashes($word);
- $qadd="($selectbot, null,'$sword',2,$parent,$lwic)";
- $parent = insertwordpattern($qadd);
- }
- }
- elseif (($word=="*")||($word=="_")){
- if ($newstarted!=1){
- $wordid=findwordidstar($word,$parent);
- }
- if (($wordid!=0) && ($newstarted!=1)){
- $parent=$wordid;
- }
- else {
- $newstarted=1;
- if ($word=="*"){
- $val=3;
- }
- elseif ($word=="_"){
- $val=1;
- }
- $qadd="($selectbot, null,null,$val,$parent,$lwic)";
- $parent = insertwordpattern($qadd);
- }
- }
- }
- return $parent;
- }
- ?>
Documentation generated on Tue, 11 Jan 2005 18:40:57 +0100 by phpDocumentor 1.3.0RC3