You are here:  » Implementing a new Feature


Implementing a new Feature

Submitted by shawnwalters on Wed, 2007-06-13 15:51 in

Hi,

I'm trying to implement a new feature for spelling correction, I've outlined it here:

{link saved}

and here if you view source:

{link saved}

The engine name is spellcheck. I tried using this:

<?php
function Spell($record)
{
  if ((
$record["RESULTSET-ENGINECODE"] == "cs")) {
    if ((
$record['RESULTSET@2-RESULTSCOUNT'])) {
      echo 
"Did You Mean: <a href='?q=" $record['RESULTSET/CORRECTION'] . "'   style='text-decoration:none;'>" $record['RESULTSET/CORRECTION'] . "</a>";
  }
}
?>

But that doesn't work. Can you help me figure out how to add this?

Thanks,
Shawn

Submitted by support on Wed, 2007-06-13 15:58

Hi Shawn,

Just looking over it very quickly, I notice that you are using:

if ($record["RESULTSET-ENGINECODE"] == "cs")

..wheras the value in the result you linked to is "ss", so as it stands nothing would be displayed...

Cheers,
David.

Submitted by shawnwalters on Wed, 2007-06-13 16:38

hmm, ok I tried ss and still nothing?

Submitted by support on Wed, 2007-06-13 16:46

Hi Shawn,

Try the following code, which is pretty much the same, and seems to work correctly:

<?php
  
require("MagicParser.php");
  function 
Spell($record)
  {
    if (
$record["RESULTSET-ENGINECODE"] == "ss")
    {
      if (
$record['RESULTSET@2-RESULTSCOUNT'])
      {
        echo 
"Did You Mean: <a href='?q=" $record['RESULTSET/CORRECTION'] . "'   style='text-decoration:none;'>" $record['RESULTSET/CORRECTION'] . "</a>";
      }
    }
  }
  
$url "{URL SNIPPED}";
  
MagicParser_parse($url,"Spell","xml|AJRESULTS/ENGINE/");
?>

Here's the output running on this server:

http://www.magicparser.com/examples/spell.php

Cheers,
David.