spellcheck 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/examples/example.md +3 -0
- data/examples/sample.md +17 -0
- data/exe/spellcheck +18 -0
- data/lib/spellcheck.rb +10 -0
- data/lib/spellcheck/cli.rb +17 -0
- data/lib/spellcheck/color_string.rb +27 -0
- data/lib/spellcheck/filter.rb +21 -0
- data/lib/spellcheck/patterns/en/start_with_A.yml +517 -0
- data/lib/spellcheck/patterns/en/start_with_B.yml +169 -0
- data/lib/spellcheck/patterns/en/start_with_C.yml +525 -0
- data/lib/spellcheck/patterns/en/start_with_D.yml +311 -0
- data/lib/spellcheck/patterns/en/start_with_E.yml +293 -0
- data/lib/spellcheck/patterns/en/start_with_F.yml +220 -0
- data/lib/spellcheck/patterns/en/start_with_G.yml +113 -0
- data/lib/spellcheck/patterns/en/start_with_H.yml +145 -0
- data/lib/spellcheck/patterns/en/start_with_I.yml +337 -0
- data/lib/spellcheck/patterns/en/start_with_J.yml +33 -0
- data/lib/spellcheck/patterns/en/start_with_K.yml +23 -0
- data/lib/spellcheck/patterns/en/start_with_L.yml +121 -0
- data/lib/spellcheck/patterns/en/start_with_M.yml +235 -0
- data/lib/spellcheck/patterns/en/start_with_N.yml +107 -0
- data/lib/spellcheck/patterns/en/start_with_O.yml +208 -0
- data/lib/spellcheck/patterns/en/start_with_P.yml +439 -0
- data/lib/spellcheck/patterns/en/start_with_Q.yml +36 -0
- data/lib/spellcheck/patterns/en/start_with_R.yml +273 -0
- data/lib/spellcheck/patterns/en/start_with_S.yml +555 -0
- data/lib/spellcheck/patterns/en/start_with_T.yml +234 -0
- data/lib/spellcheck/patterns/en/start_with_U.yml +158 -0
- data/lib/spellcheck/patterns/en/start_with_V.yml +128 -0
- data/lib/spellcheck/patterns/en/start_with_W.yml +84 -0
- data/lib/spellcheck/patterns/en/start_with_X.yml +2 -0
- data/lib/spellcheck/patterns/en/start_with_Y.yml +14 -0
- data/lib/spellcheck/patterns/en/start_with_Z.yml +2 -0
- data/lib/spellcheck/proof_reader.rb +29 -0
- data/lib/spellcheck/report.rb +52 -0
- data/lib/spellcheck/typo.rb +18 -0
- data/lib/spellcheck/version.rb +3 -0
- data/spellcheck.gemspec +31 -0
- 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,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
|
data/spellcheck.gemspec
ADDED
@@ -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: []
|