File size: 704 Bytes
24aaa76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
# Character 6-gram, modified Kneser-Ney, built with kenlm lmplz (kenlm 0.3.0 PyPI source, sha256 c4628bb9...; static-boost build on the login node).
# Usage: lm_build.sh [folder with train_text.txt]   (default DATA/outputs/r5/linedet/lm)
set -eu
DATA=/path/to/TURKIC_OCR_DATA
LM=${1:-$DATA/outputs/r5/linedet/lm}
BIN=$DATA/tmp/kenlm_build/build_static/bin
TMP=$DATA/tmp/lmplz_tmp_$$
mkdir -p $LM $TMP
cd $LM
ls -la train_text.txt
nice -n 5 $BIN/lmplz -o 6 -S 16G -T $TMP --discount_fallback < train_text.txt > char6.arpa
ls -la char6.arpa
$BIN/build_binary -q 8 -b 8 trie char6.arpa char6.klm
ls -la char6.klm
sha256sum char6.klm train_text.txt > char6.sha256
head -12 char6.arpa
rm -rf $TMP