5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ruby で英語の typo を生成するコマンドを作った

Posted at

英語の typo を生成するコマンドを作りました。

ruby 2.0 以上で動く(はず)

インストール方法

gem install typogen

使用方法

typogen [word]

typogen sample

出力

ample
smple
saple
samle
sampe
sampl
asmple
smaple
sapmle
samlpe
sampel

こんな感じで渡された word に対して想定される typo パターンを出力してくれます。

プログラム内で使用したい場合は TypoGen::Typo.create を使用します。

irb(main):001:0> require 'typogen'
=> true
irb(main):002:0> TypoGen::Typo.create('sample')
=> ["ample", "smple", "saple", "samle", "sampe", "sampl", "asmple", "smaple", "sapmle", "samlpe", "sampel"]

実装している typo パターン

  • 1文字抜け (install -> intall)
  • 文字の入れ替わり (install -> nistall)
  • 語尾の発音が似てるものに置換 (creator -> creater)
5
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?