Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

resolve_soundex()

Description

Resolves the most commonly used keyword that sounds like the given keyword.

This function attempts to find a keyword that phonetically matches the provided keyword
using the Soundex algorithm. If no Soundex match is found, it will suggest the most commonly
used keyword that starts with the same first few letters.

Parameters

ColumnTypeDefaultDescription
$keyword string The keyword to resolve.

Return

string|false Returns the matched keyword if found, or false if no match is found.

Location

include/search_functions.php lines 17 to 27

Definition

 
function resolve_soundex($keyword)
    {
    global 
$soundex_suggest_limit;
    
$soundex=ps_value("SELECT keyword value FROM keyword WHERE soundex = ? AND keyword NOT LIKE '% %' AND hit_count >= ? ORDER BY hit_count DESC LIMIT 1",["s",soundex($keyword),"i",$soundex_suggest_limit],false);
    if ((
$soundex===false) && (strlen($keyword)>=4))
        {
        
# No soundex match, suggest words that start with the same first few letters.
        
return ps_value("SELECT keyword value FROM keyword WHERE keyword LIKE ? AND keyword NOT LIKE '% %' ORDER BY hit_count DESC LIMIT 1",["s",substr($keyword,0,4) . "%"],false);
        }
    return 
$soundex;
    }

This article was last updated 17th November 2024 15:35 Europe/London time based on the source file dated 8th November 2024 11:45 Europe/London time.