Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spaced repeition #25

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,17 @@ description = "Remember all words in terminal!"
license = "GPL-2.0"
homepage = "https://github.com/vaaandark/dioxionary"
repository = "https://github.com/vaaandark/dioxionary"
build = "build.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[[bin]]
name = "dioxionary"
path = "src/main.rs"

[lib]
name = "dioxionary"
path = "src/lib.rs"
crate-type = ["lib"]

[dependencies]
reqwest = { version = "0.11.22", features = ["blocking", "default-tls"], default-features = false }
hyper = "1.0.1"
scraper = { default-features = false, version = "0.18.1" }
dirs = "5.0.1"
rusqlite = "0.30.0"
chrono = { features = ["clock"], default-features = false, version = "0.4" }
chrono = { features = ["clock", "serde"], default-features = false, version = "0.4" }
itertools = { default-features = false, version = "0.12.0" }
clap = { version = "4.4.8", features = ["derive", "help"], default-features = false }
prettytable = { default-features = false, version = "0.10.0" }
Expand All @@ -37,3 +29,22 @@ tokio = { version = "1.34.0", default-features = false }
rodio = "0.17.3"
clap_complete = "4.4.4"
anyhow = "1.0.75"
walkdir = "2.4.0"
crossterm = "0.27.0"
ratatui = "0.26.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.108"
strsim = "0.10.0"
pulldown-cmark-mdcat = "2.1.0"
mdcat = "2.1.0"
syntect = "5.1.0"
# pulldown-cmark-mdcat-ratatui = { path = "../mdcat-ratatui/pulldown-cmark-mdcat" , package = "pulldown-cmark-mdcat" }
pulldown-cmark-mdcat-ratatui = { git = "https://github.com/lengyijun/mdcat-ratatui" , branch = "ratatui", package = "pulldown-cmark-mdcat" }
shadow-rs = "0"

[dependencies.fsrs]
git = "https://github.com/open-spaced-repetition/fsrs-rs.git"
rev = "f45f46bdba6625f03677eaeb039dd8a6ffcad688"

[build-dependencies]
shadow-rs = "0"
129 changes: 0 additions & 129 deletions README-en.md

This file was deleted.

72 changes: 39 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,76 +5,78 @@

[简体中文](README.md) | [English](README-en.md)

使用 **离线** / **在线** 词典在终端中查单词、背单词!
Look up and memorize all words in terminal **offline** / **online**!

## 依赖
## Prerequisites

- sqlite3
- openssl

## 安装
## Installation

### 下载预构建二进制
### Download Prebuilt Binaries

推荐从右侧的 [Github Release](https://github.com/vaaandark/dioxionary/releases) 下载对应平台的二进制文件。
It is recommended to download the prebuilt binary file for your platform from the [Github Release](https://github.com/vaaandark/dioxionary/releases) on the right side.

也可以到 [GitHub Actions](https://github.com/vaaandark/dioxionary/actions?query=workflow%3A%22CI+build%22+actor%3Avaaandark+branch%3Amaster+event%3Apush+is%3Asuccess) 下载最新构建的二进制,包含 Linux 和 Windows 版本。
Alternatively, you can also download the latest build binaries, including Linux and Windows versions, from the [GitHub Actions](https://github.com/vaaandark/dioxionary/actions?query=workflow%3A%22CI+build%22+actor%3Avaaandark+branch%3Amaster+event%3Apush+is%3Asuccess).

### 自行编译
### Compile from source

```console
cargo install dioxionary
cargo install --git https://github.com/lengyijun/dioxionary --branch spaced_repetition_pr
```

## 使用
## Usage

![demo](images/demo.gif)

### 启用参数补全
[![asciicast](https://asciinema.org/a/630227.svg)](https://asciinema.org/a/630227)

### Enable argument completion

```console
$ eval "$(dioxionary -c bash)" # for bash
$ eval "$(dioxionary -c zsh)" # for zsh
$ eval "$(dioxionary -c fish)" # for fish
```

可以将上述命令直接写到 shell 的配置文件中。
You can write the above commands directly into the configuration file of your shell.

### 查询单词
### Look up word meaning

```console
$ dioxionary lookup [OPTIONS] [WORD]
```

子命令 `lookup` 可以省略:
The subcommand `lookup` can be omitted:

```console
$ dioxionary [OPTIONS] [WORD]
```

当参数中没有待查单词时,将进入交互模式,可以无限查询,直至按下 `Ctrl+D`
When there is no word to be searched in the parameter, it will enter the interactive mode, and can search infinitely until `Ctrl+D` is pressed.

支持并默认使用模糊搜索(fuzzy search),在词典中没有找到单词时会输出最相似的一个或多个单词的释义。
Supports and uses fuzzy search by default. When no word is found in the dictionary, it will output the most similar definition of one or more words.

使用 `-e` 或者 `--exact-search` 可以关闭模糊搜索。也可以通过在单词前添加 `/` 或者 `|` 来打开或关闭模糊搜索,在单词前添加 `@` 使用网络词典。
Use `-e` or `--exact-search` to turn off fuzzy search. You can also turn fuzzy search on or off by prefixing a word with `/` or `|`, and use web dictionaries with `@` before a word.

```console
$ dioxionary /terraria # 模糊搜索
$ dioxionary '|terraria' # 非模糊搜索,注意使用引号
$ dioxionary @terraria # 使用网络词典
$ dioxionary /terraria # Fuzzy search
$ dioxionary '|terraria' # Non-fuzzy search, pay attention to use quotation marks
$ dioxionary @terraria # Online search
```

默认使用本地词典,本地词典目录应当存放在:
The local dictionary is used by default, and the local dictionary directory should be stored in:

|Platform | Value | Example |
| ------- | ------------------------------------------------- | ---------------------------------------------- |
| Linux | `$XDG_CONFIG_HOME/dioxionary` or `$HOME`/.config/dioxionary | /home/alice/.config/dioxionary |
| macOS | `$HOME`/Library/Application Support/dioxionary | /Users/Alice/Library/Application Support/dioxionary |
| Windows | `{FOLDERID_RoamingAppData}`/dioxionary | C:\Users\Alice\AppData\Roaming/dioxionary |

> 只支持 stardict 的词典格式
> Only stardict dictionary format is supported

> 可以在 http://download.huzheng.org/ 下载 stardict 格式词典
> You can download dictionaries in stardict format at http://download.huzheng.org/

```plain
~/.config/dioxionary
Expand All @@ -91,38 +93,42 @@ $ dioxionary @terraria # 使用网络词典
└── cdict-gb.ifo
```

使用 `-x` 选项会使用在线词典查询:
Using the `-x` option will use an online dictionary lookup:

```console
$ dioxionary -x <DICTDIR> <WORD>
```

可以使用 `-l` 或 `--local` 选项指定词典文件路径。
The dictionary file path can be specified with the `-l` or `--local` option.

Use the `-L` or `--local-first` option to use the network dictionary after a local lookup fails. It is recommended to add `alias rl='dioxionary -l'` in the shell configuration file.

### Logseq support

使用 `-L` 或 `--local-first` 选项则会在本地查询失败后使用网络词典。推荐在 shell 配置文件中加入 `alias rl='dioxionary -l'`。
`rg TODO` see detail

### 多字典支持
### Multiple dictionary support

如上文示例中,可以将词典目录分别命名为 `00-XXX`, `01-YYY`, ..., `99-ZZZ` 这样的格式来实现优先级。
As in the above example, the dictionary directories can be named in the format of `00-XXX`, `01-YYY`, ..., `99-ZZZ` to achieve priority.

### 列出记录
### List records

> 注意:只有在线查词时会查得并记录单词类型
> Note: Only the word type will be searched and recorded when searching online

```console
$ dioxionary list [OPTIONS] [TYPE]
```

以下为支持的单词类型:
The following word types are supported:

CET4 | CET6 | TOEFL | IELTS | GMAT | GRE | SAT
--- | --- | --- | --- | --- | --- | ---

缺少类型时列出所有记录。
List all records when type is missing.

### 统计数据
### Statistical data

统计查询过的各类单词的个数:
Count the number of various words that have been queried:

```console
$ dioxionary count
Expand Down
3 changes: 3 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() -> shadow_rs::SdResult<()> {
shadow_rs::new()
}
1 change: 1 addition & 0 deletions rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nightly
Loading
Loading