Giter Site home page Giter Site logo

codetypo's Introduction

codetypo

Word 等工具虽然支持拼写检查,但是对于代码拼写检查却无能为力。codetypo 支持对代码做拼写检查,同时保证缩写、简写不被当做拼写错误。

codetypo 工作流程如下:

image

codetypo 的字典是基于英语字典、linux 内核源码、linux 内核 Documentation、MySQL-6.0 源码生成。

(MySQL-6.0 里也有大量错别字>_<|)

parser.py

用于生成词典。例如用 parser.py 爬 linux 中所有的单词,作为词典。

每个 project 可能有大量自己专有词汇,可以在 material 目录下新建一个文件,专门记录之,这样可以尽可能少一些误报。

checker.py

用于检查源码是否有错别字。

快速入门

用 checker.py 来检查 oceanbase 源码中的错别字:

python checker.py oceanbase-3.1/src/

会看到类似下面的输出:

/code/oceanbase/src/clog/ob_ilog_storage.cpp
 pruge (suggestion: purge)
 betweent (suggestion: betweend)

/code/oceanbase/src/clog/ob_log_archive_and_restore_driver.cpp
 archvie (suggestion: archie)

/code/oceanbase/src/clog/ob_log_membership_task_mgr.cpp
 leadera (suggestion: leaders)
 cascad (suggestion: cascade)

高级用法:定制字典

字典文件是 spell.dict。下面讲如何定制字典文件

首先,下载几本英文小说,保存为 a.txt。一般来说,小说里都是字典里包含的正规词。

然后,下载 linux 源码,用它来生成一些计算机专有的特殊词:

python parser.py linux-kernel-6.0/ > b.txt

将 a.txt b.txt 合并成 spell.dict:

cat a.txt b.txt > spell.dict

最后,用 checker.py 来检查 oceanbase 源码中的错别字:

python checker.py oceanbase-3.1/src/

codetypo's People

Contributors

raywill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.