@mailwoman/sentencepiece-wasm 9.1.0 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.cpp +3 -3
- package/index.d.ts +1 -1
- package/package.json +4 -3
- package/sentencepiece.mjs +0 -0
package/binding.cpp
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* - `encodeWithOffsets(text)` — returns { pieces: string[], ids: Int32Array-like, begins, ends }
|
|
22
22
|
* where begins/ends are UTF-8 BYTE offsets into the input. The TS layer owns the byte→UTF-16
|
|
23
23
|
* conversion (exact, via a code-point walk — see neural/tokenizer.ts).
|
|
24
|
-
* - `
|
|
24
|
+
* - `decodeIDs(ids)` — detokenize back to a string.
|
|
25
25
|
*
|
|
26
26
|
* Build: `./build.sh` (fetches sentencepiece at the pinned tag, emcmake+emmake, links this file
|
|
27
27
|
* with embind, emits the committed single-file ESM artifact `sentencepiece.mjs`).
|
|
@@ -96,7 +96,7 @@ public:
|
|
|
96
96
|
* Detokenize ids back to text. Invalid ids surface as the empty string plus the error field on
|
|
97
97
|
* the wrapper's contract being violated upstream — the TS layer validates lengths.
|
|
98
98
|
*/
|
|
99
|
-
std::string
|
|
99
|
+
std::string decodeIDs(const std::vector<int>& ids) const {
|
|
100
100
|
std::string out;
|
|
101
101
|
const auto status = processor_.Decode(ids, &out);
|
|
102
102
|
return status.ok() ? out : std::string();
|
|
@@ -115,5 +115,5 @@ EMSCRIPTEN_BINDINGS(sentencepiece_wasm) {
|
|
|
115
115
|
.constructor<>()
|
|
116
116
|
.function("loadFromSerializedProto", &SentencePieceWASM::loadFromSerializedProto)
|
|
117
117
|
.function("encodeWithOffsets", &SentencePieceWASM::encodeWithOffsets)
|
|
118
|
-
.function("
|
|
118
|
+
.function("decodeIDs", &SentencePieceWASM::decodeIDs);
|
|
119
119
|
}
|
package/index.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export declare class SentencePieceProcessor {
|
|
|
36
36
|
*/
|
|
37
37
|
loadFromSerializedProto(serialized: Uint8Array): string
|
|
38
38
|
encodeWithOffsets(text: string): EncodeWithOffsetsResult
|
|
39
|
-
|
|
39
|
+
decodeIDs(ids: IntVector): string
|
|
40
40
|
/**
|
|
41
41
|
* Embind object lifetime: the processor owns WASM-heap memory — call when done (long-lived singletons in practice
|
|
42
42
|
* never do).
|
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailwoman/sentencepiece-wasm",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"description": "google/sentencepiece v0.2.2 compiled to WASM with a native-offsets binding — the tokenizer core for @mailwoman/neural. Single-file ESM (wasm embedded), no runtime deps; per-piece byte offsets come from SentencePiece itself instead of TS-side reconstruction.",
|
|
5
5
|
"license": "AGPL-3.0-only OR LicenseRef-Commercial",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/sister-software/mailwoman.git",
|
|
9
|
-
"directory": "sentencepiece-wasm"
|
|
9
|
+
"directory": "packages/sentencepiece-wasm"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"sentencepiece.mjs",
|
|
13
13
|
"index.d.ts",
|
|
14
14
|
"binding.cpp",
|
|
15
|
-
"build.sh"
|
|
15
|
+
"build.sh",
|
|
16
|
+
"!test/**"
|
|
16
17
|
],
|
|
17
18
|
"type": "module",
|
|
18
19
|
"exports": {
|
package/sentencepiece.mjs
CHANGED
|
Binary file
|