spellcheck 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +6 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +4 -0
  7. data/README.md +41 -0
  8. data/Rakefile +6 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/examples/example.md +3 -0
  12. data/examples/sample.md +17 -0
  13. data/exe/spellcheck +18 -0
  14. data/lib/spellcheck.rb +10 -0
  15. data/lib/spellcheck/cli.rb +17 -0
  16. data/lib/spellcheck/color_string.rb +27 -0
  17. data/lib/spellcheck/filter.rb +21 -0
  18. data/lib/spellcheck/patterns/en/start_with_A.yml +517 -0
  19. data/lib/spellcheck/patterns/en/start_with_B.yml +169 -0
  20. data/lib/spellcheck/patterns/en/start_with_C.yml +525 -0
  21. data/lib/spellcheck/patterns/en/start_with_D.yml +311 -0
  22. data/lib/spellcheck/patterns/en/start_with_E.yml +293 -0
  23. data/lib/spellcheck/patterns/en/start_with_F.yml +220 -0
  24. data/lib/spellcheck/patterns/en/start_with_G.yml +113 -0
  25. data/lib/spellcheck/patterns/en/start_with_H.yml +145 -0
  26. data/lib/spellcheck/patterns/en/start_with_I.yml +337 -0
  27. data/lib/spellcheck/patterns/en/start_with_J.yml +33 -0
  28. data/lib/spellcheck/patterns/en/start_with_K.yml +23 -0
  29. data/lib/spellcheck/patterns/en/start_with_L.yml +121 -0
  30. data/lib/spellcheck/patterns/en/start_with_M.yml +235 -0
  31. data/lib/spellcheck/patterns/en/start_with_N.yml +107 -0
  32. data/lib/spellcheck/patterns/en/start_with_O.yml +208 -0
  33. data/lib/spellcheck/patterns/en/start_with_P.yml +439 -0
  34. data/lib/spellcheck/patterns/en/start_with_Q.yml +36 -0
  35. data/lib/spellcheck/patterns/en/start_with_R.yml +273 -0
  36. data/lib/spellcheck/patterns/en/start_with_S.yml +555 -0
  37. data/lib/spellcheck/patterns/en/start_with_T.yml +234 -0
  38. data/lib/spellcheck/patterns/en/start_with_U.yml +158 -0
  39. data/lib/spellcheck/patterns/en/start_with_V.yml +128 -0
  40. data/lib/spellcheck/patterns/en/start_with_W.yml +84 -0
  41. data/lib/spellcheck/patterns/en/start_with_X.yml +2 -0
  42. data/lib/spellcheck/patterns/en/start_with_Y.yml +14 -0
  43. data/lib/spellcheck/patterns/en/start_with_Z.yml +2 -0
  44. data/lib/spellcheck/proof_reader.rb +29 -0
  45. data/lib/spellcheck/report.rb +52 -0
  46. data/lib/spellcheck/typo.rb +18 -0
  47. data/lib/spellcheck/version.rb +3 -0
  48. data/spellcheck.gemspec +31 -0
  49. metadata +148 -0
