tinybpe / script.js
qikp's picture
Upload folder using huggingface_hub
ee3c664 verified
raw
history blame contribute delete
320 Bytes
q=(x)=>document.querySelector(x)
function h(i){q("button").onclick=()=>{
v=Object.entries(i).sort((e,f)=>f[0].length-e[0].length).map(e=>[e[0].replace("Ġ"," "),e[1]])
s=q("input").value
t=[]
while(s){w=v.find(u=>s.startsWith(u[0]))
if(w){s=s.slice(w[0].length)
t.push(w[1])}
else{t.push(-1)
break}}
document.write(t)}}