From 06bb5c47a60e85cd0809fab51d0652a213c38c88 Mon Sep 17 00:00:00 2001 From: sanj <67624670+iodrift@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:43:33 -0700 Subject: [PATCH] Auto-update: Thu Oct 31 16:43:33 PDT 2024 --- camel | 103 +++++++++++++++++++++++ emoji-flag => emoji_flag | 0 import-finder => import_finder | 0 mamba-exporter => mamba_exporter | 0 mamba-importer => mamba_importer | 0 nocomment | 0 tmux-merge => tmux_merge | 0 txt-line-merge-abc => txt_line_merge_abc | 0 8 files changed, 103 insertions(+) create mode 100755 camel rename emoji-flag => emoji_flag (100%) rename import-finder => import_finder (100%) rename mamba-exporter => mamba_exporter (100%) rename mamba-importer => mamba_importer (100%) mode change 100644 => 100755 nocomment rename tmux-merge => tmux_merge (100%) rename txt-line-merge-abc => txt_line_merge_abc (100%) diff --git a/camel b/camel new file mode 100755 index 0000000..a0abd2b --- /dev/null +++ b/camel @@ -0,0 +1,103 @@ +#!/usr/bin/env python3 +import re +import os +import nltk +from nltk.corpus import words +from nltk.corpus import wordnet + +try: + word_list = words.words() + nltk.download('wordnet') +except LookupError: + nltk.download('words') + nltk.download('wordnet') + word_list = words.words() + +word_set = set(word.lower() for word in word_list) +common_words = ['and', 'in', 'the', 'of', 'to', 'at', 'by', 'for', 'with', 'from'] +always_valid = {'the', 'a', 'an', 'and', 'or', 'but', 'nor', 'for', 'yet', 'so'} + +def is_word(word): + if word.lower() in always_valid: + print(f" Checking if '{word}' is in dictionary: True (common word)") + return True + + in_words = word.lower() in word_set + in_wordnet = bool(wordnet.synsets(word)) + result = in_words and in_wordnet + print(f" Checking if '{word}' is in dictionary: {result} (words:{in_words}, wordnet:{in_wordnet})") + return result + +def process_word(word): + print(f"\nProcessing word: '{word}'") + + if is_word(word): + print(f" '{word}' is in dictionary, returning as-is") + return word + + print(f" '{word}' not in dictionary, checking for common words at end...") + for common in common_words: + if word.lower().endswith(common): + print(f" Found '{common}' at end of '{word}'") + remainder = word[:-len(common)] + common_case = word[-len(common):] + print(f" Recursively processing remainder: '{remainder}'") + return f"{process_word(remainder)} {common_case}" + + print(f" No common words found at end of '{word}'") + + match = re.search(r'([a-zA-Z]+)(\d+)$', word) + if match: + text, num = match.groups() + print(f" Found number at end: '{text}' + '{num}'") + if is_word(text): + return f"{text} {num}" + + print(f" Returning '{word}' unchanged") + return word + +def split_filename(filename): + print(f"\nProcessing filename: {filename}") + base = os.path.splitext(filename)[0] + ext = os.path.splitext(filename)[1] + + print(f"Splitting on delimiters...") + parts = re.split('([_\-\s])', base) + + result = [] + for part in parts: + if part in '_-': + result.append(' ') + else: + print(f"\nSplitting on capitals: {part}") + words = re.split('(? {new_name}") + except OSError as e: + print(f"Error renaming {filename}: {e}") + +if __name__ == "__main__": + main() + diff --git a/emoji-flag b/emoji_flag similarity index 100% rename from emoji-flag rename to emoji_flag diff --git a/import-finder b/import_finder similarity index 100% rename from import-finder rename to import_finder diff --git a/mamba-exporter b/mamba_exporter similarity index 100% rename from mamba-exporter rename to mamba_exporter diff --git a/mamba-importer b/mamba_importer similarity index 100% rename from mamba-importer rename to mamba_importer diff --git a/nocomment b/nocomment old mode 100644 new mode 100755 diff --git a/tmux-merge b/tmux_merge similarity index 100% rename from tmux-merge rename to tmux_merge diff --git a/txt-line-merge-abc b/txt_line_merge_abc similarity index 100% rename from txt-line-merge-abc rename to txt_line_merge_abc