whatlanggo
1.0.0
自然語言檢測。
安裝:
go get -u github.com/abadojack/whatlanggo簡單用法示例:
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 ])
}有關更多詳細信息,請檢查文檔。
走1.8或更高
該算法基於Trigram語言模型,該模型是N-grams的一種特殊情況。要了解這個想法,請檢查原始的白皮書Cavnar和Trenkle '94:基於N-Gram的文本分類'。
它基於以下因素:
rate 。因此,可以將其作為具有閾值函數的2D空間,將其分為“可靠”和“不可靠”區域。該功能是一種雙曲線,看起來如下:
有關更多詳細信息,請查看博客文章Rust Whatlang庫和自然語言標識算法的簡介。
麻省理工學院
Whatlanggo是Titus Wormer的Franc(JavaScript,MIT)的衍生產品。
感謝Greyblake(Potapov Sergey)創建了從我獲得的想法和算法的Whatlang-Rs。