diff --git a/df_translation_toolkit/utils/df_ignore_string_rules.py b/df_translation_toolkit/utils/df_ignore_string_rules.py index a49b08f..60b6555 100644 --- a/df_translation_toolkit/utils/df_ignore_string_rules.py +++ b/df_translation_toolkit/utils/df_ignore_string_rules.py @@ -102,6 +102,26 @@ def ignore_dash_prepended_strings(string: str) -> bool: return re.fullmatch(r"-[a-z0-9_]+-?", string) is not None +@rules.register +def ignore_dash_separated_words(string: str) -> bool: + if " " in string: + return False + + if "-" not in string: + return False + + parts = string.split("-") + for part in parts: + if not part or not (part.islower() or part.isnumeric()): + return False + + if len(parts) >= 3: # noqa: PLR2004 + return True + + ending = parts[-1] + return ending.isnumeric() or ending in ("on", "off", "log", "gtr", "rtm") + + @rules.register def ignore_mixed_case(string: str) -> bool: return re.search(r"[a-z]+[A-Z]", string) is not None diff --git a/tests/test_df_ignore_string_rules.py b/tests/test_df_ignore_string_rules.py index 8d5f30c..51298ec 100644 --- a/tests/test_df_ignore_string_rules.py +++ b/tests/test_df_ignore_string_rules.py @@ -64,6 +64,9 @@ (rules.ignore_underline_separated_words, "_Thrd_id", True), (rules.ignore_underline_separated_words, "_initterm_e", True), (rules.ignore_underline_separated_words, "init_sound returned false!", True), + (rules.ignore_dash_separated_words, "piano-pluck-main", True), + (rules.ignore_dash_separated_words, "gtr-2", True), + (rules.ignore_dash_separated_words, "clouds-off", True), (rules.ignore_dash_prepended_strings, "-world_sites_and_pops", True), (rules.ignore_dash_prepended_strings, "-site_map-", True), (rules.ignore_dash_prepended_strings, "-beta23", True),