mirror of
https://github.com/ru-de/faq.git
synced 2024-12-22 17:01:49 +00:00
add custom dictionary, minimum word length and better output
This commit is contained in:
parent
fd05826a5b
commit
a1d9ed43ce
@ -10,15 +10,17 @@ git diff HEAD^ --name-status | grep "^D" -v | awk '{print $2}' > changed_files
|
||||
while read FILE; do
|
||||
echo -n "Проверка файла $FILE на опечатки... ";
|
||||
|
||||
OUTPUT_RU=$(cat "$FILE" | hunspell -d ru_RU | $DIR/spell-checker);
|
||||
OUTPUT_RU=$(cat "$FILE" | hunspell -d russian-aot,en_US,de_DE,$DIR/dictionary | $DIR/spell-checker);
|
||||
RU_EXIT_CODE=$?
|
||||
OUTPUT_EN=$(cat "$FILE" | hunspell -d en_US | $DIR/spell-checker);
|
||||
OUTPUT_EN=$(cat "$FILE" | hunspell -d en_US,russian-aot,de_DE,$DIR/dictionary | $DIR/spell-checker);
|
||||
EN_EXIT_CODE=$?
|
||||
OUTPUT_DE=$(cat "$FILE" | hunspell -d de_DE,en_US,russian-aot,$DIR/dictionary | $DIR/spell-checker);
|
||||
DE_EXIT_CODE=$?
|
||||
|
||||
if [ $RU_EXIT_CODE -ne 0 ] || [ $EN_EXIT_CODE -ne 0 ]; then
|
||||
if [ $RU_EXIT_CODE -ne 0 ] || [ $EN_EXIT_CODE -ne 0 ] || [ $DE_EXIT_CODE -ne 0 ]; then
|
||||
EXIT_CODE=1;
|
||||
echo "ошибка";
|
||||
echo "$OUTPUT_RU\n$OUTPUT_EN" | sort -n -k2;
|
||||
echo "$OUTPUT_RU\n$OUTPUT_EN\n$OUTPUT_DE" | sort -n -k2 | uniq;
|
||||
else
|
||||
echo "пройдена";
|
||||
fi
|
||||
|
2
files/dictionary.dic
Normal file
2
files/dictionary.dic
Normal file
@ -0,0 +1,2 @@
|
||||
1
|
||||
StVzo
|
@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"bufio"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
||||
@ -23,11 +25,18 @@ func main() {
|
||||
_, ok := types["&"]
|
||||
|
||||
if ok {
|
||||
var dropCol = regexp.MustCompile(`^([^ ]+) \d+ \d+:(.*)$`)
|
||||
var minimumWord = regexp.MustCompile(`^[^ ]{3}`)
|
||||
exitCode := 0
|
||||
|
||||
for _, result := range types["&"].results {
|
||||
fmt.Println("Строка " + fmt.Sprintf("%v", result.line) + ":" + result.word)
|
||||
if minimumWord.MatchString(result.word) {
|
||||
exitCode = 1
|
||||
fmt.Println("Строка " + fmt.Sprintf("%v", result.line) + ": " + dropCol.ReplaceAllString(result.word, "$1 >$2"))
|
||||
}
|
||||
}
|
||||
|
||||
os.Exit(1)
|
||||
os.Exit(exitCode)
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,6 +53,7 @@ func parseHunspellOutput(scanner *bufio.Scanner) map[string]*TypeResult {
|
||||
line++;
|
||||
} else {
|
||||
resultType := text[0:1]
|
||||
|
||||
typeResult, ok := types[resultType]
|
||||
|
||||
if !ok {
|
||||
@ -51,7 +61,7 @@ func parseHunspellOutput(scanner *bufio.Scanner) map[string]*TypeResult {
|
||||
types[resultType] = typeResult
|
||||
}
|
||||
|
||||
typeResult.results = append(typeResult.results, Result{line: line, word: text[1:]})
|
||||
typeResult.results = append(typeResult.results, Result{line: line, word: strings.Trim(text[1:], " ")})
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user