Learning with Texts - Fork 2.9.0-fork
Learn foreign languages with texts
Loading...
Searching...
No Matches
Namespaces | Functions
simterms.php File Reference

PHP Utility Functions to calculate similar terms of a term. More...

Namespaces

namespace  Lwt
 

Functions

 letterPairs ($str)
 
 wordLetterPairs ($str)
 
 getSimilarityRanking ($str1, $str2)
 
 get_similar_terms ( $lang_id, $compared_term, $max_count, $min_ranking)
 
 format_term ($termid, $compare)
 
 print_similar_terms ($lang_id, $compared_term)
 
 print_similar_terms_tabrow ()
 

Detailed Description

PHP Utility Functions to calculate similar terms of a term.

PHP version 8.1

Function Documentation

◆ format_term()

format_term (   $termid,
  $compare 
)

Prepare a field with a similar term to copy.

Parameters
int$termidInitial term ID
string$compareSimilar term to copy.
Returns
string HTNL-formatted string with the similar term displayed.

@global string $tbpref

◆ get_similar_terms()

get_similar_terms (   $lang_id,
  $compared_term,
  $max_count,
  $min_ranking 
)

For a language $lang_id and a term $compared_term (UTF-8). If string is already in database, it will be excluded in results.

Parameters
int$lang_idLanguage ID
string$compared_termTerm to compare with
int$max_countMaximum number of terms to display
float$min_rankingFor terms to match
Returns
int[] All $max_count wordids with a similarity ranking > $min_ranking, sorted decending

@psalm-return array<positive-int, int>

◆ getSimilarityRanking()

getSimilarityRanking (   $str1,
  $str2 
)

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

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

Returns
float SimilarityRanking

◆ letterPairs()

letterPairs (   $str)
Returns
string[]

@psalm-return array<0|positive-int, string>

◆ print_similar_terms()

print_similar_terms (   $lang_id,
  $compared_term 
)

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

Parameters
int$lang_idLanguage ID
string$compared_termSimilar term we compare to

◆ print_similar_terms_tabrow()

print_similar_terms_tabrow ( )

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

◆ wordLetterPairs()

wordLetterPairs (   $str)

@psalm-return list<string>

Returns
string[]