constructor Bs_TextUtil [line 39]
Bs_TextUtil Bs_TextUtil(
)
|
|
method abbreviateString [line 596]
string abbreviateString(
string
$text, [int
$maxLength = 12])
|
|
To abbreviate a string to something meaningfull
Keep as much of the beginning string as possible and abbreviate starting at the end. NOTE: Only words with a beginning capital letter are abbreviated; the rest is trashed E.g.: Bs_TextUtil::abbreviateString('The Quick Red Fox', 12) // -> 'The Q. R. F.' Bs_TextUtil::abbreviateString('Hi, my name is Sam', 12) // -> 'Hi, my N. S.'
Parameters:
method getLanguageDependentValue [line 70]
string getLanguageDependentValue(
mixed
$var, [string
$lang = 'en'])
|
|
returns the value of a [language dependant] [object] var for the current language.
example: you have a language setting var like $hello = array( 'en' =>'hello', 'en_us'=>'hi', 'en_uk'=>'good morning sir', 'de' =>'guten morgen', 'de_ch'=>'guete morge', ); now you want the best match for your language. examples: de_de => de fr => en (first entry) en_us => en_us
Tags:
Parameters:
method longestCommonSubstring [line 650]
string longestCommonSubstring(
string
$string1, string
$string2)
|
|
finds the longest common substring of 2 strings and returns that part.
http://www.php.net/manual/en/ref.strings.php carl@youngbloods.org 09-Jan-2002 08:27 I've ported a function to PHP that will find the longest common substring in two different strings. Here it is: Here is where I found the original: http://www1.ics.uci.edu/~eppstein/161/960229.html
Tags:
Parameters:
method ordinal [line 529]
string ordinal(
[int
$num = 1])
|
|
returns the number as a string with it's ordinal value
examples: 1 => 1st 22 => 22nd 133 => 133rd 9 => 9th
thanks to: http://www.phpclasses.org/browse.html/file/1027.html
Tags:
Parameters:
method parseSearchQuery [line 138]
array parseSearchQuery(
string
$string)
|
|
parses the search input we got from the user.
example: "+foobar -"hello world" AND blah"
i am not sure where to put that method. so i place it here into Bs_TextUtil. :/
returns a vector filled with hashes that have the 3 keys:
'phrase' => the word like 'hello' or more if it was a phrase
in quotes like "pole position". it is the original
user input.
'words' => the words the user is looking for (vector).
if the "word" was in quotes like "hello world" then
this vector has more than 1 element.
'operator' => the operator, one of & (and), | (or), ! (not).
'fuzzy' => bool, if a fuzzy search should be performed on that.
added in bs-4.5, experimental. (i kinda miss the
option to specify better what fuzzy searches to do,
and how to weight them. to soundex but no stemming? ...
features:
- boolean searches, examples:
- "tom AND cherry"
- "hello -world"
- "tom UND cherry NOT foo bar lala blah"
- support for quotes, eg "foobar AND "hello world""
missing:
- support for brackets, eg "foobar AND (hello OR world)"
all input is converted to lower case. Bs_String->normalize() is applied to the whole string. but no further converting is done, no check for noise words, no min/max word length etc. do that yourself.
Tags:
Parameters:
method parseSearchQuery2 [line 288]
array parseSearchQuery2(
string
$string)
|
|
parses the search input we got from the user.
example: "+foobar -"hello world" AND blah"
returns a vector filled with hashes ...:
features:
- boolean searches, examples:
- "tom AND cherry"
- "hello -world"
- "tom UND cherry NOT foo bar lala blah"
- support for quotes, eg "foobar AND "hello world""
- near searches, eg "tom near jerry"
- fuzzy searches, eg "tom ~jerri". also stem searches, eg "jerr#".
- brackets, eg "tom and (jerry or cherry)"
missing:
- support for "not near" searches.
all input is converted to lower case. Bs_String->normalize() is applied to the whole string. but no further converting is done, no check for noise words, no min/max word length etc. do that yourself.
Tags:
Parameters:
method percentUppercase [line 694]
int percentUppercase(
string
$string)
|
|
tells how many % of the given string are written in uppercase.
may be useful to modify a post to a bbs or detect it as spam/junk.
Tags:
Parameters:
method pluralS [line 552]
string pluralS(
int
$count)
|
|
determine whether to print a plural 's' or not
example: you want to print something like you have 5 product[s] in your basket. now if the user has 1 product, it should be without the 's', otherwise it should with 's'. even if there is no (0) product.
thanks to: http://www.phpclasses.org/browse.html/file/1027.html
Tags:
Parameters:
method shortenString [line 572]
string shortenString(
string
$text, int
$length, [string
$suffix = '...'])
|
|
To shorten a string to a certain number of characters, replacing surplus chars with a shortening suffix-string such as "[...]"
If shortening would make no sense, the original string is returned. Total string size (incl. suffix) is max the given length.
Tags:
Parameters: