跳转到主要内容

JupyterLab的拼写检查器。

项目描述

jupyterlab-spellchecker

Extension status Github Actions Status Binder PyPI version Conda version

这是一个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.affpl_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

从哪里获取字典?

一些字典的良好来源包括

使用在线字典

另一种将字典保存在您自己的磁盘上的方法(或者更准确地说,在 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 一起安装。您可以使用 yarnnpm 替代下面的 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 (5.4 MB 查看哈希值)

上传时间

构建分发

jupyterlab_spellchecker-0.8.4-py3-none-any.whl (5.3 MB 查看哈希值)

上传时间 Python 3

由以下组织支持