MCPcopy Create free account
hub / github.com/boutproject/BOUT-dev / ExistingAuthorNames

Class ExistingAuthorNames

bin/update_citations.py:84–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82
83
84class ExistingAuthorNames:
85 def __init__(self, existing_authors):
86 self._existing_author_names = [
87 (unidecode(a.get("given-names")), unidecode(a.get("family-names")))
88 for a in existing_authors
89 ]
90
91 def last_name_matches_surname_and_first_name_or_first_letter_matches_given_name(
92 self, last_name, first_name
93 ):
94 # Last name matches surname
95 matches = [
96 n
97 for n in self._existing_author_names
98 if n[1].casefold() == last_name.casefold()
99 ]
100
101 for match in matches:
102 # The given name also matches author first name
103 if match[0].casefold() == first_name.casefold():
104 return True
105 # The first initial matches author first name
106 if match[0][0].casefold() == first_name[0].casefold():
107 return True
108
109 def first_name_matches_surname_and_last_name_matches_given_name(
110 self, first_name, last_name
111 ):
112 # First name matches surname
113 matches = [
114 n
115 for n in self._existing_author_names
116 if n[1].casefold() == first_name.casefold()
117 ]
118
119 # The given name also matches author last name
120 for match in matches:
121 if match[0].casefold() == last_name.casefold():
122 return True
123
124 def surname_matches_whole_author_name(self, author):
125 surname_matches = [
126 n
127 for n in self._existing_author_names
128 if n[1].casefold() == author.casefold()
129 ]
130 if len(surname_matches) > 0:
131 return True
132
133 def given_name_matches_matches_whole_author_name(self, author):
134 given_name_matches = [
135 n
136 for n in self._existing_author_names
137 if n[0].casefold() == author.casefold()
138 ]
139 if len(given_name_matches) > 0:
140 return True
141

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected