fune/extensions/spellcheck/locales/en-US/hunspell/dictionary-sources/edit-dictionary.sh
Francesco Lodolo (:flod) 7afa41bb66 Bug 1806793 - Update scripts for en-US dictionary, r=sylvestre
Added .sh extension to all scripts.

edit-dictionary.sh:
* Convert to utf-8 before editing, and back to iso-8859-1 before saving
* Place a copy of the utf-8 dictionary inside the utf8 folder, and store the iso-8859-1 in place

make-new-dict.sh:
* Use .txt extension for support wordlists, and place them in a subfolder
* Exclude words in mozilla-exclusions.txt from the generated dictionary
* Save 5-mozilla-*.txt files to utf-8

Depends on D165304

Differential Revision: https://phabricator.services.mozilla.com/D165305
2022-12-28 15:06:25 +00:00

37 lines
1.1 KiB
Bash
Executable file

#! /usr/bin/env sh
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
set -e
if [ -z "$EDITOR" ]; then
echo 'Need to set the $EDITOR environment variable to your favorite editor.'
exit 1
fi
# Copy the current en-US dictionary and strip the first line that contains
# the count.
tail -n +2 ../en-US.dic > en-US.stripped
# Convert the file to UTF-8
iconv -f iso-8859-1 -t utf-8 en-US.stripped > en-US.utf8
rm en-US.stripped
# Open the hunspell dictionary and let the user edit it
echo "Now the dictionary is going to be opened for you to edit. Quit the editor to finish editing."
echo "Press Enter to begin."
read foo
$EDITOR en-US.utf8
# Add back the line count and sort the lines
wc -l < en-US.utf8 | tr -d '[:blank:]' > en-US.dic
LC_ALL=C sort en-US.utf8 >> en-US.dic
rm -f en-US.utf8
# Convert back to ISO-8859-1
iconv -f utf-8 -t iso-8859-1 en-US.dic > ../en-US.dic
# Keep a copy of the UTF-8 file in /utf8
mv en-US.dic utf8/en-US-utf8.dic