Skip to content

Commit

Permalink
usage of languagetool 3.3; released 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lindt committed Apr 22, 2016
1 parent 2e49696 commit 4f7ee96
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 3 additions & 3 deletions features/exception.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions features/report.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions gherkin_language.gemspec
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
2 changes: 1 addition & 1 deletion lib/gherkin_language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions lib/gherkin_language/language_tool_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 == "<!--\n"
output << line
line = p.readline
begin
line = p.readline
rescue EOFError
break
end
end
p.close
end
Expand Down

0 comments on commit 4f7ee96

Please sign in to comment.