Split analyze_keywords.py into multiple scripts
This commit is contained in:
parent
32f8c20b2e
commit
5cec2e8e24
5 changed files with 88 additions and 81 deletions
20
analyze_multiple_cubes_keywords.py
Normal file
20
analyze_multiple_cubes_keywords.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
"""Count keywords in a list of cube.json files.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
|
||||
import keyword_stats
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
output = open('cube_keyword_frequency.csv', 'w+')
|
||||
all_cube_files = os.listdir('cubes')
|
||||
output_file = open('cube_keyword_frequency.csv', 'w+')
|
||||
output_file.write('Cube,Keywords\n')
|
||||
for filename in all_cube_files:
|
||||
if filename.endswith('json'):
|
||||
k_dict = keyword_stats.keyword_count('cubes/' + filename)
|
||||
output_file.write(f"{filename.strip('json')},{len(k_dict)}\n")
|
||||
print(filename, len(k_dict))
|
||||
output_file.close()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue