рассчитать частоту слагаемых в Mysql - PullRequest
0 голосов
/ 03 сентября 2018

У меня есть таблица Mysql что-то вроде:

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

Теперь все, что я хочу - создать новую таблицу, в которой столбцы - это уникальные слова во всех документах, а строки - как значения, соответствующие каждому DocumentID, равному

(number of times word appears in sentence) / (number of words in sentence).

Что-то вроде: -

 DocumentID    ate      blue        bought       bright     bug         cat   fish            meow           once      orang      penni     saw           store            went
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
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
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
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
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
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
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

Я много пробовал, но не получил ожидаемых результатов.

...