检测文本的语言。
† - 基于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