自己現(xiàn)在有兩種方案,一種是直接用數(shù)進(jìn)行增長// let weight=// {// '美國': 10,// '軍區(qū)': 5,// '雇員': 7,// '灰色': 4,// '外星人': 7,// 'ufo': 3,// }另一種是將字符用utf8的方式進(jìn)行解析出來。let str='國'function hash(str){ let strcode=0
for (const iterator of str)
{
strcode += iterator.codePointAt(0).toString(2)
} return strcode
}console.log(hash(str))//0101011011111101但是兩者的的編碼仍然不能縮小數(shù)據(jù)量。計(jì)算這個(gè)是為了后面能夠進(jìn)行,文本相似度的計(jì)算。謝謝。
- 2 回答
- 0 關(guān)注
- 682 瀏覽
添加回答
舉報(bào)
0/150
提交
取消