Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def createWordFeatures(data, size):
- allewoorden = []
- tellen = {}
- for elkbestand in data:
- inhoud = elkbestand[0] # [0] eerste element uit de tuple
- classificatie = elkbestand[1] #[1] tweede element uit de tuple
- woorden = inhoud.split()
- for woord in woorden:
- if woord in tellen:
- tellen[woord] +=1
- else:
- tellen[woord] = 1
- for woord in tellen:
- allewoorden.append( (tellen[woord], woord) )
- allewoorden.sort()
- allewoorden.reverse()
- return [x[1] for x in allewoorden][:size]
- print tellen
Add Comment
Please, Sign In to add comment