codeShare commited on
Commit
06e4bc6
·
verified ·
1 Parent(s): 888d27d

Upload tag_randomizer.ipynb

Browse files
Files changed (1) hide show
  1. tag_randomizer.ipynb +1 -1
tag_randomizer.ipynb CHANGED
@@ -1 +1 @@
1
- {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/tag_randomizer.ipynb","timestamp":1756583352986},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/tag_randomizer.ipynb","timestamp":1756465686090}],"authorship_tag":"ABX9TyMbP/sC00DF0IOlKj8fkL9D"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","source":["import os\n","import random\n","import string\n","from google.colab import files\n","\n","# Create output directory if it doesn't exist\n","output_dir = '/content/output/'\n","os.makedirs(output_dir, exist_ok=True)\n","\n","# Upload text files\n","print(\"Please upload your text files:\")\n","uploaded = files.upload()\n","\n","# Process uploaded files\n","all_items = []\n","for filename, content in uploaded.items():\n"," if filename.endswith('.txt'):\n"," # Decode content and treat entire file content as one item, removing trailing whitespace\n"," file_content = content.decode('utf-8').rstrip()\n"," if file_content: # Only add non-empty content\n"," # Replace newlines with empty string\n"," file_content = file_content.replace('\\n', '')\n"," # Replace double quotes with single quotes\n"," file_content = file_content.replace('\"', \"'\")\n"," # Remove specified symbols: {}, [], ^\n"," for symbol in '{}[]^':\n"," file_content = file_content.replace(symbol, '')\n"," all_items.append(file_content)\n","\n","# Join items with '|' separator\n","combined_text = '|'.join(all_items)\n","\n","# Generate random filename (e.g., 8 characters long)\n","random_filename = ''.join(random.choices(string.ascii_lowercase + string.digits, k=8)) + '.txt'\n","output_path = os.path.join(output_dir, random_filename)\n","\n","# Write combined text to output file\n","with open(output_path, 'w') as f:\n"," f.write(combined_text)\n","\n","print(f\"Combined text saved to: {output_path}\")\n","print(f\"Content: {combined_text}\")\n","\n","# Optional: Display the output file content\n","with open(output_path, 'r') as f:\n"," print(f\"Verified content from file: {f.read()}\")"],"metadata":{"id":"rIBdbHYDhKvE"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["# Import required library\n","import random\n","\n","# Input text\n","input_text = 'A,B,C|D,E,F|G,H,I' #@param {type:'string'}\n","\n","# Split the text into groups\n","groups = input_text.split('|')\n","\n","# Randomize letters within each group\n","randomized_groups = []\n","for group in groups:\n"," letters = group.split(',')\n"," random.shuffle(letters)\n"," randomized_groups.append(','.join(letters))\n","\n","# Join the groups back together\n","output_text = '|'.join(randomized_groups)\n","\n","# Write to a text file\n","with open('randomized_output.txt', 'w') as file:\n"," file.write(output_text)\n","\n","# Print the result to verify\n","print(\"Randomized output:\", output_text)\n","\n","# Download the file in Colab\n","from google.colab import files\n","files.download('randomized_output.txt')"],"metadata":{"id":"XifDdzLoC-P2"},"execution_count":null,"outputs":[]}]}
 
1
+ {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/tag_randomizer.ipynb","timestamp":1756665629195},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/tag_randomizer.ipynb","timestamp":1756583352986},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/tag_randomizer.ipynb","timestamp":1756465686090}],"authorship_tag":"ABX9TyM+i3seWqjEpfyz4moPXDqv"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","source":["import os\n","import random\n","import string\n","from google.colab import files\n","\n","# Create output directory if it doesn't exist\n","output_dir = '/content/output/'\n","os.makedirs(output_dir, exist_ok=True)\n","\n","# Upload text files\n","print(\"Please upload your text files:\")\n","uploaded = files.upload()\n","\n","# Process uploaded files\n","all_items = []\n","for filename, content in uploaded.items():\n"," if filename.endswith('.txt'):\n"," # Decode content and treat entire file content as one item, removing trailing whitespace\n"," file_content = content.decode('utf-8').rstrip()\n"," if file_content: # Only add non-empty content\n"," # Replace newlines with empty string\n"," file_content = file_content.replace('\\n', ' ')\n"," # Replace double quotes with single quotes\n"," file_content = file_content.replace('\"', \"'\")\n"," # Remove specified symbols: {}, [], ^\n"," for symbol in '{}[]^':\n"," file_content = file_content.replace(symbol, '')\n"," all_items.append(file_content)\n","\n","# Join items with '|' separator\n","combined_text = '|'.join(all_items)\n","\n","# Generate random filename (e.g., 8 characters long)\n","random_filename = ''.join(random.choices(string.ascii_lowercase + string.digits, k=8)) + '.txt'\n","output_path = os.path.join(output_dir, random_filename)\n","\n","# Write combined text to output file\n","with open(output_path, 'w') as f:\n"," f.write(combined_text)\n","\n","print(f\"Combined text saved to: {output_path}\")\n","print(f\"Content: {combined_text}\")\n","\n","# Optional: Display the output file content\n","with open(output_path, 'r') as f:\n"," print(f\"Verified content from file: {f.read()}\")"],"metadata":{"id":"rIBdbHYDhKvE"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["# Import required library\n","import random\n","\n","# Input text\n","input_text = 'A,B,C|D,E,F|G,H,I' #@param {type:'string'}\n","\n","# Split the text into groups\n","groups = input_text.split('|')\n","\n","# Randomize letters within each group\n","randomized_groups = []\n","for group in groups:\n"," letters = group.split(',')\n"," random.shuffle(letters)\n"," randomized_groups.append(','.join(letters))\n","\n","# Join the groups back together\n","output_text = '|'.join(randomized_groups)\n","\n","# Write to a text file\n","with open('randomized_output.txt', 'w') as file:\n"," file.write(output_text)\n","\n","# Print the result to verify\n","print(\"Randomized output:\", output_text)\n","\n","# Download the file in Colab\n","from google.colab import files\n","files.download('randomized_output.txt')"],"metadata":{"id":"XifDdzLoC-P2"},"execution_count":null,"outputs":[]}]}