JamSpell เป็นไลบรารีตรวจสอบการสะกดพร้อมคุณสมบัติดังต่อไปนี้:
ตัวอย่างโคลาบ
jamspell.com - ลองดู Jamspell เวอร์ชันใหม่พร้อมคุณสมบัติดังต่อไปนี้
en, ru, de, fr, it, es, tr, uk, pl, nl, pt, hi, noJava, C#, Ruby ในตัว| ข้อผิดพลาด | ข้อผิดพลาด 7 อันดับแรก | อัตราคงที่ | อัตราการแก้ไข 7 อันดับแรก | แตกหัก | ความเร็ว (คำ/วินาที) | |
| JamSpell | 3.25% | 1.27% | 79.53% | 84.10% | 0.64% | 4854 |
| นอร์วีก | 7.62% | 5.00% | 46.58% | 66.51% | 0.69% | 395 |
| ฮันสเปล | 13.10% | 10.33% | 47.52% | 68.56% | 7.14% | 163 |
| หุ่นเชิด | 13.14% | 13.14% | 0.00% | 0.00% | 0.00% | - |
โมเดลได้รับการฝึกฝนเกี่ยวกับประโยควิกิพีเดีย 300,000 ประโยค + ประโยคข่าว 300,000 ประโยค (ภาษาอังกฤษ) 95% ใช้สำหรับรถไฟ 5% ใช้สำหรับการประเมินผล มีการใช้โมเดลข้อผิดพลาดเพื่อสร้างข้อความที่มีข้อผิดพลาดจากต้นฉบับ ตัวแก้ไข JamSpell ถูกเปรียบเทียบกับของ Norvig, Hunspell และตัวจำลอง (ไม่มีการแก้ไข)
เราใช้ตัวชี้วัดต่อไปนี้:
เพื่อให้แน่ใจว่าแบบจำลองของเราไม่พอดีเกินไปสำหรับวิกิพีเดีย+ข่าว เราได้ตรวจสอบมันในข้อความ "The Adventures of Sherlock Holmes":
| ข้อผิดพลาด | ข้อผิดพลาด 7 อันดับแรก | อัตราคงที่ | อัตราการแก้ไข 7 อันดับแรก | แตกหัก | ความเร็ว (คำต่อวินาที) | |
| JamSpell | 3.56% | 1.27% | 72.03% | 79.73% | 0.50% | 5524 |
| นอร์วีก | 7.60% | 5.30% | 35.43% | 56.06% | 0.45% | 647 |
| ฮันสเปล | 9.36% | 6.44% | 39.61% | 65.77% | 2.95% | 284 |
| หุ่นเชิด | 11.16% | 11.16% | 0.00% | 0.00% | 0.00% | - |
รายละเอียดเพิ่มเติมเกี่ยวกับการสืบพันธุ์มีอยู่ในส่วน "รถไฟ"
ติดตั้ง swig3 (โดยปกติจะอยู่ในตัวจัดการแพ็คเกจ distro ของคุณ)
ติดตั้ง jamspell :
pip install jamspellดาวน์โหลดหรือฝึกโมเดลภาษา
ใช้มัน:
import jamspell
corrector = jamspell . TSpellCorrector ()
corrector . LoadLangModel ( 'en.bin' )
corrector . FixFragment ( 'I am the begt spell cherken!' )
# u'I am the best spell checker!'
corrector . GetCandidates ([ 'i' , 'am' , 'the' , 'begt' , 'spell' , 'cherken' ], 3 )
# (u'best', u'beat', u'belt', u'bet', u'bent', ... )
corrector . GetCandidates ([ 'i' , 'am' , 'the' , 'begt' , 'spell' , 'cherken' ], 5 )
# (u'checker', u'chicken', u'checked', u'wherein', u'coherent', ...) เพิ่ม jamspell และ contrib dirs ให้กับโปรเจ็กต์ของคุณ
ใช้มัน:
# include < jamspell/spell_corrector.hpp >
int main ( int argc, const char ** argv) {
NJamSpell::TSpellCorrector corrector;
corrector. LoadLangModel ( " model.bin " );
corrector. FixFragment ( L" I am the begt spell cherken! " );
// "I am the best spell checker!"
corrector. GetCandidates ({ L" i " , L" am " , L" the " , L" begt " , L" spell " , L" cherken " }, 3 );
// "best", "beat", "belt", "bet", "bent", ... )
corrector. GetCandidates ({ L" i " , L" am " , L" the " , L" begt " , L" spell " , L" cherken " }, 3 );
// "checker", "chicken", "checked", "wherein", "coherent", ... )
return 0 ;
} คุณสามารถสร้างส่วนขยายสำหรับภาษาอื่นได้โดยใช้บทช่วยสอน swig ไฟล์อินเทอร์เฟซ swig คือ jamspell.i ยินดีรับคำขอพุลพร้อมสคริปต์บิลด์
ติดตั้ง cmake
โคลนและสร้าง jamspell (รวมถึงเซิร์ฟเวอร์ http):
git clone https://github.com/bakwc/JamSpell.git
cd JamSpell
mkdir build
cd build
cmake ..
make./web_server/web_server en.bin localhost 8080$ curl " http://localhost:8080/fix?text=I am the begt spell cherken "
I am the best spell checker$ curl -d " I am the begt spell cherken " http://localhost:8080/fix
I am the best spell checkercurl " http://localhost:8080/candidates?text=I am the begt spell cherken "
# or
curl -d " I am the begt spell cherken " http://localhost:8080/candidates {
"results" : [
{
"candidates" : [
"best" ,
"beat" ,
"belt" ,
"bet" ,
"bent" ,
"beet" ,
"beit"
] ,
"len" : 4 ,
"pos_from" : 9
} ,
{
"candidates" : [
"checker" ,
"chicken" ,
"checked" ,
"wherein" ,
"coherent" ,
"cheered" ,
"cherokee"
] ,
"len" : 7 ,
"pos_from" : 20
}
]
} ที่นี่ pos_from - คำที่สะกดผิดตำแหน่งตัวอักษรตัวแรก len - คำที่สะกดผิด len
ในการฝึกโมเดลแบบกำหนดเอง คุณต้องมี:
ติดตั้ง cmake
โคลนและสร้าง jamspell:
git clone https://github.com/bakwc/JamSpell.git
cd JamSpell
mkdir build
cd build
cmake ..
make เตรียมไฟล์ข้อความ utf-8 พร้อมประโยคที่จะฝึก (เช่น sherlockholmes.txt ) และอีกไฟล์ที่มีตัวอักษรภาษา (เช่น alphabet_en.txt )
โมเดลรถไฟ:
./main/jamspell train ../test_data/alphabet_en.txt ../test_data/sherlockholmes.txt model_sherlock.binevaluate/evaluate.py : python evaluate/evaluate.py -a alphabet_file.txt -jsp your_model.bin -mx 50000 your_test_data.txtevaluate/generate_dataset.py เพื่อสร้างข้อมูลฝึกอบรม/ทดสอบได้ รองรับไฟล์ txt รูปแบบ Leipzig Corpora Collection และหนังสือ fb2 นี่คือโมเดลง่ายๆ บางส่วน พวกเขาฝึกฝนเกี่ยวกับข่าว 300,000 ประโยค + ประโยควิกิพีเดีย 300,000 ประโยค เราขอแนะนำอย่างยิ่งให้ฝึกโมเดลของคุณเอง อย่างน้อยสองสามล้านประโยคเพื่อให้ได้คุณภาพที่ดีขึ้น ดูส่วนรถไฟด้านบน