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

doc: add a document about program dictionary #1355

Merged
merged 1 commit into from
Jan 4, 2024
Merged
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
Binary file added website/docs/howto/add-program-dictionary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions website/docs/howto/how to add a program as dictionary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# How to add a program or script to the goldendict-ng

GoldenDict has offered a program dictionary function that allow you to customize the user experience when using the this software.

# An example

tokenize the input german sentence into words.

## use python script

You can use any script language or program to implement this feature.


## install python

## install SoMaJo

you can follow the instructions in the documentation https://github.com/tsproisl/SoMaJo?tab=readme-ov-file#installation

`pip install -U SoMaJo`

## create a script

```
from somajo import SoMaJo
import sys

tokenizer = SoMaJo("de_CMC", split_camel_case=True)

# note that paragraphs are allowed to contain newlines
paragraphs = [sys.argv[1]]
sentences = tokenizer.tokenize_text(paragraphs)
for sentence in sentences:
for token in sentence:
if token.token_class=='regular':
print(f"{token.text}")
```

and save the script in the E:\test.py for example.

## add the script to the program dictionary

![Add the script as program dictionary](add-program-dictionary.png)
`python e:\test.py %GDWORD%`

## the result

![](program-result.png)



Binary file added website/docs/howto/program-result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions website/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ nav:
- Build ffmpeg on Windows: howto/how to build ffmpeg for visual studio.md
- How to update the crowdin.ts file: howto/how to update crowdin.ts file.md
- How to debug dictionary js: howto/how to debug dictionary js.md
- How to add a program dictionary: howto/how to add a program as dictionary.md