daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Dec 15th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from collections import Counter
  2. import random
  3.  
  4. def Contador_Prob(texto):
  5.     texto = texto.lower()
  6.     skips = [".", ",", ":", ";", "'", '"']
  7.     #contador=[]
  8.     for ch in skips:
  9.         texto = texto.replace(ch, "")
  10.     word_counts = Counter(texto.split(" "))  
  11.     #counts = word_counts.values()
  12.     num_unique = len(word_counts)
  13.  
  14.     num_total=sum(word_counts.values())
  15.  
  16.  
  17.     """ for word_counts.keys in texto:
  18.         if random.randint(0,1) < 0.5:
  19.             contador[word_counts.keys]+=1
  20.         else:
  21.             contador[word_counts.keys]=1  """
  22.     return (word_counts, num_unique, num_total)
  23.  
  24. texto="É uma verdade universalmente reconhecida, que um único homem na posse de uma boa fortuna, deve estar em falta de uma esposa."
  25. print(Contador_Prob(texto))
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