@@ -0,0 +1,84 @@
1
+ ---
2
+ waht: what
3
+ warrent: warrant
4
+ wass: was
5
+ watchs: watches
6
+ watn: want
7
+ weakend: weakened
8
+ weaponary: weaponry
9
+ webcasted: webcast
10
+ webstie: website
11
+ wecked: wrecked
12
+ wehn: when
13
+ weilded: wielded
14
+ wel: well
15
+ welcame: welcomed
16
+ wendsay: Wednesday
17
+ wendsday: Wednesday
18
+ wensday: Wednesday
19
+ wesbite: website
20
+ whant: want
21
+ whants: wants
22
+ whcih: which
23
+ wheelbarrel: wheelbarrow
24
+ whent: went
25
+ wherabouts: whereabouts
26
+ wheras: whereas
27
+ wherby: whereby
28
+ whereever: wherever
29
+ wherin: wherein
30
+ whic: which
31
+ whihc: which
32
+ whilest: while
33
+ wholely: wholly
34
+ wholey: wholly
35
+ wholistic: holistic
36
+ wholley: wholly
37
+ whon: whom
38
+ whta: what
39
+ widht: width
40
+ witdh: width
41
+ wief: wife
42
+ wierd: weird
43
+ wiht: with
44
+ wihtin: within
45
+ wihtout: without
46
+ willingess: willingness
47
+ wirting: writing
48
+ Wisconson: Wisconsin
49
+ wistle: whistle
50
+ witchs: witches
51
+ withing: within
52
+ withold: withhold
53
+ withought: without
54
+ witht: with
55
+ witout: without
56
+ winows: windows
57
+ widnows: windows
58
+ windwos: windows
59
+ winodws: windows
60
+ Winsows: windows
61
+ wittness: witness
62
+ wiull: will
63
+ wnat: want
64
+ wnated: wanted
65
+ wnats: wants
66
+ wohle: whole
67
+ wokr: work
68
+ wokring: working
69
+ worlwide: worldwide
70
+ worsten: worsen
71
+ worstened: worsened
72
+ worstening: worsening
73
+ woudl: would
74
+ wreckless: reckless
75
+ wrecklessness: recklessness
76
+ wriet: write
77
+ writen: written
78
+ writter: writer
79
+ writting: writing
80
+ wroet: wrote
81
+ wrok: work
82
+ wroking: working
83
+ wtih: with
84
+ wupport: support
@@ -0,0 +1,2 @@
1
+ ---
2
+ XBox: Xbox
@@ -0,0 +1,14 @@
1
+ ---
2
+ yaer: year
3
+ yaht: yacht
4
+ yatch: yacht
5
+ yeasr: years
6
+ yeild: yield
7
+ yelow: yellow
8
+ yeras: years
9
+ yersa: years
10
+ yhe: the
11
+ Yorkhire: Yorkshire
12
+ youself: yourself
13
+ ytou: you
14
+ yuonger: younger
@@ -0,0 +1,2 @@
1
+ ---
2
+ zeebra: zebra
@@ -0,0 +1,29 @@
1
+ module SpellCheck
2
+ class ProofReader
3
+
4
+ # @param [String] content text data.
5
+ # @return [SpellCheck::Report] check result.
6
+ def self.check(content)
7
+ report = SpellCheck::Report.new
8
+
9
+ content.lines.each.with_index(1) do |line, line_number|
10
+
11
+ line.scan(/\w+/).each do |pattern|
12
+ line.chomp!
13
+ result = Filter.spellcheck(pattern)
14
+
15
+ next if result[:correct]
16
+
17
+ report.errata << Typo.new(
18
+ pattern: pattern,
19
+ expected: result[:expected],
20
+ line: line,
21
+ line_number: line_number
22
+ )
23
+ end
24
+ end
25
+
26
+ report
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,52 @@
1
+ module SpellCheck
2
+ class Report
3
+ attr_reader :errata
4
+
5
+ def initialize
6
+ @errata = []
7
+ end
8
+
9
+ def typo_count
10
+ @errata.size
11
+ end
12
+
13
+ def accept?
14
+ status == 'Accept'
15
+ end
16
+
17
+ def reject?
18
+ !accept?
19
+ end
20
+
21
+ def status
22
+ typo_count.zero? ? 'Accept' : 'Reject'
23
+ end
24
+
25
+ def to_s
26
+ [
27
+ results,
28
+ conclusions
29
+ ].join("\n\n")
30
+ end
31
+
32
+ private
33
+
34
+ def results
35
+ header = %w(Location Text Pattern Expected)
36
+ rows = errata.map do |typo|
37
+ [
38
+ typo.line_number,
39
+ typo.place,
40
+ ColorString.red(typo.pattern),
41
+ ColorString.green(typo.expected)
42
+ ]
43
+ end
44
+
45
+ Terminal::Table.new(headings: header, rows: rows)
46
+ end
47
+
48
+ def conclusions
49
+ ColorString.red("result: #{typo_count} typo found.")
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,18 @@
1
+ module SpellCheck
2
+ class Typo
3
+ attr_reader :pattern, :expected, :line, :line_number
4
+
5
+ def initialize(pattern: nil, expected: nil, line: nil, line_number: nil)
6
+ @pattern = pattern
7
+ @expected = expected
8
+ @line = line
9
+ @line_number = line_number
10
+ end
11
+
12
+ def place
13
+ m = line.match(/(?<before>.{0,20})#{pattern}(?<after>.{0,20})/)
14
+
15
+ [m[:before] || '', ColorString.red(pattern), m[:after] || ''].join
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module SpellCheck
2
+ VERSION = '0.3.0'
3
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'spellcheck/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "spellcheck"
8
+ spec.version = SpellCheck::VERSION
9
+ spec.authors = ["siman-man"]
10
+ spec.email = ["k128585@ie.u-ryukyu.ac.jp"]
11
+
12
+ spec.summary = %q{simple spell check script.}
13
+ spec.description = %q{simple spell check script.}
14
+ spec.homepage = "https://github.com/siman-man/spellcheck"
15
+ spec.license = 'MIT'
16
+ spec.required_ruby_version = '>= 2.2.0'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_dependency "terminal-table"
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.14"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rspec", "~> 3.5"
31
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spellcheck
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - siman-man
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-02-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: terminal-table
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.14'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.14'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.5'
69
+ description: simple spell check script.
70
+ email:
71
+ - k128585@ie.u-ryukyu.ac.jp
72
+ executables:
73
+ - spellcheck
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - CODE_OF_CONDUCT.md
81
+ - Gemfile
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - examples/example.md
87
+ - examples/sample.md
88
+ - exe/spellcheck
89
+ - lib/spellcheck.rb
90
+ - lib/spellcheck/cli.rb
91
+ - lib/spellcheck/color_string.rb
92
+ - lib/spellcheck/filter.rb
93
+ - lib/spellcheck/patterns/en/start_with_A.yml
94
+ - lib/spellcheck/patterns/en/start_with_B.yml
95
+ - lib/spellcheck/patterns/en/start_with_C.yml
96
+ - lib/spellcheck/patterns/en/start_with_D.yml
97
+ - lib/spellcheck/patterns/en/start_with_E.yml
98
+ - lib/spellcheck/patterns/en/start_with_F.yml
99
+ - lib/spellcheck/patterns/en/start_with_G.yml
100
+ - lib/spellcheck/patterns/en/start_with_H.yml
101
+ - lib/spellcheck/patterns/en/start_with_I.yml
102
+ - lib/spellcheck/patterns/en/start_with_J.yml
103
+ - lib/spellcheck/patterns/en/start_with_K.yml
104
+ - lib/spellcheck/patterns/en/start_with_L.yml
105
+ - lib/spellcheck/patterns/en/start_with_M.yml
106
+ - lib/spellcheck/patterns/en/start_with_N.yml
107
+ - lib/spellcheck/patterns/en/start_with_O.yml
108
+ - lib/spellcheck/patterns/en/start_with_P.yml
109
+ - lib/spellcheck/patterns/en/start_with_Q.yml
110
+ - lib/spellcheck/patterns/en/start_with_R.yml
111
+ - lib/spellcheck/patterns/en/start_with_S.yml
112
+ - lib/spellcheck/patterns/en/start_with_T.yml
113
+ - lib/spellcheck/patterns/en/start_with_U.yml
114
+ - lib/spellcheck/patterns/en/start_with_V.yml
115
+ - lib/spellcheck/patterns/en/start_with_W.yml
116
+ - lib/spellcheck/patterns/en/start_with_X.yml
117
+ - lib/spellcheck/patterns/en/start_with_Y.yml
118
+ - lib/spellcheck/patterns/en/start_with_Z.yml
119
+ - lib/spellcheck/proof_reader.rb
120
+ - lib/spellcheck/report.rb
121
+ - lib/spellcheck/typo.rb
122
+ - lib/spellcheck/version.rb
123
+ - spellcheck.gemspec
124
+ homepage: https://github.com/siman-man/spellcheck
125
+ licenses:
126
+ - MIT
127
+ metadata: {}
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: 2.2.0
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.6.10
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: simple spell check script.
148
+ test_files: []