JupyterLab的拼写检查器。
项目描述
jupyterlab-spellchecker
这是一个JupyterLab扩展,用于在笔记本中的Markdown单元格和文本文件中突出显示拼写错误的单词。
此JupyterLab扩展基于拼写检查器Jupyter Notebook扩展,并依赖于Typo.js进行实际的拼写检查。拼写检查建议可在上下文菜单中找到。可以自定义突出显示的样式在《高级设置编辑器》中。
您可以通过点击状态栏项来
- 更改语言
- 在当前文档中启用拼写检查
可以在设置中配置代码中的注释和字符串的拼写检查。
此扩展提供了 (Hunspell) SCOWL 字典,用于
- 美国、英国、加拿大和澳大利亚英语
- 法语
- 德语(德国、奥地利、瑞士)
- 葡萄牙语
- 西班牙语
并且还将使用安装在 已知路径 上的 Hunspell 字典,这些路径因操作系统而异。如果您在运行在不同计算机上的浏览器中运行 JupyterLab,请注意,字典需要在服务器机器上安装。
您可以通过将 Hunspell 文件放置在 dictionaries
文件夹中的一个 data
位置(由以下返回)中来添加自定义字典:
jupyter --paths
您应该放置两个具有扩展名 .aff
和 .dic
的文件,并按以下 BCP 47 标准命名。有关更多详细信息,请参阅下面的 示例。
JupyterLab 版本
此扩展已测试至 JupyterLab 版本 4.0。
安装
对于 JupyterLab 3.x 和 4.x
pip install jupyterlab-spellchecker
或
conda install -c conda-forge jupyterlab-spellchecker
对于 JupyterLab 2.x
jupyter labextension install @ijmbarr/jupyterlab_spellchecker
添加字典 - 示例
如果 jupyter --paths
看起来像
config:
/home/your_name/.jupyter
/usr/local/etc/jupyter
/etc/jupyter
data:
/home/your_name/.local/share/jupyter
/usr/local/share/jupyter
/usr/share/jupyter
runtime:
/home/your_name/.local/share/jupyter/runtime
并且您想添加波兰语,您将 pl_PL.aff
和 pl_PL.dic
放在 /home/your_name/.local/share/jupyter/dictionaries
中(您需要创建此文件夹),以便最终结构类似于
/home/your_name/.local/share/jupyter
├── dictionaries
│ ├── pl_PL.aff
│ └── pl_PL.dic
├── kernels
│ └── julia-1.5
│ ├── kernel.json
│ ├── logo-32x32.png
│ └── logo-64x64.png
├── nbconvert
│ └── templates
│ ├── html
│ └── latex
├── nbsignatures.db
├── notebook_secret
└── runtime
从哪里获取字典?
一些字典的良好来源包括
- LibreOffice/dictionaries GitHub 仓库
- Chromium 仓库
- (如果您知道其他质量资源,请发送 PR 以将其添加到此处)
使用在线字典
另一种将字典保存在您自己的磁盘上的方法(或者更准确地说,在 jupyter-server 设置的磁盘上)是从远程 URL 获取字典。这需要互联网连接来加载字典(每次打开 JupyterLab 或更改字典时),如果您无法在磁盘上保存字典(例如,当使用由他人配置的 JupyterHub 上的 JupyterLab 时),这可能很有用。
要配置在线字典,请转到 高级设置编辑器 → 拼写检查器 并将 onlineDictionaries
设置为以下示例中的 JSON 对象数组
[
{
"id": "en_US-online",
"aff": "https://cdn.jsdelivr.net.cn/codemirror.spell-checker/latest/en_US.aff",
"dic": "https://cdn.jsdelivr.net.cn/codemirror.spell-checker/latest/en_US.dic",
"name": "My favorite variant of English"
}
]
贡献
开发安装
注意:您需要 NodeJS 来构建扩展包。
jlpm
命令是 JupyterLab 随附的 yarn 版本,它与 JupyterLab 一起安装。您可以使用 yarn
或 npm
替代下面的 jlpm
。
# Clone the repo to your local environment
# Change directory to the jupyterlab_spellchecker directory
# Install package in development mode
pip install -e .
# Link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# Rebuild extension Typescript source after making changes
jlpm run build
pip install pytest
您可以在不同的终端中同时监视源目录并运行 JupyterLab,以便监视扩展源的变化并自动重新构建扩展。
# Watch the source directory in one terminal, automatically rebuilding when needed
jlpm run watch
# Run JupyterLab in another terminal
jupyter lab
提交之前
确保 eslint 通过
jlpm run eslint:check
如果有任何问题,可能会通过以下方式自动修复
jlpm run eslint
运行测试
python -m pytest
项目详情
jupyterlab_spellchecker-0.8.4.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | e0722f00c795e8b5d60655ed475dd91a67fe7180c32ac891a50f38c7abc7684b |
|
MD5 | 0dc1521ec1cbd7dd77774b7d7762e69f |
|
BLAKE2b-256 | 97747f05f8ee3c9cb47f4f52ea08e5a56cf8e4ed154a39472330435f977db178 |
jupyterlab_spellchecker-0.8.4-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 2701999d6a826e0a54a12fa41c60b9ffef220ee267e78fe20144423dbcc6d6d8 |
|
MD5 | 52b5632447daf3ac92a268b2508b51a0 |
|
BLAKE2b-256 | 0854b3d575124fa9404ceef40728f205d033fe52cf417a2245c5d108afe728e8 |