Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def Normalize(count,one_language = True):
- counter = 0
- if one_language:
- normalized = {}
- for letter in count.keys():
- counter += count[letter]
- for letter in count.keys():
- normalized[letter] = float(count[letter]) / counter
- else:
- normalized = {}
- for lang in count.keys():
- normalized.update({lang:{}})
- for name in count[lang].keys():
- counter = 0
- normalized[lang].update({name:{}})
- for letter in count[lang][name].keys():
- counter += count[lang][name][letter]
- for letter in count[lang][name].keys():
- normalized[lang][name][letter] = float(count[lang][name][letter]) / counter
- return normalized
Add Comment
Please, Sign In to add comment