@@ -11,7 +11,7 @@ class BillookupHandler(BaseHandler):
1111 def get_pair_or_error (self , langpair ):
1212 try :
1313 l1 , l2 = map (to_alpha3_code , langpair .split ('|' ))
14- in_mode = f" { l1 } -{ l2 } "
14+ in_mode = f' { l1 } -{ l2 } '
1515 except ValueError :
1616 self .send_error (400 , explanation = 'That pair is invalid, use e.g. eng|spa' )
1717 return None
@@ -25,7 +25,7 @@ def get_pair_or_error(self, langpair):
2525 @gen .coroutine
2626 def lookup_and_respond (self , pair , query ):
2727 try :
28- path , mode = self .billookup ["-" .join (pair )]
28+ path , mode = self .billookup ['-' .join (pair )]
2929 formatting = 'none'
3030 commands = [['apertium' , '-d' , path , '-f' , formatting , mode ]]
3131 result = yield translate_simple (query , commands )
@@ -48,15 +48,15 @@ def lookup_and_respond(self, pair, query):
4848 # allowed subcategories per POS (to be filled out)
4949 # could separate this out in a language specific way
5050 allowed = {
51- "n" : ["m" , "f" , "nt" , "aa" , "nn" ],
52- "np" : [" ant" , " top" , " cog" , "m" , "f" , "nt" , "mf" , "aa" , "nn" ],
53- "v" : ["tv" , "iv" ],
54- " vblex" : [],
51+ 'n' : ['m' , 'f' , 'nt' , 'aa' , 'nn' ],
52+ 'np' : [' ant' , ' top' , ' cog' , 'm' , 'f' , 'nt' , 'mf' , 'aa' , 'nn' ],
53+ 'v' : ['tv' , 'iv' ],
54+ ' vblex' : [],
5555 }
5656
5757 def normalize (form ):
58- word = form .split ("<" , 1 )[0 ]
59- tags = re .findall (r" <([^>]+)>" , form )
58+ word = form .split ('<' , 1 )[0 ]
59+ tags = re .findall (r' <([^>]+)>' , form )
6060 if not tags :
6161 return word , []
6262 pos = tags [0 ]
@@ -68,39 +68,39 @@ def normalize(form):
6868 if t not in filtered :
6969 filtered .append (t )
7070 else :
71- tag_with_brackets = f" <{ t } >"
71+ tag_with_brackets = f' <{ t } >'
7272 if tag_with_brackets not in extra :
7373 extra .append (tag_with_brackets )
74- tag_str = f" <{ pos } >" + "" .join (f" <{ t } >" for t in filtered )
75- return f" { word } { tag_str } " , extra
74+ tag_str = f' <{ pos } >' + '' .join (f' <{ t } >' for t in filtered )
75+ return f' { word } { tag_str } ' , extra
7676
7777 consolidated = {}
7878 for item in raw_results :
7979 for src in item :
8080 norm_src , extra_src = normalize (src )
8181 if norm_src not in consolidated :
82- consolidated [norm_src ] = {" targets" : {}, " extra_tags" : []}
82+ consolidated [norm_src ] = {' targets' : {}, ' extra_tags' : []}
8383 for tag in extra_src :
84- if tag not in consolidated [norm_src ][" extra_tags" ]:
85- consolidated [norm_src ][" extra_tags" ].append (tag )
84+ if tag not in consolidated [norm_src ][' extra_tags' ]:
85+ consolidated [norm_src ][' extra_tags' ].append (tag )
8686 for tgt in item [src ]:
8787 norm_tgt , _ = normalize (tgt )
88- if norm_tgt not in consolidated [norm_src ][" targets" ]:
89- consolidated [norm_src ][" targets" ][norm_tgt ] = True
88+ if norm_tgt not in consolidated [norm_src ][' targets' ]:
89+ consolidated [norm_src ][' targets' ][norm_tgt ] = True
9090
9191 results = []
9292 for src , data in consolidated .items ():
93- tgt_list = list (data [" targets" ].keys ())
94- if data [" extra_tags" ]:
95- extra_combined = "" .join (data [" extra_tags" ])
93+ tgt_list = list (data [' targets' ].keys ())
94+ if data [' extra_tags' ]:
95+ extra_combined = '' .join (data [' extra_tags' ])
9696 entry = {
9797 src : tgt_list ,
98- " extra-tags" : [extra_combined ]
98+ ' extra-tags' : [extra_combined ],
9999 }
100100 else :
101101 entry = {
102102 src : tgt_list ,
103- " extra-tags" : []
103+ ' extra-tags' : [],
104104 }
105105 results .append (entry )
106106
0 commit comments