daily pastebin goal
10%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def createWordFeatures(data, size):
  2.    
  3.     allewoorden = []
  4.     tellen = {}
  5.    
  6.     for elkbestand in data:
  7.         inhoud = elkbestand[0]  # [0] eerste element uit de tuple
  8.         classificatie = elkbestand[1] #[1] tweede element uit de tuple
  9.         woorden = inhoud.split()
  10.         for woord in woorden:
  11.             if woord in tellen:
  12.                 tellen[woord] +=1
  13.             else:
  14.                 tellen[woord] = 1
  15.                
  16.         for woord in tellen:
  17.             allewoorden.append( (tellen[woord], woord) )
  18.             allewoorden.sort()
  19.             allewoorden.reverse()
  20.            
  21.     return [x[1] for x in allewoorden][:size]
  22.     print tellen
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