自己現在有兩種方案,一種是直接用數進行增長// let weight=// {// '美國': 10,// '軍區': 5,// '雇員': 7,// '灰色': 4,// '外星人': 7,// 'ufo': 3,// }另一種是將字符用utf8的方式進行解析出來。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但是兩者的的編碼仍然不能縮小數據量。計算這個是為了后面能夠進行,文本相似度的計算。謝謝。
- 2 回答
- 0 關注
- 700 瀏覽
添加回答
舉報
0/150
提交
取消
