__construct (Constructor) [line 181]
Text_LanguageDetect __construct(
)
|
|
Constructor
Will attempt to load the language database. If it fails, you will get an exception.
clusteredSearch [line 1350]
array clusteredSearch(
string
$str)
|
|
Perform an intelligent detection based on clusterLanguages()
WARNING: this method is EXPERIMENTAL. It is not recommended for common use, and it may disappear or its functionality may change in future releases without notice.
This compares the sample text to top the top level of clusters. If the sample is similar to the cluster it will drop down and compare it to the languages in the cluster, and so on until it hits a leaf node.
this should find the language in considerably fewer compares (the equivalent of a binary search), however clusterLanguages() is costly and the loss of accuracy from this technique is significant.
This method may need to be 'fuzzier' in order to become more accurate.
This function could be more useful if the universe of possible languages was very large, however in such cases some method of Bayesian inference might be more helpful.
Parameters:
clusterLanguages [line 1159]
array clusterLanguages(
)
|
|
Cluster known languages according to languageSimilarity()
WARNING: this method is EXPERIMENTAL. It is not recommended for common use, and it may disappear or its functionality may change in future releases without notice.
Uses a nearest neighbor technique to generate the maximum possible number of dendograms from the similarity data.
detect [line 678]
mixed detect(
string
$sample, [int
$limit = 0])
|
|
Detects the closeness of a sample of text to the known languages
Calculates the statistical difference between the text and the trigrams for each language, normalizes the score then returns results for all languages in sorted order
If perl compatible, the score is 300-0, 0 being most similar. Otherwise, it's 0-1 with 1 being most similar.
The $sample text should be at least a few sentences in length; should be ascii-7 or utf8 encoded, if another and the mbstring extension is present it will try to detect and convert. However, experience has shown that mb_detect_encoding() *does not work very well* with at least some types of encoding.
Parameters:
detectConfidence [line 859]
array detectConfidence(
string
$sample)
|
|
Returns an array containing the most similar language and a confidence rating
Confidence is a simple measure calculated from the similarity score minus the similarity score from the next most similar language divided by the highest possible score. Languages that have closely related cousins (e.g. Norwegian and Danish) should generally have lower confidence scores.
The similarity score answers the question "How likely is the text the returned language regardless of the other languages considered?" The confidence score is one way of answering the question "how likely is the text the detected language relative to the rest of the language model set?"
To see how similar languages are a priori, see languageSimilarity()
Parameters:
detectSimple [line 819]
string detectSimple(
string
$sample)
|
|
Returns only the most similar language to the text sample
Calls $this->detect() and returns only the top result
Parameters:
detectUnicodeBlocks [line 906]
array detectUnicodeBlocks(
string
$str, bool
$skip_symbols)
|
|
Returns the distribution of unicode blocks in a given utf8 string
For the block name of a single char, use unicodeBlockName()
Parameters:
getLanguageCount [line 360]
Returns the number of languages that this object can detect
getLanguages [line 402]
Returns the list of detectable languages
languageExists [line 372]
bool languageExists(
mixed
$lang)
|
|
Checks if the language with the given name exists in the database
Parameters:
languageSimilarity [line 1066]
array languageSimilarity(
[string
$lang1 = null], [string
$lang2 = null])
|
|
Calculate the similarities between the language models
Use this function to see how similar languages are to each other.
If passed 2 language names, will return just those languages compared. If passed 1 language name, will return that language compared to all others. If passed none, will return an array of every language model compared to every other one.
Parameters:
omitLanguages [line 301]
int omitLanguages(
mixed
$omit_list, [bool
$include_only = false])
|
|
Omits languages
Pass this function the name of or an array of names of languages that you don't want considered
If you're only expecting a limited set of languages, this can greatly speed up processing
Parameters:
setNameMode [line 440]
void setNameMode(
integer
$name_mode)
|
|
Sets the way how language names are accepted and returned.
Parameters:
setPerlCompatible [line 416]
void setPerlCompatible(
[bool
$setting = true])
|
|
Make this object behave like Language::Guess
Parameters:
unicodeBlockName [line 935]
mixed unicodeBlockName(
mixed
$unicode)
|
|
Returns the block name for a given unicode value
If passed a string, will assume it is being passed a UTF8-formatted character and will automatically convert. Otherwise it will assume it is being passed a numeric unicode value.
Make sure input is of the correct type!
Parameters:
useUnicodeBlocks [line 457]
void useUnicodeBlocks(
[bool
$setting = true])
|
|
Whether to use unicode block ranges in detection
Should speed up most detections if turned on (detault is on). In some circumstances it may be slower, such as for large text samples (> 10K) in languages that use latin scripts. In other cases it should speed up detection noticeably.
Parameters:
utf8strlen [line 1476]
int utf8strlen(
string
$str)
|
|
ut8-safe strlen()
Returns the numbers of characters (not bytes) in a utf8 string
Parameters:
_arr_rank [line 493]
array _arr_rank(
array
$arr)
|
|
Converts a set of trigrams from frequencies to ranks
Thresholds (cuts off) the list at $this->_threshold
Parameters:
_read_unicode_block_db [line 1033]
array _read_unicode_block_db(
)
|
|
Brings up the unicode block database
_unicode_block_name [line 980]
mixed _unicode_block_name(
int
$unicode, array
$blocks, [int
$block_count = -1])
|
|
Searches the unicode block database
Returns the block name for a given unicode value. unicodeBlockName() is the public interface for this function, which does input checks which this function omits for speed.
Parameters:
_utf8char2unicode [line 1495]
int _utf8char2unicode(
string
$char)
|
|
Returns the unicode value of a utf8 char
Parameters: