-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cdafe86
commit 2744199
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,6 +192,32 @@ Output: | |
['我', '的', '电话', '是', '15555555555', ',', '邮箱', '是', '[email protected]', ',', '工作', '单位', '是', 'Tokyo', 'University', '。'] | ||
``` | ||
|
||
## How to train and use your own models | ||
|
||
### How to Train | ||
|
||
MicroTokenizer also provides tools to help you train your own models. | ||
|
||
```python | ||
from MicroTokenizer.training.train import train | ||
|
||
# You can use multiple files as training data, provided as a list | ||
train(["./corpus.txt"], "./model_data") | ||
``` | ||
|
||
## How to Use Your Own Models | ||
|
||
```python | ||
# import your tokenizer, XXXTokenizer is just a placeholder | ||
from MicroTokenizer import XXXTokenizer | ||
|
||
model_dir = "path/to/your/model" | ||
input_text = "Your text to be tokenized" | ||
|
||
tokenizer = XXXTokenizer.load(model_dir) | ||
tokens = tokenizer.segment(input_text) | ||
print(f"{name} Tokenizer:", tokens) | ||
``` | ||
|
||
## Algorithm Explanation | ||
|
||
|