2222from fuzzywuzzy import fuzz
2323from werkzeug .utils import cached_property
2424
25- CSV_FILE = ' ./data/affiliations.csv'
25+ CSV_FILE = " ./data/affiliations.csv"
2626
2727
28- class AffiliationResolver () :
28+ class AffiliationResolver :
2929 """Affiliation resolver."""
3030
3131 @cached_property
@@ -36,8 +36,8 @@ def affiliations(self):
3636 """
3737 affiliations = []
3838
39- with open (CSV_FILE , 'r' ) as file :
40- reader = csv .reader (file , delimiter = ' \t ' )
39+ with open (CSV_FILE , "r" ) as file :
40+ reader = csv .reader (file , delimiter = " \t " )
4141 for row in reader :
4242 affiliation = []
4343 for index , value in enumerate (row ):
@@ -64,21 +64,24 @@ def resolve(self, searched_affiliation):
6464 standard_form = affiliations [0 ]
6565 for affiliation in affiliations :
6666 score = fuzz .partial_ratio (searched_affiliation , affiliation )
67- if ( score > 92 and standard_form not in collected_affiliations ) :
67+ if score > 92 and standard_form not in collected_affiliations :
6868 # handle special case UZH / ZHdK
6969 # TODO: solve this special case by converting the CSV file to JSON
7070 # using rejected forms https://github.com/rero/sonar/issues/824
71- if (affiliation .lower () == 'zurich university' and
72- 'zurich university of the arts' in searched_affiliation .lower ()
71+ if (
72+ affiliation .lower () == "zurich university"
73+ and "zurich university of the arts"
74+ in searched_affiliation .lower ()
7375 ):
7476 continue
7577 # handle special case CERN/Lucerne
76- if (affiliation .lower () == 'cern' and
77- 'lucerne' in searched_affiliation .lower ()
78+ if (
79+ affiliation .lower () == "cern"
80+ and "lucerne" in searched_affiliation .lower ()
7881 ):
7982 continue
8083 # handle special case Freiburg im Breisgau
81- if ' university of freiburg' in searched_affiliation .lower ():
84+ if " university of freiburg" in searched_affiliation .lower ():
8285 break
8386
8487 collected_affiliations .append (standard_form )
0 commit comments