66
77from kss ._utils .const import (
88 alphabet_with_quotes ,
9- numbers_with_quotes ,
109 url_pattern ,
1110 email_pattern ,
1211 backup_normal ,
@@ -19,12 +18,6 @@ class SentenceProcessor:
1918 _all_s_poses_wo_qtn = ("SP" , "SF" , "SY" , "SE" , "SSC" , "QTC" , "EMOJI" , "JAMO" )
2019
2120 _heavy_backup = {}
22- _heavy_backup .update (
23- {
24- k : {_v : str (abs (hash (_v ))) for _v in v }
25- for k , v in numbers_with_quotes .items ()
26- }
27- )
2821 _heavy_backup .update (
2922 {
3023 k : {_v : str (abs (hash (_v ))) for _v in v }
@@ -58,21 +51,23 @@ def _add_url_or_email(self, text):
5851 }
5952 self ._normal_backup .update (_url_or_email )
6053
61- def _backup_or_restore_heavy (self , target : str , check : str , restore : bool = False ):
62- for source , purpose_dict in self ._heavy_backup .items ():
63- if source in check :
64- target = self ._replace (target , purpose_dict , restore = restore )
65- return target
66-
6754 @lru_cache (100 )
6855 def backup (self , inputs : str ):
6956 self ._add_url_or_email (inputs )
7057 inputs = self ._replace (inputs , self ._normal_backup )
71- inputs = self ._backup_or_restore_heavy (inputs , inputs )
58+
59+ for source , purpose_dict in self ._heavy_backup .items ():
60+ if source in inputs :
61+ inputs = self ._replace (inputs , purpose_dict , restore = False )
62+
7263 return inputs
7364
7465 @lru_cache (100 )
7566 def restore (self , outputs : str , inputs : str ):
7667 outputs = self ._replace (outputs , self ._normal_backup , restore = True )
77- outputs = self ._backup_or_restore_heavy (outputs , inputs , restore = True )
68+
69+ for source , purpose_dict in self ._heavy_backup .items ():
70+ if source in inputs :
71+ outputs = self ._replace (outputs , purpose_dict , restore = True )
72+
7873 return outputs
0 commit comments