1
I have a function in Python that takes a text and returns 2 lists, one with all the words that appear and the other returns is the number of times each word appears.
def frequencia(lista):
conv = str(lista)
plSeparadas = separa_palavras(conv)
listUnic = []
listFreq = []
for p in plSeparadas:
if p in listUnic:
i = listUnic.index(p)
listFreq[i] = listFreq[i] + 1
else:
listUnic.append(p)
listFreq.append(1)
xList = listUnic
xFreq = listFreq
return xList, xFreq
I need to use this number of times (xFreq) in another function to calculate the mean value of the frequency :
def mediaFreq(listaFrequencia):
ordenar = sorted(listaFrequencia)
tamanho = len(ordenar)
media = tamanho/2
return(media)
How can I do that ??