SHARE
TWEET

Untitled

a guest Jun 20th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import io
  2. poema = io.open("cantardemiocid.txt", "rt", encoding="utf-8")
  3. eibici = 'abcdefghijklmnñopqrstuvwxyz'
  4.  
  5. def sinmayus(palabra):
  6.     palabra = palabra.replace('á','a')
  7.     palabra = palabra.replace('é','e')
  8.     palabra = palabra.replace('í','i')
  9.     palabra = palabra.replace('ó','o')
  10.     palabra = palabra.replace('ú','u')
  11.     for a in palabra:
  12.         if a in eibici:
  13.             pass
  14.         else:
  15.            palabra = palabra.replace(a,'')
  16.     return palabra
  17.  
  18.  
  19. totaldepalabras = poema.read().split()
  20. totaldepalabras = [x.lower() for x in totaldepalabras]
  21. totaldepalabras = [sinmayus(x) for x in totaldepalabras]
  22.  
  23. palabrasunicas = set(totaldepalabras)
  24.  
  25. conteo = dict()
  26.  
  27. for word in palabrasunicas:
  28.     conteo[word] = totaldepalabras.count(word)
  29.    
  30. print(conteo)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top