strip html tags from alice responses

Help
matteo
2007-02-19
2013-04-25
  • matteo

    matteo - 2007-02-19

    hello
    i have a little problem while attempting to eliminate html tags (mainly <br/>) from the botresponse

    i tried to use php built-in function strip_tags()

    and i also tried using a custom function
    here is the code:
    function strip_html_tags($string) {
        $search = "@<[\/\!]*?[^<>]*?>@si";
        if (is_string($string)){
            $cleanString = preg_replace($search, "", $string);
            return $cleanString;
        }   
    }

    the string resulting from these functions seems ok, but it's not, cause it doesn't have <br/> but still keeps the information of breaking the line, somehow

    so, how can i change the core-engine of programE in order to instruct it not to go to a new line when responding with more than one sentence?
    thanks
    matteo

     
    • Anne Kootstra

      Anne Kootstra - 2007-02-20

      Just to cover the basics, have you tested the input, i.e. the AIML files, that they themselves do not contain any <br/> or other HTML tags in the <template> ...</template> section? If so, then continue to check if they are indeed loaded into the database by checking the table "templates" for tags in it's records.

      Kind regards,

      Anne.

       
      • matteo

        matteo - 2007-02-21

        i checked the aiml files and found many <br/> tags in them. so, once deleted all of them and reloaded the aiml files into the database, the problem should be solved. i didn't think that they could be hard coded but somehow assumed that the php interpreter put tags among sentences.
        I will update this thread once the database will be reloaded
        thanks
        matteo

         
    • Anne Kootstra

      Anne Kootstra - 2007-02-23

      In the standard AIML sets there is a lot of non-AIML content; <br/> is just one example. Another would be the unsupported <javascript> tag, or some other user specific tag or construct. So, in order to be able to make pure text responder it's best to filter the AIML files, either through a script or manually.

      Kind regards,

      Anne.

       
    • matteo

      matteo - 2007-03-05

      i eliminated all html tags from the aiml files, yet the problem still appears.
      i exploded the bot response into an array so that the newline gap is evident, and here is an example of what i get: www.mmatteo.com/explodedResponse.txt
      there is no <br/> or whatsoever, but still the response is divided and goes to a new line after the first sentence..

       

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks