toki_pona/word_count.py
2023-10-08 18:27:27 +02:00

14 lines
330 B
Python

from collections import Counter
def main():
with open('lyrics_pan_nanpa_wan.txt') as f:
lyrics = f.read()
alphabetic_only = ''.join([c for c in lyrics if c.isalpha() or c == ' '])
words = alphabetic_only.split()
print(Counter(words))
print(len(Counter(words)))
if __name__ == '__main__':
main()