HMM automatic vowel detection
#45
(28-11-2018, 06:07 PM)MarcoP wrote: You are not allowed to view links. Register or Login to view.I also had to update the script to assign each letter to one of the states. I have lost this script in a computer crash about one year ago, so I don't remember the details, but of course this was based on the B matrix. The simplest thing would be to assign each letter to that of the two states where that letter has the highest weight.

Hi Marco,

Thanks for your reply.

I tried to print rdict (the mapping from indices to letters), newA (A Matrix) and newB (B Matrix) and got this for a small portion of English test data from Wikipedia:

Code:
======== rdict ======== {0: ' ', 1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e', 6: 'f', 7: 'g', 8: 'h', 9: 'i', 10: 'j', 11: 'k', 12: 'l', 13: 'm', 14: 'n', 15: 'o', 16: 'p', 17: 'q', 18: 'r', 19: 's', 20: 't', 21: 'u', 22: 'v', 23: 'w', 24: 'x', 25: 'y', 26: 'z'} ======== newA ======== [[0.209 0.791]  [0.647 0.353]] ======== newB ======== [[0.    0.    0.02  0.057 0.072 0.014 0.036 0.04  0.    0.    0.    0.008 0.109 0.043 0.172 0.    0.023 0.    0.103 0.13  0.125 0.    0.017 0.023 0.005 0.    0.001]  [0.287 0.152 0.001 0.    0.    0.163 0.003 0.036 0.071 0.116 0.    0.    0.    0.    0.    0.105 0.003 0.    0.    0.    0.004 0.043 0.    0.    0.    0.018 0.   ]]

rdict was not in the code. I added it. There was only cdict which maps from letters to indices:

Code:
cdict = dict([(x, i) for i, x in enumerate(chars)])

But it is easy to add a reversed one:

Code:
rdict = dict([(i, x) for i, x in enumerate(chars)])

Then we could assign letters to states where they have the maximum value:

Code:
highest_indices = np.argmax(newB, axis=0) sets = dict([(i, []) for i, _ in enumerate(newB)]) for i, s in enumerate(highest_indices):     sets[s].append(rdict[i])

In this case, if you want to assign letters based on minimum values, you could simply replace np.argmax with np.argmin.

Finally, we print sets, and get:

Code:
======== sets ======== {0: ['b', 'c', 'd', 'f', 'g', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z'], 1: [' ', 'a', 'e', 'h', 'i', 'o', 'u', 'y']}

If I am not mistaking anything, this is how you get the “sets”, right?

(the attachment is some English test data, copied from Wikipedia)


Attached Files
.txt   textdata.processed.txt (Size: 5.74 KB / Downloads: 26)
Reply


Messages In This Thread
HMM automatic vowel detection - by MarcoP - 26-09-2017, 09:20 AM
RE: HMM automatic vowel detection - by Koen G - 26-09-2017, 09:45 AM
RE: HMM automatic vowel detection - by MarcoP - 26-09-2017, 10:57 AM
RE: HMM automatic vowel detection - by Koen G - 26-09-2017, 11:18 AM
RE: HMM automatic vowel detection - by Davidsch - 26-09-2017, 01:26 PM
RE: HMM automatic vowel detection - by ReneZ - 26-09-2017, 07:36 PM
RE: HMM automatic vowel detection - by Davidsch - 27-09-2017, 12:43 PM
RE: HMM automatic vowel detection - by MarcoP - 27-09-2017, 09:37 PM
RE: HMM automatic vowel detection - by -JKP- - 27-09-2017, 11:59 PM
RE: HMM automatic vowel detection - by MarcoP - 28-09-2017, 10:22 AM
RE: HMM automatic vowel detection - by Davidsch - 28-09-2017, 12:07 PM
RE: HMM automatic vowel detection - by MarcoP - 28-09-2017, 12:29 PM
RE: HMM automatic vowel detection - by ReneZ - 28-09-2017, 08:05 PM
RE: HMM automatic vowel detection - by MarcoP - 28-09-2017, 08:32 PM
RE: HMM automatic vowel detection - by MarcoP - 28-09-2017, 09:43 PM
RE: HMM automatic vowel detection - by MarcoP - 28-09-2017, 09:35 PM
RE: HMM automatic vowel detection - by ReneZ - 29-09-2017, 05:45 AM
RE: HMM automatic vowel detection - by MarcoP - 29-09-2017, 04:24 PM
RE: HMM automatic vowel detection - by Davidsch - 29-09-2017, 06:03 PM
RE: HMM automatic vowel detection - by Koen G - 30-09-2017, 10:23 PM
RE: HMM automatic vowel detection - by -JKP- - 01-10-2017, 12:26 AM
RE: HMM automatic vowel detection - by MarcoP - 01-10-2017, 10:28 AM
RE: HMM automatic vowel detection - by Koen G - 01-10-2017, 10:52 AM
RE: HMM automatic vowel detection - by MarcoP - 01-10-2017, 12:16 PM
RE: HMM automatic vowel detection - by Koen G - 01-10-2017, 12:25 PM
RE: HMM automatic vowel detection - by ReneZ - 01-10-2017, 01:18 PM
RE: HMM automatic vowel detection - by MarcoP - 01-10-2017, 01:51 PM
RE: HMM automatic vowel detection - by Koen G - 01-10-2017, 01:46 PM
RE: HMM automatic vowel detection - by MarcoP - 01-10-2017, 02:04 PM
RE: HMM automatic vowel detection - by ReneZ - 01-10-2017, 02:10 PM
RE: HMM automatic vowel detection - by ReneZ - 03-10-2017, 08:14 AM
RE: HMM automatic vowel detection - by MarcoP - 03-10-2017, 07:39 PM
RE: HMM automatic vowel detection - by MarcoP - 28-11-2018, 06:07 PM
RE: HMM automatic vowel detection - by ChenZheChina - 29-11-2018, 04:24 AM
RE: HMM automatic vowel detection - by MarcoP - 30-11-2018, 11:38 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)