Skip to content

Commit

Permalink
final changes to kairyou
Browse files Browse the repository at this point in the history
  • Loading branch information
Bikatr7 committed Feb 18, 2024
1 parent c7d6545 commit 06bb247
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/kairyou/kairyou.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ class Kairyou:
##------------------------/

## Supported types of json files.
## Kudasai is kairyou's native json format. See https://github.com/Bikatr7/Kairyou/blob/main/examples/blank_replacements.json
## Kudasai is kairyou's native json format. See https://github.com/Bikatr7/Kairyou/blob/main/examples/blank_kudasai.json
## Fukuin is the format used by the original onegai processor and kroatoan's Fukuin. See https://github.com/Bikatr7/Kairyou/tree/main/examples/blank_fukuin.json
json_type:typing.Literal["kudasai", "fukuin"] = "kudasai"

## kudasai replacement rules
replacement_rules = [
# (title, json_key, is_name, replace_name, honorific_type)
('Punctuation', 'kutouten', False, None, None),
Expand Down Expand Up @@ -106,6 +107,7 @@ def validate_replacement_json() -> None:

Kairyou.json_type = "fukuin"

## fukuin replacement rules
Kairyou.replacement_rules = [
# title, json_key, is_name, replace_name, honorific_type
('Special', 'specials', False, None, None),
Expand All @@ -128,6 +130,8 @@ def reset_globals() -> None:
Resets the global variables.
Resets both logs, the total replacements, json type, and replacement rules to their default values: Empty strings, 0, and Kudasai type respectively.
"""

Kairyou.preprocessing_log = ""
Expand All @@ -136,6 +140,22 @@ def reset_globals() -> None:
Kairyou.total_replacements = 0

Kairyou.json_type = "kudasai"

Kairyou.replacement_rules = [
# (title, json_key, is_name, replace_name, honorific_type)
('Punctuation', 'kutouten', False, None, None),
('Unicode', 'unicode', False, None, None),
('Phrases', 'phrases', False, None, None),
('Words', 'single_words', False, None, None),
('Enhanced Check Whitelist', 'enhanced_check_whitelist',
True, ReplacementType.ALL_NAMES, ReplacementType.ALL_NAMES),
('Full ReplacementType', 'full_names', True,
ReplacementType.ALL_NAMES, ReplacementType.ALL_NAMES),
('Single ReplacementType', 'single_names', True,
ReplacementType.ALL_NAMES, ReplacementType.ALL_NAMES),
('Name Like', 'name_like', True,
ReplacementType.ALL_NAMES, ReplacementType.NONE),
]

##-------------------start-of-preprocess()---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -218,7 +238,7 @@ def replace_non_katakana(replaced_names: dict) -> None:
Handles non-katakana replacements.
Parameters:
replaced_names (dict - str) : ReplacementType we have replaced.
replaced_names (dict - str) : Names that have been replaced.
"""

Expand Down Expand Up @@ -276,7 +296,7 @@ def replace_katakana(replaced_names: dict) -> None:
Handles katakana replacements.
Parameters:
replaced_names (dict - str) : ReplacementType we have replaced.
replaced_names (dict - str) : Names we have replaced.
"""

Expand Down

0 comments on commit 06bb247

Please sign in to comment.