From 4f7ee96e249b4519f436f83fe6e8029f0679eaf8 Mon Sep 17 00:00:00 2001 From: stefan Date: Fri, 22 Apr 2016 11:28:42 +0200 Subject: [PATCH] usage of languagetool 3.3; released 0.2.0 --- Rakefile | 2 +- features/exception.feature | 6 +++--- features/report.feature | 8 ++++---- gherkin_language.gemspec | 6 +++--- lib/gherkin_language.rb | 2 +- lib/gherkin_language/language_tool_process.rb | 14 +++++++++----- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Rakefile b/Rakefile index a0d61a2..eda1d4f 100644 --- a/Rakefile +++ b/Rakefile @@ -18,7 +18,7 @@ task test: :cucumber desc 'Publishes the Gem' task push: :build do - sh 'gem push gherkin_language-0.1.4.gem' + sh 'gem push gherkin_language-0.2.0.gem' end desc 'Checks ruby style' diff --git a/features/exception.feature b/features/exception.feature index a85482e..5242043 100644 --- a/features/exception.feature +++ b/features/exception.feature @@ -21,7 +21,7 @@ Feature: Exception Given a file named "test.feature" with: """ Feature: Test - Scenario: Tag + Scenario: Scenario Given an test When execute Then pass @@ -36,7 +36,7 @@ Feature: Exception Given a file named "test.feature" with: """ Feature: Test - Scenario: Tag + Scenario: Scenario Given a test When exicute Then pass @@ -46,7 +46,7 @@ Feature: Exception """ [misspelling] MORFOLOGIK_RULE_EN_US Possible spelling mistake found - Context: Given a test when exicute then pass + Context: Test Scenario Given a test when exicute then pass Replacements: execute References: test.feature diff --git a/features/report.feature b/features/report.feature index 239ea88..5d2a556 100644 --- a/features/report.feature +++ b/features/report.feature @@ -22,7 +22,7 @@ Feature: Report Given a file named "test.feature" with: """ Feature: Test - Scenario: Tag + Scenario: Scenario Given an test When execute Then pass @@ -32,7 +32,7 @@ Feature: Report """ [misspelling] EN_A_VS_AN Use 'a' instead of 'an' if the following word doesn't start with a vowel sound, e.g. 'a sentence', 'a university' - Context: Given an test when execute then pass + Context: Test Scenario Given an test when execute then pass Replacements: a References: test.feature @@ -42,7 +42,7 @@ Feature: Report Given a file named "test.feature" with: """ Feature: Test - Scenario: Tag + Scenario: Scenario Given a test When exicute Then pass @@ -52,7 +52,7 @@ Feature: Report """ [misspelling] MORFOLOGIK_RULE_EN_US Possible spelling mistake found - Context: Given a test when exicute then pass + Context: Test Scenario Given a test when exicute then pass Replacements: execute References: test.feature 1 unknown words: exicute diff --git a/gherkin_language.gemspec b/gherkin_language.gemspec index c03a2a8..de90bb3 100644 --- a/gherkin_language.gemspec +++ b/gherkin_language.gemspec @@ -1,9 +1,9 @@ Gem::Specification.new do |s| s.name = 'gherkin_language' - s.version = '0.1.4' - s.date = '2016-02-28' + s.version = '0.2.0' + s.date = '2016-04-23' s.summary = 'Gherkin Language' - s.description = 'Check language and readability of Gherkin Files' + s.description = 'Check language of Gherkin Files' s.authors = ['Stefan Rohe'] s.homepage = 'http://github.com/funkwerk/gherkin_language/' s.files = `git ls-files`.split("\n") diff --git a/lib/gherkin_language.rb b/lib/gherkin_language.rb index 078ca8b..887d117 100644 --- a/lib/gherkin_language.rb +++ b/lib/gherkin_language.rb @@ -29,7 +29,7 @@ def initialize(no_cache = false, ngram = false, unknown_words = false) end @references = {} @line_to_reference = {} - @exceptions = %w(SENTENCE_FRAGMENT) # sentences starting with 'When' are perfectly fine in gherkin + @exceptions = %w(SENTENCE_FRAGMENT ENGLISH_WORD_REPEAT_BEGINNING_RULE) @ngram = ngram @unknown_words = unknown_words end diff --git a/lib/gherkin_language/language_tool_process.rb b/lib/gherkin_language/language_tool_process.rb index 10cabad..bcd925a 100644 --- a/lib/gherkin_language/language_tool_process.rb +++ b/lib/gherkin_language/language_tool_process.rb @@ -16,7 +16,7 @@ class LanguageToolProcess attr_accessor :errors, :unknown_words - VERSION = 'LanguageTool-3.2'.freeze + VERSION = 'LanguageTool-3.3'.freeze URL = "https://www.languagetool.org/download/#{VERSION}.zip".freeze NGRAM_VERSION = 'ngrams-en-20150817'.freeze NGRAM_URL = "https://languagetool.org/download/ngram-data/#{NGRAM_VERSION}.zip".freeze @@ -60,23 +60,27 @@ def start! Dir.chdir("#{@path}/#{VERSION}/") do command = 'java -jar languagetool-commandline.jar ' command += '--list-unknown ' if @check_unknown_words - command += '--api --language en-US ' + command += '--api --language en-us ' command += "--languagemodel #{@ngrams_path}" if @ngrams - @p = IO.popen("#{command} -", 'r+') + @p = IO.popen("#{command} - 2>&1", 'r+') end end def tag(sentences) output = '' Dir.chdir("#{@path}/#{VERSION}/") do - p = IO.popen('java -jar languagetool-commandline.jar --taggeronly --api --language en-US -', 'r+') + p = IO.popen('java -jar languagetool-commandline.jar --taggeronly --api --language en-US - 2>/dev/null', 'r+') sentences.each { |sentence| p.write sentence } p.close_write line = p.readline loop do break if line == "