From f7bfa4367218879977757ad2b6ae5482201d23dd Mon Sep 17 00:00:00 2001 From: Evgeniy Sokolov Date: Sat, 16 Jan 2016 21:32:42 +0100 Subject: [PATCH 1/7] AOT dictionary --- test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test.txt diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..3d00b06 --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +баббаб \ No newline at end of file From 516da1513525c3bbe4bb8430a76f16af1833d8d9 Mon Sep 17 00:00:00 2001 From: Evgeniy Sokolov Date: Sat, 16 Jan 2016 21:39:48 +0100 Subject: [PATCH 2/7] AOT dict to travis addded --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f736de2..4effc25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ before_install: - sudo apt-get -qq update - sudo apt-get install -y hunspell hunspell-ru hunspell-en-us - + - curl -s http://extensions.libreoffice.org/extension-center/russian-spellcheck-dictionary.-based-on-works-of-aot-group | grep -oP "http://extensions.libreoffice.org/extension-center/russian-spellcheck-dictionary.-based-on-works-of-aot-group/pscre[^\"]+" | sort -r | head -1 | wget -q -i - -O dictionary.otx + - unzip dictionary.otx script: - - git diff HEAD^ | hunspell -d ru_RU,en_US | grep "^&" + - git diff HEAD^ | hunspell -d russian-aot,en_US | grep "^&" notifications: email: false From e7b7090f4285d41e4a072832f7bdf85b69541a6a Mon Sep 17 00:00:00 2001 From: Evgeniy Sokolov Date: Tue, 19 Jan 2016 00:38:49 +0100 Subject: [PATCH 3/7] spell-checker --- .travis.sh | 26 +++++++++++++++++++++ spell-checker.go | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 .travis.sh create mode 100644 spell-checker.go diff --git a/.travis.sh b/.travis.sh new file mode 100644 index 0000000..2c3d6b3 --- /dev/null +++ b/.travis.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +go build spell-checker.go + +EXIT_CODE=0 + +git diff HEAD^ --name-only > changed_files + +while read FILE; do + echo -n "Проверка файла $FILE на опечатки... "; + + OUTPUT_RU=$(cat "$FILE" | hunspell -d ru_RU | ./spell-checker); + RU_EXIT_CODE=$? + OUTPUT_EN=$(cat "$FILE" | hunspell -d en_US | ./spell-checker); + EN_EXIT_CODE=$? + + if [ $RU_EXIT_CODE -ne 0 ] || [ $EN_EXIT_CODE -ne 0 ]; then + EXIT_CODE=1; + echo "ошибка"; + echo "$OUTPUT_RU\n$OUTPUT_EN" | sort -n -k1,4; + else + echo "пройдена"; + fi +done < changed_files + +exit $EXIT_CODE \ No newline at end of file diff --git a/spell-checker.go b/spell-checker.go new file mode 100644 index 0000000..f946ba5 --- /dev/null +++ b/spell-checker.go @@ -0,0 +1,59 @@ +package main + +import ( + "fmt" + "os" + "bufio" +) + + +type TypeResult struct { + results []Result +} + +type Result struct { + line int + word string +} + +func main() { + scanner := bufio.NewScanner(os.Stdin) + types := parseHunspellOutput(scanner); + + _, ok := types["&"] + + if ok { + for _, result := range types["&"].results { + fmt.Println("Строка " + fmt.Sprintf("%v", result.line) + ":" + result.word) + } + + os.Exit(1) + } +} + +func parseHunspellOutput(scanner *bufio.Scanner) map[string]*TypeResult { + line := 1; + types := make(map[string]*TypeResult) + + scanner.Scan() + + for scanner.Scan() { + text := scanner.Text() + + if text == "" { + line++; + } else { + resultType := text[0:1] + typeResult, ok := types[resultType] + + if !ok { + typeResult = &TypeResult{} + types[resultType] = typeResult + } + + typeResult.results = append(typeResult.results, Result{line: line, word: text[1:]}) + } + } + + return types +} \ No newline at end of file From d130bc59b98e41a67b35a86a133a24c44a731018 Mon Sep 17 00:00:00 2001 From: Evgeniy Sokolov Date: Tue, 19 Jan 2016 00:38:53 +0100 Subject: [PATCH 4/7] spell-checker --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4effc25..b87a832 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ before_install: - curl -s http://extensions.libreoffice.org/extension-center/russian-spellcheck-dictionary.-based-on-works-of-aot-group | grep -oP "http://extensions.libreoffice.org/extension-center/russian-spellcheck-dictionary.-based-on-works-of-aot-group/pscre[^\"]+" | sort -r | head -1 | wget -q -i - -O dictionary.otx - unzip dictionary.otx script: - - git diff HEAD^ | hunspell -d russian-aot,en_US | grep "^&" + - ./.travis.sh notifications: email: false From 750f401918fd7c75a329381c3626c783c5cb5dd8 Mon Sep 17 00:00:00 2001 From: Evgeniy Sokolov Date: Tue, 19 Jan 2016 00:41:39 +0100 Subject: [PATCH 5/7] right call of travis.sh --- test.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 test.txt diff --git a/test.txt b/test.txt deleted file mode 100644 index 3d00b06..0000000 --- a/test.txt +++ /dev/null @@ -1 +0,0 @@ -баббаб \ No newline at end of file From 08fc02d4867ef191ae3a7d3421dfefec9a83c266 Mon Sep 17 00:00:00 2001 From: Evgeniy Sokolov Date: Tue, 19 Jan 2016 00:41:42 +0100 Subject: [PATCH 6/7] right call of travis.sh --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b87a832..cd8edb8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ before_install: - curl -s http://extensions.libreoffice.org/extension-center/russian-spellcheck-dictionary.-based-on-works-of-aot-group | grep -oP "http://extensions.libreoffice.org/extension-center/russian-spellcheck-dictionary.-based-on-works-of-aot-group/pscre[^\"]+" | sort -r | head -1 | wget -q -i - -O dictionary.otx - unzip dictionary.otx script: - - ./.travis.sh + - sh travis.sh notifications: email: false From 2c142888ba8e969d0c237a7305ec22c6fd6ff7a5 Mon Sep 17 00:00:00 2001 From: Evgeniy Sokolov Date: Tue, 19 Jan 2016 00:45:02 +0100 Subject: [PATCH 7/7] right call of travis.sh --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cd8edb8..b072a64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ before_install: - curl -s http://extensions.libreoffice.org/extension-center/russian-spellcheck-dictionary.-based-on-works-of-aot-group | grep -oP "http://extensions.libreoffice.org/extension-center/russian-spellcheck-dictionary.-based-on-works-of-aot-group/pscre[^\"]+" | sort -r | head -1 | wget -q -i - -O dictionary.otx - unzip dictionary.otx script: - - sh travis.sh + - sh .travis.sh notifications: email: false