Go, 219 217 192 210 209209 156 bytes
Saved 25 bytes thanks to @Lynn! Saved 53 bytes thanks to @ovs!
Had to lose 18 bytes because of a bug with strings with no underscores :(
func p(s string){b:=0;n:=0;r:=g.Index(s,"_");if r==-1{r=0};for=0;for _,c:=range s[0:r]s{if IsLetter(c){x:=0;ifb+=b;if IsUpper(c){x=1};b+=b+x;n++b+=1};if n==5{n=0;s=g;n++;s=g.Replace(s,"_",string('a'+b%32),1(5-n%5);b=0/5)}};Print(g.ToLower(s))}