fix problem with .lower(); add total journals count

This commit is contained in:
Mark Eaton
2024-12-17 20:57:21 -05:00
parent 21badae763
commit cc292c846f
+4 -4
View File
@@ -28,6 +28,7 @@ def extract_journal_titles(data):
journal_titles.append(row[3]) journal_titles.append(row[3])
count_journal_titles = Counter(journal_titles).most_common(20) count_journal_titles = Counter(journal_titles).most_common(20)
pprint(count_journal_titles) pprint(count_journal_titles)
print("Total journals: " + str(len(set(journal_titles))))
def extract_title_keywords(data): def extract_title_keywords(data):
@@ -37,10 +38,10 @@ def extract_title_keywords(data):
raw_words = row[2].split(' ') raw_words = row[2].split(' ')
row_words = [] row_words = []
for word in raw_words: for word in raw_words:
re_word = re.sub(r'[^a-zA-Z\-]', '', word) re_word = re.sub(r'[^a-zA-Z\-]', '', word.lower())
if re_word not in stop_words: if re_word not in stop_words:
re_words.append(re_word.lower()) re_words.append(re_word)
row_words.append(re_word.lower()) row_words.append(re_word)
title_keywords = [(word, row_words) for word in re_words] title_keywords = [(word, row_words) for word in re_words]
return title_keywords return title_keywords
@@ -80,7 +81,6 @@ def dash_viz(data):
for edge1, edge2 in edges: for edge1, edge2 in edges:
if edge1 and edge2: if edge1 and edge2:
output_data.append({'data': {'source': edge1, 'target': edge2}}) output_data.append({'data': {'source': edge1, 'target': edge2}})
pprint(output_data)
with open('viz_data.json', 'w') as file: with open('viz_data.json', 'w') as file:
json.dump(output_data, file) json.dump(output_data, file)