檢測文本的語言。
† - 基於UDHR,這是世界上最不含版權的文檔。
Franc支持許多語言,這意味著它很容易在小樣本上混淆。確保將其大量文檔通過以獲得可靠的結果。
注意:這安裝了
franc軟件包,並支持187種語言(具有100萬或更多揚聲器的語言)。franc-min(82種語言,800萬揚聲器)和franc-all(所有414種可能的語言)也可用。最後,使用franc-cli安裝CLI。
此軟件包僅是ESM。在Node.js(版本14.14+,16.0+)中,使用NPM安裝:
npm install franc與esm.sh一起在Deno中:
import { franc , francAll } from 'https://esm.sh/franc@6'在帶有esm.sh的瀏覽器中:
< script type =" module " >
import { franc , francAll } from 'https://esm.sh/franc@6?bundle'
</ script > import { franc , francAll } from 'franc'
franc ( 'Alle menslike wesens word vry' ) //=> 'afr'
franc ( 'এটি একটি ভাষা একক IBM স্ক্রিপ্ট' ) //=> 'ben'
franc ( 'Alle menneske er fødde til fridom' ) //=> 'nno'
franc ( '' ) //=> 'und' (language code that stands for undetermined)
// You can change what’s too short (default: 10):
franc ( 'the' ) //=> 'und'
franc ( 'the' , { minLength : 3 } ) //=> 'sco'
console . log ( francAll ( 'Considerando ser essencial que os direitos humanos' ) )
//=> [['por', 1], ['glg', 0.771284519307895], ['spa', 0.6034146900423971], …123 more items]
console . log ( francAll ( 'Considerando ser essencial que os direitos humanos' , { only : [ 'por' , 'spa' ] } ) )
//=> [['por', 1 ], ['spa', 0.6034146900423971]]
console . log ( francAll ( 'Considerando ser essencial que os direitos humanos' , { ignore : [ 'spa' , 'glg' ] } ) )
//=> [['por', 1], ['cat', 0.5367251059928957], ['src', 0.47461899851037015], …121 more items] 該軟件包導出了標識符franc , francAll 。沒有默認導出。
franc(value[, options])獲取給定值的最可能的語言。
value ( string ) - 測試值options ( Options ,可選) - 配置最可能的語言( string )。
francAll(value[, options])獲取給定值的最可能的語言。
value ( string ) - 測試值options ( Options ,可選) - 配置包含語言的數組 - 距離元組( Array<[string, number]> )。
Options配置( Object ,可選)具有以下字段:
options.only允許的語言( Array<string> ,可選)。
options.ignore忽略的語言( Array<string> ,可選)。
options.minLength最小長度接受( number ,默認值: 10 )。
安裝:
npm install franc-cli --global使用:
CLI to detect the language of text
Usage: franc [options] <string>
Options:
-h, --help output usage information
-v, --version output version number
-m, --min-length <number> minimum length to accept
-o, --only <string> allow languages
-i, --ignore <string> disallow languages
-a, --all display all guesses
Usage:
# output language
$ franc "Alle menslike wesens word vry"
# afr
# output language from stdin (expects utf8)
$ echo "এটি একটি ভাষা একক IBM স্ক্রিপ্ট" | franc
# ben
# ignore certain languages
$ franc --ignore por,glg "O Brasil caiu 26 posições"
# src
# output language from stdin with only
$ echo "Alle mennesker er født frie og" | franc --only nob,dan
# nob
| 包裹 | 語言 | 演講者 |
|---|---|---|
franc-min | 82 | 8m或更多 |
franc | 187 | 1m或更多 |
franc-all | 414 | - |
注意:法郎返回ISO 639-3代碼(三個字母代碼)。不是ISO 639-1或ISO 639-2。另請參見GH-10和GH-30。
要獲取有關ISO 639-3表示的語言的更多信息,請使用iso-639-3 。還有一個索引可用於將ISO 639-3映射到ISO 639-1代碼, iso-639-3/to-1.json 。
這些軟件包已與打字稿完全鍵入。他們導出其他類型的TrigramTuple和Options 。
這些軟件包至少與所有維護的node.js的版本兼容。截至目前,Node.js 14.14+和16.0+。他們還在DeNo和現代瀏覽器中工作。
弗朗克(Franc)已被移植到其他幾種編程語言中。
paasaaefrancfranco , whatlanggofrancwhatlang-rsfrancdpyfranc法郎的作品源自本身也被移植到其他語言中。
弗朗克(Franc)是猜測語言(Python,LGPL),猜測(C ++,LGPL)和Language ::猜測(Perl,GPL)的衍生作品。他們的創作者授予我根據麻省理工學院許可證法郎分發法郎的權利:分別是肯特·J·約翰遜,雅各布·R·雷德(Jacob R. Ride)和Maciej Ceglowski。
是的,請!請參閱如何為開源做出貢獻。
這個包裝是安全的。
麻省理工學院©Titus Wormer