Module: Ronin::Support::Text::Typo
- Defined in:
- lib/ronin/support/text/typo.rb,
lib/ronin/support/text/typo/generator.rb,
lib/ronin/support/text/typo/exceptions.rb
Overview
Defined Under Namespace
Classes: Generator, NoTypoPossible
Constant Summary collapse
- OMIT_CHARS =
Typo generator that repeats characters.
Generator[ [/(?<=\w)ae(?=\w)/, 'e']
- REPEAT_CHARS =
Typo generator that repeats characters.
- SWAP_CHARS =
Typo generator that swaps neighboring characters.
- SWAP_SYMBOLS =
Typo generator that swaps different symbols.
- CHANGE_SUFFIX =
Typo generator that changes the suffix of words.
- DEFAULT =
Note:
Does not include the SWAP_SYMBOLS typo rules.
Default typo generator.
Generator.new( OMIT_CHARS.rules + REPEAT_CHARS.rules + SWAP_CHARS.rules + CHANGE_SUFFIX.rules )
Class Method Summary collapse
-
.change_suffix ⇒ Generator
Typo generator that changes the suffix of words.
-
.each_substitution(word, **kwargs) {|typoed| ... } ⇒ Enumerator
Enumerates over every typo mistake for the given word.
-
.generator(**kwargs) ⇒ Generator
Builds a set of typo substitution rules.
-
.omit_chars ⇒ Generator
Typo generator that repeats characters.
-
.repeat_chars ⇒ Generator
Typo generator that repeats characters.
-
.substitute(word, **kwargs) ⇒ String
Returns a random typo substitution for the given word.
-
.swap_chars ⇒ Generator
Typo generator that swaps neighboring characters.
-
.swap_symbols ⇒ Generator
Typo generator that swaps different symbols.
Class Method Details
.change_suffix ⇒ Generator
Typo generator that changes the suffix of words.
158 159 160 |
# File 'lib/ronin/support/text/typo.rb', line 158 def self.change_suffix CHANGE_SUFFIX end |
.each_substitution(word, **kwargs) {|typoed| ... } ⇒ Enumerator
Enumerates over every typo mistake for the given word.
263 264 265 |
# File 'lib/ronin/support/text/typo.rb', line 263 def self.each_substitution(word,**kwargs,&block) generator(**kwargs).each_substitution(word,&block) end |
.generator(**kwargs) ⇒ Generator
Builds a set of typo substitution rules.
184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/ronin/support/text/typo.rb', line 184 def self.generator(**kwargs) if kwargs.empty? DEFAULT else rules = [] rules.concat(OMIT_CHARS.rules) if kwargs[:omit_chars] rules.concat(REPEAT_CHARS.rules) if kwargs[:repeat_chars] rules.concat(SWAP_CHARS.rules) if kwargs[:swap_chars] rules.concat(SWAP_SYMBOLS.rules) if kwargs[:swap_symbols] rules.concat(CHANGE_SUFFIX.rules) if kwargs[:change_suffix] Generator.new(rules) end end |
.omit_chars ⇒ Generator
Typo generator that repeats characters.
114 115 116 |
# File 'lib/ronin/support/text/typo.rb', line 114 def self.omit_chars OMIT_CHARS end |
.repeat_chars ⇒ Generator
Typo generator that repeats characters.
125 126 127 |
# File 'lib/ronin/support/text/typo.rb', line 125 def self.repeat_chars REPEAT_CHARS end |
.substitute(word, **kwargs) ⇒ String
Returns a random typo substitution for the given word.
225 226 227 |
# File 'lib/ronin/support/text/typo.rb', line 225 def self.substitute(word,**kwargs) generator(**kwargs).substitute(word) end |
.swap_chars ⇒ Generator
Typo generator that swaps neighboring characters.
136 137 138 |
# File 'lib/ronin/support/text/typo.rb', line 136 def self.swap_chars SWAP_CHARS end |
.swap_symbols ⇒ Generator
Typo generator that swaps different symbols.
147 148 149 |
# File 'lib/ronin/support/text/typo.rb', line 147 def self.swap_symbols SWAP_SYMBOLS end |