| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # |
| 3 | # (C) 2008 Caolán McNamara <[email protected]> |
| 4 | # |
| 5 | # This program is free software; you can redistribute it and/or modify |
| 6 | # it under the terms of the GNU General Public License as published by |
| 7 | # the Free Software Foundation; either version 2 of the License, or |
| 8 | # (at your option) any later version. |
| 9 | # |
| 10 | # This program is distributed in the hope that it will be useful, |
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | # GNU General Public License for more details. |
| 14 | # |
| 15 | # You should have received a copy of the GNU General Public License |
| 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | # This creates a LANG_TERRITORY .aff & .dic from a wordlist. |
| 19 | # It is only a simple wordlist spellchecking dictionary output, no |
| 20 | # knowledge of language rules can be extrapolated to shrink the |
| 21 | # wordlist or provide .aff rules for extending wordstems |
| 22 | |
| 23 | if [scip-shell system . . `[`. $# -lt 2 ]; then |
| 24 | echoscip-shell system . . echo. "Usage: wordlist2hunspell wordlist_file locale" |
| 25 | echoscip-shell system . . echo. "e.g. wordlist2hunspell breton.words br_FR to create br_FR.dic and br_FR.aff in cwd" |
| 26 | exit 1 |
| 27 | fi |
| 28 | |
| 29 | export LANG=$2.utf8 |
| 30 | echoscip-shell system . . echo. "# A basic .aff for a raw wordlist, created through wordlist2hunspell" > $2.aff |
| 31 | echoscip-shell system . . echo. SET UTF-8 >> $2.aff |
| 32 | #see https://bugzilla.redhat.com/show_bug.cgi?id=462184 for the "C" hacks |
| 33 | echoscip-shell system . . echo. TRY `sedscip-shell system . . sed. 's/./&\n/g' $1 | sedscip-shell system . . sed. '/^$/dscip-shell filesystem . . `/^$/d`.' | LC_ALL=C sortscip-shell system . . sort. -n | LC_ALL=C uniqscip-shell system . . uniq. -c | LC_ALL=C sortscip-shell system . . sort. -rn | trscip-shell system . . tr. -s ' ' | cutscip-shell system . . cut. -d ' ' -f 3 | trscip-shell system . . tr. -d '\n'` >> $2.aff |
| 34 | catscip-shell system . . cat. $1 | sedscip-shell system . . sed. '/^$/dscip-shell filesystem . . `/^$/d`.' | wcscip-shell system . . wc. -l > $2.dic |
| 35 | LC_ALL=C sortscip-shell system . . sort. $1 | sedscip-shell system . . sed. '/^$/dscip-shell filesystem . . `/^$/d`.' >> $2.dic |
| 36 | |
| 37 | echoscip-shell system . . echo. Basic $2.dic and $2.aff created |