6
6
7
7
from kss ._utils .const import (
8
8
alphabet_with_quotes ,
9
- numbers_with_quotes ,
10
9
url_pattern ,
11
10
email_pattern ,
12
11
backup_normal ,
@@ -19,12 +18,6 @@ class SentenceProcessor:
19
18
_all_s_poses_wo_qtn = ("SP" , "SF" , "SY" , "SE" , "SSC" , "QTC" , "EMOJI" , "JAMO" )
20
19
21
20
_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
- )
28
21
_heavy_backup .update (
29
22
{
30
23
k : {_v : str (abs (hash (_v ))) for _v in v }
@@ -58,21 +51,23 @@ def _add_url_or_email(self, text):
58
51
}
59
52
self ._normal_backup .update (_url_or_email )
60
53
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
-
67
54
@lru_cache (100 )
68
55
def backup (self , inputs : str ):
69
56
self ._add_url_or_email (inputs )
70
57
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
+
72
63
return inputs
73
64
74
65
@lru_cache (100 )
75
66
def restore (self , outputs : str , inputs : str ):
76
67
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
+
78
73
return outputs
0 commit comments