检查命令行上包含一个时期字符(dot)字符的单词的拼写

发布于 2025-01-20 11:37:44 字数 981 浏览 2 评论 0原文

我正在尝试让我们的 CI/CD 管道对网站进行拼写检查。为了使其发挥作用,我们需要一个包含正确单词(例如产品名称)的自定义词典。我尝试了 Aspell 和 Hunspell,但在这两种情况下我都遇到了同样的问题 - 名称中带有句点,例如“Node.js”。它被认为是两个词:“Node”和“js”,其中第二个是不正确的。

我想列出这样的单词,以便它们被认为是正确的。一些注意事项:

  • 我不想添加单词“js”,因为它不是一个正确的单词(大写的“JS”是有效的缩写)。而且这只是一个例子。类似的化合物还可以有更多。
  • 设置应该封装在项目中,即不需要对主机环境进行自定义修改。

这是我到目前为止所拥有的(不起作用):

sample.txt 文件有一些拼写错误:

The cat was on the rooof with Fana. They were using Node.js to do their shtuff.

Aspell 的自定义词典 (custom.pws):

personal_ws-1.1 en 2
Fana
Node.js
$ aspell list --home-dir=. --personal=custom.pws sample.txt
Error: ./custom.pws: The word "Node.js" is invalid. The character '.' (U+2E) may not appear in the middle of a word.

Hunspell 的自定义词典 ( custom.dic):

Fana
Node.js
$ hunspell -p custom.dic -l sample.txt
rooof
js
shtuff

I'm trying to get our CI/CD pipeline to spell check a website. To make it work we need a custom dictionary of correct words e.g. names of products. I tried Aspell and Hunspell, but in both cases I've ran into the same problem - names with period in them, e.g. "Node.js". It's considered to be two words: "Node" and "js", where second is incorrect.

I'd like to make a list of words like that so they are considered correct. Some considerations:

  • I don't want to add word "js" as it is not a correct word (capitalized "JS" is a valid abbreviation). Also it's just an example. There can be more compounds like this.
  • The setup should be encapsulated in the project, i.e. require no custom modifications to the host environment.

Here's what I have so far (not working):

The sample.txt file with some spelling errors:

The cat was on the rooof with Fana. They were using Node.js to do their shtuff.

Custom dictionary for Aspell (custom.pws):

personal_ws-1.1 en 2
Fana
Node.js
$ aspell list --home-dir=. --personal=custom.pws sample.txt
Error: ./custom.pws: The word "Node.js" is invalid. The character '.' (U+2E) may not appear in the middle of a word.

Custom dictionary for Hunspell (custom.dic):

Fana
Node.js
$ hunspell -p custom.dic -l sample.txt
rooof
js
shtuff

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文