Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cloudef/zig-budoux
Budoux for Zig and C
https://github.com/cloudef/zig-budoux
c chinese dependency-free internationalization japanese machine-learning natural-language-processing no-std text thai typography word word-wrapping zig
Last synced: 2 months ago
JSON representation
Budoux for Zig and C
- Host: GitHub
- URL: https://github.com/cloudef/zig-budoux
- Owner: Cloudef
- License: mit
- Created: 2024-02-25T17:27:45.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-06-12T22:59:40.000Z (7 months ago)
- Last Synced: 2024-10-11T10:25:15.927Z (3 months ago)
- Topics: c, chinese, dependency-free, internationalization, japanese, machine-learning, natural-language-processing, no-std, text, thai, typography, word, word-wrapping, zig
- Language: Zig
- Homepage:
- Size: 39.1 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# zig-budoux
[Budoux](https://github.com/google/budoux) for Zig (and C)
---
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
Project is tested on zig version 0.14.0-dev.23+d9bd34fd0
## Example
### Zig
```zig
const budoux = @import("zig-budoux");
var model = try budoux.init(allocator, .ja);
defer model.deinit(allocator);
var iter = model.iterator("今日は天気です。");
try std.testing.expectEqualSlices(u8, "今日は", iter.next().?);
try std.testing.expectEqualSlices(u8, "天気です。", iter.next().?);
```### C
```c
#include
BudouxModel model = budoux_init(budoux_model_ja);
BudouxChunkIterator iter = budoux_iterator_init(model, "今日は天気です。");
BudouxChunk chunk;
chunk = budoux_iterator_next(&iter); // 今日は
chunk = budoux_iterator_next(&iter); // 天気です。
budoux_deinit(model);
```> [!NOTE]
> zig-budoux does not allocate any strings, thus it won't add any html markup or zero width spaces.
> However with `model.iterator` it is simple to construct strings for your needs.
> To parse html you need to bring your own html parser.## Depend
`build.zig.zon`
```zig
.zig_budoux = .{
.url = "https://github.com/Cloudef/zig-budoux/archive/{COMMIT}.tar.gz",
.hash = "{HASH}",
},
````build.zig`
```zig
const zig_budoux = b.dependency("zig_budoux", .{}).module("zig-budoux");
exe.root_module.addImport("zig-budoux", zig_budoux);
```