在mysql中计算术语频率

smtd7mpg  于 2021-06-20  发布在  Mysql
关注(0)|答案(0)|浏览(234)

我的mysql表类似于:

  1. |DocumentID| Documents
  2. ============================================
  3. 0 Penny bought bright blue fishes.
  4. 1 Penny bought bright blue and orange fish.
  5. 2 The cat ate a fish at the store.
  6. 3 Penny went to the store. Penny ate a bug. Penn...
  7. 4 It meowed once at the bug, it is still meowing...
  8. 5 The cat is at the fish store. The cat is orang...
  9. 6 Penny is a fish

现在,我只想创建一个新表,其中列是所有文档和行中唯一的单词,作为每个文档和行对应的值 DocumentID 等于 (number of times word appears in sentence) / (number of words in sentence) .
什么like:-

  1. DocumentID ate blue bought bright bug cat fish meow once orang penni saw store went
  2. 0 0.000000 0.200000 0.200000 0.200000 0.000000 0.000 0.200000 0.000000 0.000000 0.000000 0.200000 0.000000 0.000000 0.000000
  3. 1 0.000000 0.166667 0.166667 0.166667 0.000000 0.000 0.166667 0.000000 0.000000 0.166667 0.166667 0.000000 0.000000 0.000000
  4. 2 0.250000 0.000000 0.000000 0.000000 0.000000 0.250 0.250000 0.000000 0.000000 0.000000 0.000000 0.000000 0.250000 0.000000
  5. 3 0.111111 0.000000 0.000000 0.000000 0.111111 0.000 0.111111 0.000000 0.000000 0.000000 0.333333 0.111111 0.111111 0.111111
  6. 4 0.000000 0.000000 0.000000 0.000000 0.333333 0.000 0.166667 0.333333 0.166667 0.000000 0.000000 0.000000 0.000000 0.000000
  7. 5 0.000000 0.000000 0.000000 0.000000 0.000000 0.375 0.250000 0.125000 0.000000 0.125000 0.000000 0.000000 0.125000 0.000000
  8. 6 0.000000 0.000000 0.000000 0.000000 0.000000 0.000 0.500000 0.000000 0.000000 0.000000 0.500000 0.000000 0.000000 0.000000

我试了很多,但没有达到预期的效果。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题