Documentation

simterms.php

\file \brief PHP Utility Functions to calculate similar terms of a term.

PHP version 8.1

Tags
author

LWT Project lwt-project@hotmail.com

license

Unlicense http://unlicense.org/

link
https://hugofara.github.io/lwt/docs/php/files/inc-simterms.html

Table of Contents

Functions

letterPairs()  : array<string|int, string>
wordLetterPairs()  : array<string|int, string>
getSimilarityRanking()  : float
Similarity ranking of two UTF-8 strings $str1 and $str2
get_similar_terms()  : array<string|int, int>
For a language $lang_id and a term $compared_term (UTF-8).
format_term()  : string
Prepare a field with a similar term to copy.
print_similar_terms()  : string
Get Term and translation of terms in termid array (calculated in function get_similar_terms(...)) as string for echo
print_similar_terms_tabrow()  : void
Print a row for similar terms if the feature is enabled.

Functions

letterPairs()

letterPairs(mixed $str) : array<string|int, string>
Parameters
$str : mixed
Tags
psalm-return

array<0|positive-int, string>

Return values
array<string|int, string>

wordLetterPairs()

wordLetterPairs(mixed $str) : array<string|int, string>
Parameters
$str : mixed
Tags
psalm-return

list

Return values
array<string|int, string>

getSimilarityRanking()

Similarity ranking of two UTF-8 strings $str1 and $str2

getSimilarityRanking(mixed $str1, mixed $str2) : float

Source http://www.catalysoft.com/articles/StrikeAMatch.html Source http://stackoverflow.com/questions/653157

Parameters
$str1 : mixed
$str2 : mixed
Return values
float

SimilarityRanking

get_similar_terms()

For a language $lang_id and a term $compared_term (UTF-8).

get_similar_terms(int $lang_id, string $compared_term, int $max_count, float $min_ranking) : array<string|int, int>

If string is already in database, it will be excluded in results.

Parameters
$lang_id : int

Language ID

$compared_term : string

Term to compare with

$max_count : int

Maximum number of terms to display

$min_ranking : float

For terms to match

Tags
psalm-return

array<positive-int, int>

Return values
array<string|int, int>

All $max_count wordids with a similarity ranking > $min_ranking, sorted decending

format_term()

Prepare a field with a similar term to copy.

format_term(int $termid, string $compare) : string
Parameters
$termid : int

Initial term ID

$compare : string

Similar term to copy.

Tags
global

string $tbpref

Return values
string

HTNL-formatted string with the similar term displayed.

print_similar_terms()

Get Term and translation of terms in termid array (calculated in function get_similar_terms(...)) as string for echo

print_similar_terms(int $lang_id, string $compared_term) : string
Parameters
$lang_id : int

Language ID

$compared_term : string

Similar term we compare to

Return values
string

print_similar_terms_tabrow()

Print a row for similar terms if the feature is enabled.

print_similar_terms_tabrow() : void

        
On this page

Search results