simterms.php
\file \brief PHP Utility Functions to calculate similar terms of a term.
PHP version 8.1
Tags
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
Return values
array<string|int, string>wordLetterPairs()
wordLetterPairs(mixed $str) : array<string|int, string>
Parameters
- $str : mixed
Tags
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
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
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
stringprint_similar_terms_tabrow()
Print a row for similar terms if the feature is enabled.
print_similar_terms_tabrow() : void