ตรวจจับภาษาของข้อความ
† - ขึ้นอยู่กับ UDHR ซึ่งเป็นเอกสารที่ไม่มีลิขสิทธิ์ที่แปลมากที่สุดในโลก
ฟรังก์ รองรับหลายภาษาซึ่งหมายความว่ามันสับสนกับตัวอย่างขนาดเล็กได้ง่าย ตรวจสอบให้แน่ใจว่าได้ส่งผ่านเอกสารขนาดใหญ่เพื่อให้ได้ผลลัพธ์ที่เชื่อถือได้
หมายเหตุ : สิ่งนี้ติดตั้งแพ็คเกจ
francโดยรองรับ 187 ภาษา (ภาษาที่มีลำโพง 1 ล้านตัวขึ้นไป)franc-min(82 ภาษา, ลำโพง 8m ขึ้นไป) และfranc-all(ทั้งหมด 414 ภาษาที่เป็นไปได้) ก็มีให้เลือกเช่นกัน ในที่สุดใช้franc-cliเพื่อติดตั้ง CLI
แพ็คเกจนี้เป็น ESM เท่านั้น ใน node.js (เวอร์ชัน 14.14+, 16.0+) ติดตั้งด้วย NPM:
npm install franc ใน Deno กับ esm.sh :
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 ตัวเลือก) - การกำหนดค่า อาร์เรย์ที่มีภาษา - tupple ระยะไกล ( 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 | - |
หมายเหตุ : Franc ส่งคืนรหัส 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 แต่โปรดทราบว่าไม่สามารถแสดงรหัส 639-3 ทั้งหมดใน 639-1
แพ็คเกจเหล่านี้พิมพ์เต็มด้วย typeScript พวกเขาส่งออกประเภทเพิ่มเติม TrigramTuple และ Options
อย่างน้อยแพ็คเกจเหล่านี้เข้ากันได้กับ Node.js ทุกรุ่นที่ได้รับการบำรุงรักษาทั้งหมด ณ ตอนนี้นั่นคือ node.js 14.14+ และ 16.0+ พวกเขายังทำงานใน Deno และ Modern Browsers
ฟรังก์ได้ถูกส่งไปยังภาษาการเขียนโปรแกรมอื่น ๆ อีกหลายภาษา
paasaaefrancfranco , whatlanggofrancwhatlang-rsfrancdpyfrancผลงานฟรังก์นั้นได้มาจากตัวเองก็ถูกส่งไปยังภาษาอื่น ๆ
ฟรังก์เป็นงานอนุพันธ์จาก Guess-Language (Python, LGPL), GuessLanguage (C ++, LGPL) และภาษา :: Guess (Perl, GPL) ผู้สร้างของพวกเขาให้สิทธิ์แก่ฉันในการแจกจ่ายฟรังก์ภายใต้ใบอนุญาต MIT: ตามลำดับ Kent S. Johnson, Jacob R. Rideout และ Maciej Ceglowski
ได้โปรด! ดูวิธีการมีส่วนร่วมในโอเพ่นซอร์ส
แพ็คเกจนี้ปลอดภัย
MIT © Titus Wormer