Détection du langage naturel pour GO.
Installation:
go get -u github.com/abadojack/whatlanggoExemple d'utilisation simple:
package main
import (
"fmt"
"github.com/abadojack/whatlanggo"
)
func main () {
info := whatlanggo . Detect ( "Foje funkcias kaj foje ne funkcias" )
fmt . Println ( "Language:" , info . Lang . String (), " Script:" , whatlanggo . Scripts [ info . Script ], " Confidence: " , info . Confidence )
} package main
import (
"fmt"
"github.com/abadojack/whatlanggo"
)
func main () {
//Blacklist
options := whatlanggo. Options {
Blacklist : map [whatlanggo. Lang ] bool {
whatlanggo . Ydd : true ,
},
}
info := whatlanggo . DetectWithOptions ( "האקדמיה ללשון העברית" , options )
fmt . Println ( "Language:" , info . Lang . String (), "Script:" , whatlanggo . Scripts [ info . Script ])
//Whitelist
options1 := whatlanggo. Options {
Whitelist : map [whatlanggo. Lang ] bool {
whatlanggo . Epo : true ,
whatlanggo . Ukr : true ,
},
}
info = whatlanggo . DetectWithOptions ( "Mi ne scias" , options1 )
fmt . Println ( "Language:" , info . Lang . String (), " Script:" , whatlanggo . Scripts [ info . Script ])
}Pour plus de détails, veuillez consulter la documentation.
Aller 1,8 ou plus
L'algorithme est basé sur les modèles de langue trigramme, qui est un cas particulier de n-grammes. Pour comprendre l'idée, veuillez consulter le livre blanc Cavnar et Trenkle '94: catégorisation de texte basée sur N-GRAM '.
Il est basé sur les facteurs suivants:
rate dans la base de code.Par conséquent, il peut être présenté comme un espace 2D avec des fonctions de seuil, qui le divise en zones "fiables" et "non fiables". Cette fonction est une hyperbole et elle ressemble à la suivante:
Pour plus de détails, veuillez consulter un article de blog Introduction à Rust Whatlang Library and Natural Language Identification Algorithms.
Mit
Whatlanggo est un dérivé de Franc (JavaScript, MIT) de Titus Wormer.
Merci à Greyblake (Potapov Sergey) pour avoir créé Whatlang-RS à partir de l'endroit où j'ai eu l'idée et les algorithmes.