Skip to content

Commit

Permalink
Fix some unnecessary newlines in code
Browse files Browse the repository at this point in the history
  • Loading branch information
Mkranj committed Nov 6, 2022
1 parent 98ddcc7 commit 6a97883
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions PapersCited.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ def get_file():
# Make the main window of tkinter invisible since we only need the dialog.
root.withdraw()
root.attributes("-topmost", True)
filename = filedialog.askopenfilename(
title="Select a document to search for citations:")
filename = filedialog.askopenfilename(title="Select a document to search for citations:")
root.destroy()
return(filename)

Expand Down Expand Up @@ -197,8 +196,7 @@ def get_matches(target_document):
for index_no, citation in enumerate(second_authors):
# Citation by citation, check and change all listed symbols
for phrase in starts_with_and:
second_authors[index_no] = second_authors[index_no].replace(
phrase, "", 1)
second_authors[index_no] = second_authors[index_no].replace(phrase, "", 1)

# Now we have two lists, all authors with year detected and only those who occur after an 'i'/'&'
# For each occuring in the second list, delete ONE from the first - so if theres A & B 2000 and also B 2000,
Expand All @@ -224,22 +222,19 @@ def get_matches(target_document):
)

# Combine all found cases into a single list
all_found_citations = matches_single_author + \
matches_multiple_authors + matches_author_et_al
all_found_citations = matches_single_author + matches_multiple_authors + matches_author_et_al
return(all_found_citations)


def remove_characters_adjust_phrases(list_of_matches, characters_to_remove, phrases_to_adjust):
for index_no, citation in enumerate(list_of_matches):
# Remove uneccessary characters
for char in characters_to_remove:
list_of_matches[index_no] = list_of_matches[index_no].replace(
char, "")
list_of_matches[index_no] = list_of_matches[index_no].replace(char, "")

# Change several phrases
for key in phrases_to_adjust:
list_of_matches[index_no] = list_of_matches[index_no].replace(
key, phrases_to_adjust[key])
list_of_matches[index_no] = list_of_matches[index_no].replace(key, phrases_to_adjust[key])

# Remove leading and trailing spaces with strip() to not confuse the duplicate detection
list_of_matches[index_no] = list_of_matches[index_no].strip()
Expand Down Expand Up @@ -326,8 +321,7 @@ def write_excel(list_of_matches, filename):
workbook.close()

print(f"Success! A file has been created at {output_filename}.")
print(
f"A total of {len(list_of_matches)} different citations have been recorded.")
print(f"A total of {len(list_of_matches)} different citations have been recorded.")
input("\nPress Enter to exit the program.")

# MAIN ----
Expand Down

0 comments on commit 6a97883

Please sign in to comment.