~/bend-docscommunity

test/encode.bend checks

raw source on the hub · import bend-bpe-tokenizer@0.1.0.0/test/encode.bend as Encode

Encodes texts with a tokenizer.json, one line of ids (or an error) per text, for test/compare.py. Usage: ./encode TOKENIZER_JSON TEXTS OUT, TEXTS being UTF-8 texts separated by NUL bytes.

2 imports
import Base
import ../tok.bend as TK

Definitions

def lap source · line 6 · raw

@label:String -> @+t0:Nat -> IO(Nat)

def got source · line 12 · raw

@r:Result<&1, &1, Pair(U32, String), List<&2, U32>> -> List<&2, U32>

def read_done source · line 19 · raw

@r:Pair(File, Result<&1, &1, Pair(U32, String), List<&2, U32>>) -> IO(List<&2, U32>)

def read_all source · line 26 · raw

@path:String -> IO(List<&2, U32>)

def texts_cut source · line 33 · raw

@z:Bool -> @+b:U32 -> @cur:List<&2, U32> -> @go:(@_:List<&2, U32> -> List<&2, List<&2, U32>>) -> List<&2, List<&2, U32>>

texts separated by 0 bytes

def texts_go source · line 40 · raw

@bs:List<&2, U32> -> @cur:List<&2, U32> -> List<&2, List<&2, U32>>

def ids_line source · line 47 · raw

@ids:List<&2, U32> -> String

def show_err source · line 54 · raw

@e:0x0c46c789483b48a99efa2c996652d510/tok.Err -> String

def show source · line 61 · raw

@r:Result<&2, &2, 0x0c46c789483b48a99efa2c996652d510/tok.Err, List<&2, U32>> -> String

def lines source · line 68 · raw

@+tk:0x0c46c789483b48a99efa2c996652d510/tok.Tok -> @ts:List<&2, List<&2, U32>> -> String

def close_w source · line 75 · raw

@w:Pair(File, Result<&1, &1, Pair(U32, String), Unit>) -> IO(Unit)

def run source · line 80 · raw

@r:Result<&2, &2, String, 0x0c46c789483b48a99efa2c996652d510/tok.Tok> -> @ts:List<&2, List<&2, U32>> -> @out:String -> @+t1:Nat -> IO(Unit)

def nth source · line 91 · raw

@xs:List<&2, String> -> @n:Nat -> String

def reuse source · line 100 · raw

@xs:List<&1, String> -> List<&2, String>

def main source · line 107 · raw

IO(Unit)