inaka-sheldonErlang 拼写检查器

联合创作 · 2023-09-30 16:02

Sheldon 是一个非常简单的 Erlang 拼写检查器。当某些单词拼写错误时,Sheldon会建议正确的单词。该功能的灵感来自 Elixir 项目拼写检查

安装

注意 sheldon仅适用于 Erlang 21 或更高版本

  1. 克隆仓库
  2. rebar3 compile

用法

Erlang Shell

首先 Sheldon 是一个应用程序,需要启动。可以使用rebar3 shell来设置必要的路径,然后使用sheldon:start/0application:ensure_all_started(sheldon)来启动 Sheldon,但如果使用 Sheldon 作为依赖项,也可以让 OTP 从 your_app.app 文件中启动它。

Sheldon 只有两个主要方法,sheldon:check/1sheldon:check/2. 作为用户只需要使用这些。

1> sheldon:check("I want to check this correct text").
ok
2> sheldon:check("I want to check this misspeled text").
#{bazinga => <<"That's no reason to cry. One cries because one is sad. For example, I cry because others are stupid, and that ma"...>>,
  misspelled_words => [#{candidates => ["misspeed","misspelled"],
     line_number => 1,
     word => "misspeled"}]}

配置

sheldon:check/2工作原理与sheldon:check/1类似,但它接受配置参数。使用此 Conf 参数,我们可以对要检查的文本应用一些规则。这些规则是忽略单词、忽略模式和忽略块。

这是格式:

#{ ignore_words    => [string()]
 , ignore_patterns => [regex()]
 , ignore_blocks   => [ignore_block()]
 , adapters        => [adapter()]
 }.

依赖关系

  • Erlang/OTP 23+

 

浏览 4
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报