46
46
47
47
@final_changes .register (regex = r"Histories of (\w+) and (\w+)" )
48
48
def corr_histories_of (_ , search_result ):
49
- return "Истории о{} и {}" . format ( histories_adjs [search_result .group (1 )], histories_adjs [search_result .group (2 )])
49
+ return f "Истории о{ histories_adjs [search_result .group (1 )]} и { histories_adjs [search_result .group (2 )]} "
50
50
51
51
52
52
possessive_adjectives = {"жаба" : "жабий" , "корова" : "коровий" , "медведь" : "медвежий" }
@@ -117,7 +117,7 @@ def corr_container(text, _):
117
117
adjective = None
118
118
gender = get_gender (container , {"nomn" })
119
119
adjective = inflect_adjective (adjective , gender )
120
- replacement_string = "{ } {} ({})". format ( container , containment , adjective )
120
+ replacement_string = f" { container } { containment } ({ adjective } )"
121
121
else :
122
122
words = of_material .split ()
123
123
material = None
@@ -144,7 +144,7 @@ def corr_container(text, _):
144
144
material = "из " + " " .join (gen_case )
145
145
else :
146
146
material = of_material
147
- replacement_string = "{ } {} ({}" . format ( container , containment , material )
147
+ replacement_string = f" { container } { containment } ({ material } "
148
148
if initial_string [- 1 ] == ")" :
149
149
replacement_string += ")"
150
150
text = text .replace (initial_string , replacement_string .capitalize ())
@@ -245,7 +245,7 @@ def corr_of_material_item(text, _):
245
245
else :
246
246
replacement_string = " " .join (words ) + " " + of_material
247
247
else :
248
- raise ValueError ("Unknown case: {!r}" . format ( text ) )
248
+ raise ValueError (f "Unknown case: { text !r} " )
249
249
250
250
text = text .replace (initial_string , replacement_string )
251
251
return text
@@ -282,7 +282,7 @@ def corr_clothes(text, _):
282
282
search_result = re_clothes .search (text )
283
283
text = text .replace (
284
284
search_result .group (1 ),
285
- "{} {} {}" . format ( search_result .group (4 ), search_result .group (3 ), to_genitive_case (search_result .group (2 ))) ,
285
+ f" { search_result .group (4 )} { search_result .group (3 )} { to_genitive_case (search_result .group (2 ))} " ,
286
286
)
287
287
text = text .replace ("левый" , "левая" )
288
288
text = text .replace ("правый" , "правая" )
@@ -307,7 +307,7 @@ def corr_prepared(text, search_result):
307
307
# >>> corr_prepared(" рубленная гигантский крот лёгкие")
308
308
# ' рубленные лёгкие гигантского крота'
309
309
groups = search_result .groups ()
310
- result = text .replace (groups [0 ], "{} {} {}" . format ( groups [1 ], groups [3 ], to_genitive_case (groups [2 ])) )
310
+ result = text .replace (groups [0 ], f" { groups [1 ]} { groups [3 ]} { to_genitive_case (groups [2 ])} " )
311
311
return result
312
312
313
313
@@ -414,14 +414,14 @@ def corr_weapon_trap_parts(text, search_result):
414
414
gender = get_main_word_gender (obj )
415
415
new_adj = inflect_as_adjective (adj , gender )
416
416
new_word_2 = inflect_adjective (make_adjective [material ], gender )
417
- text = text .replace (search_result .group (0 ), "{ } {} {}" . format ( new_adj , new_word_2 , obj ) )
417
+ text = text .replace (search_result .group (0 ), f" { new_adj } { new_word_2 } { obj } " )
418
418
else :
419
419
material = " " .join (words [:3 ])
420
420
obj = " " .join (words [3 :])
421
421
gender = get_main_word_gender (obj )
422
422
assert gender is not None
423
423
new_adj = inflect_as_adjective (adj , gender )
424
- text = text .replace (search_result .group (0 ), "{ } {} {}" . format ( new_adj , obj , material ) )
424
+ text = text .replace (search_result .group (0 ), f" { new_adj } { obj } { material } " )
425
425
return text
426
426
427
427
@@ -632,7 +632,7 @@ def corr_stopped_construction(_, search_result):
632
632
else :
633
633
gen_case_obj = to_genitive_case (obj )
634
634
635
- return ( "{ } приостановили строительство {}.". format ( subj , gen_case_obj )) .capitalize ()
635
+ return f" { subj } приостановили строительство { gen_case_obj } ." .capitalize ()
636
636
637
637
638
638
@final_changes .register (
@@ -655,7 +655,7 @@ def corr_relief(_, search_result):
655
655
if group1 .split (" " )[0 ] == "Мёртвый" :
656
656
text = "Мёртвое деревце ({})" .format ("" .join (search_result .group (0 ).split (" " )[1 :- 1 ]))
657
657
else :
658
- text = "Деревце ({})" . format ( group1 )
658
+ text = f "Деревце ({ group1 } )"
659
659
return text .capitalize ()
660
660
661
661
if " " in group1 :
@@ -688,7 +688,7 @@ def corr_relief(_, search_result):
688
688
text = "{} {} из {}" .format (" " .join (first_words ), obj , " " .join (words ))
689
689
else :
690
690
material = group1
691
- text = "{ } из {}" . format ( obj , to_genitive_case (material ))
691
+ text = f" { obj } из { to_genitive_case (material )} "
692
692
693
693
if "иза" in text :
694
694
text = text .replace (" иза" , "" )
@@ -722,7 +722,7 @@ def corr_adjective_relief(text, search_result):
722
722
gender = get_gender (obj )
723
723
new_word = inflect_adjective (adjective , gender , "nomn" )
724
724
if new_word :
725
- text = "{ } {}" . format ( new_word , obj )
725
+ text = f" { new_word } { obj } "
726
726
727
727
return text .capitalize ()
728
728
@@ -787,7 +787,7 @@ def corr_settlement(_, search_result):
787
787
name = search_result .group (3 )
788
788
789
789
if len (adjective ) == 0 :
790
- return "{} {}" . format ( settlement .capitalize (), name .capitalize ())
790
+ return f" { settlement .capitalize ()} { name .capitalize ()} "
791
791
792
792
if adjective in {"Покинуть" , "Разрушить" }:
793
793
return
@@ -802,7 +802,7 @@ def corr_settlement(_, search_result):
802
802
if adjective_2 is None :
803
803
adjective_2 = adjective
804
804
805
- return "{} {} {}" . format ( adjective_2 .capitalize (), settlement , name .capitalize ())
805
+ return f" { adjective_2 .capitalize ()} { settlement } { name .capitalize ()} "
806
806
807
807
808
808
# Clothier's shop
@@ -845,7 +845,7 @@ def corr_clothiers_shop(_, search_result):
845
845
preposition = "на"
846
846
material = inflect_noun (material , case = "loct" , orig_form = {"nomn" })
847
847
848
- return "{ } {} {} {}" . format ( verb , product , preposition , material )
848
+ return f" { verb } { product } { preposition } { material } "
849
849
else :
850
850
if product in {"щит" , "баклер" }:
851
851
_ , of_material = cloth_subst [material ] # Don't change the verb, leave 'Делать'/'Изготовить'
@@ -860,9 +860,9 @@ def corr_clothiers_shop(_, search_result):
860
860
if material in make_adjective : # "шёлк" -> "шёлковый"
861
861
gender = get_gender (product , {"nomn" })
862
862
material_adj = inflect_adjective (make_adjective [material ], gender , "accs" , animated = False )
863
- return "{ } {} {}" . format ( verb , material_adj , product_accus ) # {Шить} {шёлковую} {робу}
863
+ return f" { verb } { material_adj } { product_accus } " # {Шить} {шёлковую} {робу}
864
864
else :
865
- return "{ } {} {}" . format ( verb , product_accus , of_material ) # {Шить} {робу} {из ткани}
865
+ return f" { verb } { product_accus } { of_material } " # {Шить} {робу} {из ткани}
866
866
867
867
868
868
@final_changes .register (regex = r"(Делать|Изготовить|Украшать)([\w\s/]+)$" )
@@ -903,7 +903,7 @@ def corr_craft_general(text, search_result):
903
903
if len (words ) == 1 and words [0 ] not in make_adjective and not is_adjective (words [0 ]):
904
904
material = inflect_noun (words [0 ], "gent" , orig_form = {"nomn" , "inan" }) # рог -> (из) рога
905
905
assert material is not None
906
- result = "{ } {} из {}" . format ( verb , product , material )
906
+ result = f" { verb } { product } из { material } "
907
907
else :
908
908
adjectives = [
909
909
make_adjective [word ] if word in make_adjective else word if is_adjective (word ) else None
@@ -913,7 +913,7 @@ def corr_craft_general(text, search_result):
913
913
adjectives = [inflect_adjective (adj , product_gender , "accs" , animated = False ) for adj in adjectives ]
914
914
result = "{} {} {}" .format (verb , " " .join (adjectives ), product )
915
915
else :
916
- result = "{ } {}" . format ( verb , product )
916
+ result = f" { verb } { product } "
917
917
918
918
return text .replace (search_result .group (0 ), result ).capitalize ()
919
919
@@ -962,7 +962,7 @@ def corr_animal_material(_, search_result):
962
962
def corr_rings (text , search_result ):
963
963
obj = search_result .group (2 )
964
964
description = search_result .group (1 )
965
- return text .replace (search_result .group (0 ), "{ } из {}" . format ( obj , to_genitive_case (description )) )
965
+ return text .replace (search_result .group (0 ), f" { obj } из { to_genitive_case (description )} " )
966
966
967
967
968
968
@final_changes .register (predicate = lambda text : text .startswith ("Вы нашли из " ))
@@ -983,7 +983,7 @@ def corr_you_struck(text, _):
983
983
else :
984
984
result = inflect_collocation (material , {"accs" })
985
985
986
- return "{ } {}!". format ( you_struck , result )
986
+ return f" { you_struck } { result } !"
987
987
988
988
989
989
@final_changes .register (regex = r"(.+)\s(стал)\s(.+)\." )
@@ -1005,6 +1005,6 @@ def corr_become(_, search_result):
1005
1005
words = search_result .group (3 )
1006
1006
words = inflect_collocation (words , {"ablt" })
1007
1007
if subj .startswith ("Животное" ):
1008
- return "Животное выросло и стало {}." . format ( words )
1009
- else :
1010
- return "{ } {} {}.". format ( subj , verb , words )
1008
+ return f "Животное выросло и стало { words } ."
1009
+
1010
+ return f" { subj } { verb } { words } ."
0 commit comments