Smart.Framework Logo

final class \SmartModExtLib\LangDetect\LanguageNgrams
{ } ->

Class: LanguageNgrams - provides a Language Detection utility based on Text N-Grams that can be used to validate Language / GetLanguage Confidence for a text.


class Methods

public function __construct ( STRING $ngrams_path = "modules/mod-lang-detect/libs/data-1-3-930", ARRAY $lang = [] ) {} @ 
@param: {STRING} $ngrams_path: The path to the resources or NULL if only need to train
@param: {ARRAY} $lang: The Array of languages to detect for OR an empty array to try detect all available languages
Class Constructor
public function getLanguageConfidence ( STRING $str ) {} -> ARRAY
@return: {ARRAY} The detection result: [ service-available, lang-id, confidence-score, error-message ]
@param: {STRING} $str: The text to be checked
Detects and Get the Language Confidence information for the best detected Language (from the available list) for a given text
public function setMinLength ( INTEGER+ $minLength ) {} -> VOID
@return: {VOID}
@param: {INTEGER+} $minLength: Min Ngrams Length: Default is 1
Set the Ngrams Minimum Length
public function setMaxLength ( INTEGER+ $maxLength ) {} -> VOID
@return: {VOID}
@param: {INTEGER+} $maxLength: Max Ngrams Length: Default is 3
Set the Ngrams Maximum Length
public function setMaxNgrams ( INTEGER+ $maxNgrams ) {} -> VOID
@return: {VOID}
@param: {INTEGER+} $maxNgrams: Max Ngrams: Default is 310
Set the Maximum (significant) Ngrams

class Properties


class Constants


Sample code: PHP

<?php

$langtest 
= (new \SmartModExtLib\LangDetect\LanguageNgrams())->getLanguageConfidence('Your Text to Check Goes Here ...');

// #end php code


documentation generated on: 2023-10-19 23:15:58 +0000


Smart.Framework © 2009-2023 unix-world.org