How to count the number of occurrences in columns?
File:
luz NC luz
mas ADV más
blanquita ADJ blanco
que CQUE que
las ART el
que CQUE que
traía VLfin traer
de PREP de
serie NC serie
mi PPO mi|mío
coche NC coche
Script:
from collections import Counter
with open ("corpus_TreeTagger.txt", "r") as f:
texte = f.read()
colunas = texte.split("\n")
def frequencia(colunas):
for linhas in colunas:
lexema = linhas.split('\t')[0]
pos = linhas.split('\t')[1]
lema = linhas.split('\t')[2]
return Counter(lexema)
return Counter(pos)
return Counter(lema)
print(frequencia(colunas))
Error:
Traceback (most recent call last):
File "FINALV2.py", line 72, in <module>
print(frequencia(colunas))
File "FINALV2.py", line 23, in frequencia
pos = linhas.split('\t')[1]
IndexError: list index out of range
Could anyone help me?