diff --git a/kss/__init__.py b/kss/__init__.py index 5c99482..ec31e64 100644 --- a/kss/__init__.py +++ b/kss/__init__.py @@ -6,4 +6,4 @@ from kss._modules.summarization.summarize_sentences import summarize_sentences __ALL__ = [split_sentences, split_morphemes, summarize_sentences] -__version__ = "4.5.1" +__version__ = "4.5.2" diff --git a/kss/_modules/sentences/sentence_processor.py b/kss/_modules/sentences/sentence_processor.py index e2baf88..9d53916 100644 --- a/kss/_modules/sentences/sentence_processor.py +++ b/kss/_modules/sentences/sentence_processor.py @@ -6,7 +6,6 @@ from kss._utils.const import ( alphabet_with_quotes, - numbers_with_quotes, url_pattern, email_pattern, backup_normal, @@ -19,12 +18,6 @@ class SentenceProcessor: _all_s_poses_wo_qtn = ("SP", "SF", "SY", "SE", "SSC", "QTC", "EMOJI", "JAMO") _heavy_backup = {} - _heavy_backup.update( - { - k: {_v: str(abs(hash(_v))) for _v in v} - for k, v in numbers_with_quotes.items() - } - ) _heavy_backup.update( { k: {_v: str(abs(hash(_v))) for _v in v} @@ -58,21 +51,23 @@ def _add_url_or_email(self, text): } self._normal_backup.update(_url_or_email) - def _backup_or_restore_heavy(self, target: str, check: str, restore: bool = False): - for source, purpose_dict in self._heavy_backup.items(): - if source in check: - target = self._replace(target, purpose_dict, restore=restore) - return target - @lru_cache(100) def backup(self, inputs: str): self._add_url_or_email(inputs) inputs = self._replace(inputs, self._normal_backup) - inputs = self._backup_or_restore_heavy(inputs, inputs) + + for source, purpose_dict in self._heavy_backup.items(): + if source in inputs: + inputs = self._replace(inputs, purpose_dict, restore=False) + return inputs @lru_cache(100) def restore(self, outputs: str, inputs: str): outputs = self._replace(outputs, self._normal_backup, restore=True) - outputs = self._backup_or_restore_heavy(outputs, inputs, restore=True) + + for source, purpose_dict in self._heavy_backup.items(): + if source in inputs: + outputs = self._replace(outputs, purpose_dict, restore=True) + return outputs diff --git a/kss/_utils/const.py b/kss/_utils/const.py index 044c720..058030e 100644 --- a/kss/_utils/const.py +++ b/kss/_utils/const.py @@ -279,16 +279,6 @@ ] -# inch: 3'2 inch -# time: 06'30 -# year: '60s -numbers_with_quotes = {} -for num in numbers: - numbers_with_quotes[num] = set() - numbers_with_quotes[num].update({f"{num}{q}" for q in ["'", "’"]}) - numbers_with_quotes[num].update({f"{q}{num}" for q in ["'", "’"]}) - - # apostrophe: I`m, You’re, ... alphabet_with_quotes = {} for alpha in alphabets: