{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Processing chunk... Rows: 10000000\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9999999\n", "--- Duplicates Deleted\t\t\t--> Rows: 9999306\n", "--- Source-Copied Rows Deleted\t\t--> Rows: 9999302\n", "--- Too Long Source/Target Deleted\t--> Rows: 9889531\n", "--- HTML Removed\t\t\t--> Rows: 9889531\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9889521\n", "--- Rows Shuffled\t\t\t--> Rows: 9889521\n", "Processing chunk... Rows: 10000000\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9999997\n", "--- Duplicates Deleted\t\t\t--> Rows: 9999354\n", "--- Source-Copied Rows Deleted\t\t--> Rows: 9999348\n", "--- Too Long Source/Target Deleted\t--> Rows: 9893544\n", "--- HTML Removed\t\t\t--> Rows: 9893544\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9893537\n", "--- Rows Shuffled\t\t\t--> Rows: 9893537\n", "Processing chunk... Rows: 10000000\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9999998\n", "--- Duplicates Deleted\t\t\t--> Rows: 9999360\n", "--- Source-Copied Rows Deleted\t\t--> Rows: 9999357\n", "--- Too Long Source/Target Deleted\t--> Rows: 9898546\n", "--- HTML Removed\t\t\t--> Rows: 9898546\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9898539\n", "--- Rows Shuffled\t\t\t--> Rows: 9898539\n", "Processing chunk... Rows: 10000000\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9999999\n", "--- Duplicates Deleted\t\t\t--> Rows: 9999183\n", "--- Source-Copied Rows Deleted\t\t--> Rows: 9999182\n", "--- Too Long Source/Target Deleted\t--> Rows: 9959799\n", "--- HTML Removed\t\t\t--> Rows: 9959799\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9959797\n", "--- Rows Shuffled\t\t\t--> Rows: 9959797\n", "Processing chunk... Rows: 10000000\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9999998\n", "--- Duplicates Deleted\t\t\t--> Rows: 9999392\n", "--- Source-Copied Rows Deleted\t\t--> Rows: 9999389\n", "--- Too Long Source/Target Deleted\t--> Rows: 9961466\n", "--- HTML Removed\t\t\t--> Rows: 9961466\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9961453\n", "--- Rows Shuffled\t\t\t--> Rows: 9961453\n", "Processing chunk... Rows: 10000000\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9999999\n", "--- Duplicates Deleted\t\t\t--> Rows: 9999207\n", "--- Source-Copied Rows Deleted\t\t--> Rows: 9999203\n", "--- Too Long Source/Target Deleted\t--> Rows: 9874636\n", "--- HTML Removed\t\t\t--> Rows: 9874636\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9874635\n", "--- Rows Shuffled\t\t\t--> Rows: 9874635\n", "Processing chunk... Rows: 10000000\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9999999\n", "--- Duplicates Deleted\t\t\t--> Rows: 9999084\n", "--- Source-Copied Rows Deleted\t\t--> Rows: 9999080\n", "--- Too Long Source/Target Deleted\t--> Rows: 9761122\n", "--- HTML Removed\t\t\t--> Rows: 9761122\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9761122\n", "--- Rows Shuffled\t\t\t--> Rows: 9761122\n", "Processing chunk... Rows: 10000000\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9999999\n", "--- Duplicates Deleted\t\t\t--> Rows: 9999366\n", "--- Source-Copied Rows Deleted\t\t--> Rows: 9999342\n", "--- Too Long Source/Target Deleted\t--> Rows: 9551684\n", "--- HTML Removed\t\t\t--> Rows: 9551684\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9551683\n", "--- Rows Shuffled\t\t\t--> Rows: 9551683\n", "Processing chunk... Rows: 10000000\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9999999\n", "--- Duplicates Deleted\t\t\t--> Rows: 9999409\n", "--- Source-Copied Rows Deleted\t\t--> Rows: 9999385\n", "--- Too Long Source/Target Deleted\t--> Rows: 9513043\n", "--- HTML Removed\t\t\t--> Rows: 9513043\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9513040\n", "--- Rows Shuffled\t\t\t--> Rows: 9513040\n", "Processing chunk... Rows: 10000000\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9999998\n", "--- Duplicates Deleted\t\t\t--> Rows: 9999395\n", "--- Source-Copied Rows Deleted\t\t--> Rows: 9999391\n", "--- Too Long Source/Target Deleted\t--> Rows: 9910026\n", "--- HTML Removed\t\t\t--> Rows: 9910026\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9910017\n", "--- Rows Shuffled\t\t\t--> Rows: 9910017\n", "Processing chunk... Rows: 10000000\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9999999\n", "--- Duplicates Deleted\t\t\t--> Rows: 9999383\n", "--- Source-Copied Rows Deleted\t\t--> Rows: 9999381\n", "--- Too Long Source/Target Deleted\t--> Rows: 9782818\n", "--- HTML Removed\t\t\t--> Rows: 9782818\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9782806\n", "--- Rows Shuffled\t\t\t--> Rows: 9782806\n", "Processing chunk... Rows: 10000000\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9999999\n", "--- Duplicates Deleted\t\t\t--> Rows: 9999379\n", "--- Source-Copied Rows Deleted\t\t--> Rows: 9999378\n", "--- Too Long Source/Target Deleted\t--> Rows: 9745191\n", "--- HTML Removed\t\t\t--> Rows: 9745191\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9745182\n", "--- Rows Shuffled\t\t\t--> Rows: 9745182\n", "Processing chunk... Rows: 10000000\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9999999\n", "--- Duplicates Deleted\t\t\t--> Rows: 9999165\n", "--- Source-Copied Rows Deleted\t\t--> Rows: 9999163\n", "--- Too Long Source/Target Deleted\t--> Rows: 9846325\n", "--- HTML Removed\t\t\t--> Rows: 9846325\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9846324\n", "--- Rows Shuffled\t\t\t--> Rows: 9846324\n", "Processing chunk... Rows: 10000000\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9999999\n", "--- Duplicates Deleted\t\t\t--> Rows: 9999164\n", "--- Source-Copied Rows Deleted\t\t--> Rows: 9999163\n", "--- Too Long Source/Target Deleted\t--> Rows: 9845725\n", "--- HTML Removed\t\t\t--> Rows: 9845725\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9845724\n", "--- Rows Shuffled\t\t\t--> Rows: 9845724\n", "Processing chunk... Rows: 10000000\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9999995\n", "--- Duplicates Deleted\t\t\t--> Rows: 9993169\n", "--- Source-Copied Rows Deleted\t\t--> Rows: 9993055\n", "--- Too Long Source/Target Deleted\t--> Rows: 9858406\n", "--- HTML Removed\t\t\t--> Rows: 9858406\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9858405\n", "--- Rows Shuffled\t\t\t--> Rows: 9858405\n", "Processing chunk... Rows: 10000000\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9999994\n", "--- Duplicates Deleted\t\t\t--> Rows: 9978650\n", "--- Source-Copied Rows Deleted\t\t--> Rows: 9978453\n", "--- Too Long Source/Target Deleted\t--> Rows: 9869161\n", "--- HTML Removed\t\t\t--> Rows: 9869161\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9869159\n", "--- Rows Shuffled\t\t\t--> Rows: 9869159\n", "Processing chunk... Rows: 10000000\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9999988\n", "--- Duplicates Deleted\t\t\t--> Rows: 9977991\n", "--- Source-Copied Rows Deleted\t\t--> Rows: 9977875\n", "--- Too Long Source/Target Deleted\t--> Rows: 9811295\n", "--- HTML Removed\t\t\t--> Rows: 9811295\n", "--- Rows with Empty Cells Deleted\t--> Rows: 9811287\n", "--- Rows Shuffled\t\t\t--> Rows: 9811287\n", "Processing chunk... Rows: 6353792\n", "--- Rows with Empty Cells Deleted\t--> Rows: 6353790\n", "--- Duplicates Deleted\t\t\t--> Rows: 6353120\n", "--- Source-Copied Rows Deleted\t\t--> Rows: 6353114\n", "--- Too Long Source/Target Deleted\t--> Rows: 6178129\n", "--- HTML Removed\t\t\t--> Rows: 6178129\n", "--- Rows with Empty Cells Deleted\t--> Rows: 6178124\n", "--- Rows Shuffled\t\t\t--> Rows: 6178124\n", "Processing complete. Filtered files saved as: train_cleaned.src-filtered.src train.tgt-filtered.tgt\n" ] } ], "source": [ "import pandas as pd\n", "import numpy as np\n", "import csv\n", "import sys\n", "\n", "def process_chunk(chunk, source_lang, target_lang, lower=False):\n", " # Drop nan\n", " chunk = chunk.dropna()\n", " print(\"--- Rows with Empty Cells Deleted\\t--> Rows:\", chunk.shape[0])\n", "\n", " # Drop duplicates\n", " chunk = chunk.drop_duplicates()\n", " print(\"--- Duplicates Deleted\\t\\t\\t--> Rows:\", chunk.shape[0])\n", "\n", " # Drop copy-source rows\n", " chunk[\"Source-Copied\"] = chunk['Source'] == chunk['Target']\n", " chunk = chunk.set_index(['Source-Copied'])\n", " chunk = chunk.drop([True], errors='ignore')\n", " chunk = chunk.reset_index()\n", " chunk = chunk.drop(['Source-Copied'], axis=1)\n", " print(\"--- Source-Copied Rows Deleted\\t\\t--> Rows:\", chunk.shape[0])\n", "\n", " # Drop too-long rows (source or target)\n", " chunk[\"Too-Long\"] = ((chunk['Source'].str.count(' ')+1) > (chunk['Target'].str.count(' ')+1) * 2) | \\\n", " ((chunk['Target'].str.count(' ')+1) > (chunk['Source'].str.count(' ')+1) * 2) | \\\n", " ((chunk['Source'].str.count(' ')+1) > 200) | \\\n", " ((chunk['Target'].str.count(' ')+1) > 200)\n", "\n", " chunk = chunk.set_index(['Too-Long'])\n", " chunk = chunk.drop([True], errors='ignore')\n", " chunk = chunk.reset_index()\n", " chunk = chunk.drop(['Too-Long'], axis=1)\n", " print(\"--- Too Long Source/Target Deleted\\t--> Rows:\", chunk.shape[0])\n", "\n", " # Remove HTML and normalize\n", " chunk = chunk.replace(r'<.*?>|<.*?>|&?(amp|nbsp|quot);|{}', ' ', regex=True)\n", " chunk = chunk.replace(r' ', ' ', regex=True)\n", " print(\"--- HTML Removed\\t\\t\\t--> Rows:\", chunk.shape[0])\n", "\n", " # Lower-case the data if specified\n", " if lower:\n", " chunk['Source'] = chunk['Source'].str.lower()\n", " chunk['Target'] = chunk['Target'].str.lower()\n", " print(\"--- Rows are now lower-cased\\t\\t--> Rows:\", chunk.shape[0])\n", "\n", " # Replace empty cells with NaN and delete them\n", " chunk = chunk.replace(r'^\\s*$', np.nan, regex=True)\n", " chunk = chunk.dropna()\n", " print(\"--- Rows with Empty Cells Deleted\\t--> Rows:\", chunk.shape[0])\n", "\n", " # Shuffle the data\n", " chunk = chunk.sample(frac=1).reset_index(drop=True)\n", " print(\"--- Rows Shuffled\\t\\t\\t--> Rows:\", chunk.shape[0])\n", "\n", " return chunk\n", "\n", "def filter_and_save(source_file, target_file, source_lang, target_lang, chunk_size=100000, lower=False):\n", " # Open output files for source and target\n", " source_file_out = source_file + '-filtered.' + source_lang\n", " target_file_out = target_file + '-filtered.' + target_lang\n", "\n", " with open(source_file_out, 'w', encoding='utf-8', newline='') as source_out, \\\n", " open(target_file_out, 'w', encoding='utf-8', newline='') as target_out:\n", " \n", " source_writer = csv.writer(source_out, delimiter='\\n')\n", " target_writer = csv.writer(target_out, delimiter='\\n')\n", "\n", " # Process the source and target files in chunks\n", " for chunk_source, chunk_target in zip(pd.read_csv(source_file, names=['Source'], sep=\"\\0\", quoting=csv.QUOTE_NONE, skip_blank_lines=False, on_bad_lines=\"skip\", chunksize=chunk_size),\n", " pd.read_csv(target_file, names=['Target'], sep=\"\\0\", quoting=csv.QUOTE_NONE, skip_blank_lines=False, on_bad_lines=\"skip\", chunksize=chunk_size)):\n", " \n", " # Concatenate source and target data\n", " df = pd.concat([chunk_source, chunk_target], axis=1)\n", " print(\"Processing chunk... Rows:\", df.shape[0])\n", "\n", " # Filter and process the chunk\n", " filtered_chunk = process_chunk(df, source_lang, target_lang, lower)\n", "\n", " # Write the filtered chunk to the output files\n", " filtered_chunk['Source'].to_csv(source_out, header=False, index=False, quoting=csv.QUOTE_NONE, sep=\"\\n\")\n", " filtered_chunk['Target'].to_csv(target_out, header=False, index=False, quoting=csv.QUOTE_NONE, sep=\"\\n\")\n", " \n", " print(\"Processing complete. Filtered files saved as:\", source_file_out, target_file_out)\n", "\n", "if __name__ == '__main__':\n", " # Corpora details\n", " source_file = \"train.eng_Latn\" # path to the source file\n", " target_file = \"train.guj_Gujr\" # path to the target file\n", " source_lang = \"en\" # source language\n", " target_lang = \"gu\" # target language\n", " \n", " # Run the filter_and_save function\n", " filter_and_save(source_file, target_file, source_lang, target_lang, chunk_size=10000000, lower=False)\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import os" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'/home/vikrant-MNMT/myenv/BPCC/inline_tages'" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pwd" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "os.chdir(\"/home/vikrant-MNMT/myenv/BPCC/inline_tages/eng_Latn-guj_Gujr\")" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'/home/vikrant-MNMT/myenv/NMT_V2'" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pwd" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Did you want to find it?\n", "I have read all of the letters sent to me.\n", "यदि आपके पास कोई दिलचस्पी वाले उत्पाद हैं, जिन्हें उत्पादित करने की आवश्यकता है, तो कृपया मुझसे संपर्क करने के लिए स्वतंत्र महसूस करें, यह आपकी सेवा करने की मेरी खुशी है।\n", "તેને ધ્યાનમાં રાખતા સ્વાસ્થ્ય અને પરિવાર કલ્યાણ મંત્રાલેય વિદેશથી પ્રવાસ કરીને ભારત આવનારા માટે નવા નિયમ બહાર પાડ્યા છે.\n", "“A discussion and debate should be held on this.\n", "At least seven to eight ministers could be inducted into Chief Minister Yogi Adityanath's cabinet.\n", "95% of primary schools do not have computers\n", "Sample rate:\n", "ಈ ಸಮಯದಲ್ಲಿ ಶೌಚಾಲಯಗಳು ಮುಚ್ಚಲ್ಪಟ್ಟಿವೆ.\n", "For reasons of transparency, we point out that we use Google Tag Manager.\n", "18 Find The Best View From The Lion's Gate Bridge\n", "If there's anything you need, tell me and I'll grab it.\n", "यदि आप छोड़ने के तरीकों में रुचि रखते हैं, तो कोशिश करने के नए तरीके हैं, जैसे निकोटिन रिप्लेसमेंट थेरेपी।\n", "Share His Music to the World\n", "I take my children with me.\n", "କିନ୍ତୁ ଆଜି ସକାଳେ ସେ ଆସିନଥିଲେ ।\n", "Regardless of what kind of relationship it is.\n", "എല്ലാ വർഷവും ഞാൻ ഇതിൽ പങ്കെടുക്കാറുണ്ട്.\n", "5 Signs You're Going To Get Cheated On\n", "\"কারখানা সেটিংস পুনরুদ্ধার করার জন্য, এখানে আপনাকে \"\"রিসেট ডিভাইস\"\" বাটনে ক্লিক করতে হবে।\"\n" ] } ], "source": [ "!head -n 20 train_aggressively_shuffled.tgt" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "क्या आप इसे खोजना चाहते थे?\n", "എനിക്ക് വേണ്ടി കിട്ടിയിരുന്ന എല്ലാ കത്തുകളും ഞാൻ വായിച്ചിട്ടുണ്ട്.\n", "If you have any interested products that need to be produced, please feel free to contact me, it's my pleasure to serve you\n", "In view of this, the Ministry of Health and Family Welfare has issued a new rule for those coming to India from abroad.\n", "ਉਨ੍ਹਾਂ ਕਿਹਾ ਕਿ ਇਸ ਸਬੰਧੀ ਬਹਿਸ ਜ਼ਰੂਰ ਹੋਣੀ ਚਾਹੀਦੀ ਹੈ।\n", "मुख्यमंत्री योगी आदित्यनाथ की कैबिनेट में कम से कम सात से आठ मंत्रियों को शामिल किया जा सकता है।\n", "৯২ ভাগ স্কুলে নেই কম্পিউটার সুবিধা\n", "নমুনা হাৰ:\n", "Restrooms are closed at this time.\n", "पारदर्शकतेच्या कारणास्तव कृपया लक्षात घ्या की आम्ही Google टॅग व्यवस्थापक वापरतो.\n", "18 शेर के गेट ब्रिज से सबसे अच्छा दृश्य खोजें\n", "आपको किसी चीज की जरूरत है तो मुझे बता दो, मैं ला दूंगा।\n", "If you're interested in ways to quit, there are new methods to try, such as nicotine replacement therapy.\n", "अपने संगीत को दुनिया के साथ साझा करें\n", "ನನ್ನ ಮಕ್ಕಳನ್ನೂ ನನ್ನ ಜೊತೆ ಕರೆದುಕೊಂಡು ಹೋಗುತ್ತಿದ್ದೇನೆ.\n", "He was not here this morning.\n", "তা সে যে ধরনের সম্পর্কই হোক না কেন।\n", "I am taking part in it each year.\n", "5 ਸੰਕੇਤ ਤੁਸੀਂ ਜਾ ਰਹੇ ਹੋ ਗਲੇਡ\n", "\"In order to return to the factory settings, here you need to click on the \"\"Reset device\"\" button.\"\n", "At any moment, there are about 2.5 trillion red blood cells in your body.\n", "শাসন করেছি।\n", "A student needs to understand this.\n", "This is a very intelligent way to gain valuable insight from what people are already searching for, and understand how to use it to give your website visitors what they are trying to .\n", "11-year-old girl gives birth to her 14-year-old brother's baby\n", "آپ پوری فلم یوٹیوب پر یہاں کلک کرکے دیکھ سکتے ہیں۔\n", "So let's discuss how you can do that.\n", "A lot of improvement is to be done with this app.\n", "మార్కెట్లో అధిక డయాబెటిక్ సాక్స్ అడుగుల పొడిని ఉంచడానికి, పాదాల గాయం ప్రమాదాన్ని తగ్గిస్తాయి మరియు రక్త ప్రసరణను నిరోధించడం లేదా మందగించడం నివారించడానికి తయారు చేయబడిన సాక్స్.\n", "ఈ వర్చువల్ సర్వర్లు జూమ్ల, Drupal మరియు WordPress తో సహా వివిధ MySQL మరియు PHP అప్లికేషన్లతో అనుకూలంగా ఉంటాయి.\n", "ਪਰ ਤੁਸੀਂ ਕਿਵੇਂ ਜਾਣਦੇ ਹੋ?\n", "\"The message of the Hon'ble Prime Minister to children is to eat healthy and nutrient food and become like \"\"The Iron Man of India\"\"\"\n", "No, I'm only kid.\n", "And I don't know if you're married.\n", "The problem, however, isn't simply economic or political.\n", "ആമസോൺ ഗ്രേറ്റ് ഇന്ത്യൻ ഫെസ്റ്റിവൽ സെപ്തംബർ 28 സെയിൽ ഉച്ചയ്ക്ക് 12 മണി മുതൽ ആമസോൺ പ്രൈം മെമ്പർമാർക്ക് വേണ്ടി ആരംഭിക്കും.\n", "ಫೇಸ್ಬುಕ್ ಈಗಾಗಲೇ ತನ್ನ ಬಳಕೆದಾ. . .\n", "An example where it can be used\n", "The temple was destroyed and rebuilt numerous times.\n", "இதழியல் படிக்க நேரம் இல்லை.\n", "आम्हा भारतीयांना ही मांडणी नवीन नाही.\n", "अधिकारी कर्मचाऱ्यांना याबाबत सूचित केले आहे.\n", "1:23 اور جب شام اور صبح بن گیا, پانچویں دن.\n", "I may have questions for you later!\n", "ಪರಿಣಾಮವಾಗಿ, ದೋಷವನ್ನು ಸರಿಪಡಿಸಲು ಹೆಚ್ಚುವರಿ ಪ್ರೋಗ್ರಾಮಿಂಗ್ ಹಂತಗಳನ್ನು ತೆಗೆದುಕೊಳ್ಳಬೇಕಾಗಿದೆ.\n", "It is not 100 per cent complete but still very good.\n", "1930లో యుకె లోని అబింగ్డన్లో స్థాపించబడిన ఎంజీ కార్ క్లబ్ వేలాది మంది విశ్వసనీయ అభిమానులను పొందింది, ఈ కార్ బ్రాండ్ ప్రపంచంలోనే అతిపెద్ద క్లబ్లలో ఒకటిగా నిలిచింది.\n", "তেওঁৰ প্ৰতিটো চৰিত্ৰই অসাধাৰণ।\n", "But I can't grab a hold of it.\n", "This includes all women.\n", "The most important Italian architect of all, however, is arguably Marcus Vitruvius Pollio (c.\n", "ਬਹੁਤ ਸਾਰੇ ਲੋਕ ਕੋਸ਼ਿਸ਼ ਵੀ ਨਹੀਂ ਕਰਦੇ।\n", "പെൺകുട്ടിയുടെ ഹൃദയം കീഴടക്കാനുള്ള പരിശ്രമത്തിലായിരുന്നു ഇരുവരും .\n", "आपल्या स्थानिक आरोग्य प्राधिकरणाच्या निर्देशांचे अनुसरण करा.\n", "If he had swallowed.\n", "\"\"\"ನಾವು ಇಲ್ಲಿರುವುದು ಒಂದೇ ಉದ್ದೇಶಕ್ಕಾಗಿ.\"\n", "అలాగే, ఇది ఒక శుభ్రపరచడం agent వంటి మద్దతిస్తుంది.\n", "ചിലർക്ക് ആൺകുഞ്ഞിനെയാവും ആഗ്രഹം, എന്നാൽ ചിലർക്കാകട്ടെ പെൺകുഞ്ഞിനെയാവും ആഗ്രഹം.\n", "ఎక్జిక్యూటబుల్ ప్రోగ్రామ్ల వలె కాకుండా, EXE ఫైల్ ఎక్స్టెన్షన్తో ఉన్న DLL ఫైల్స్ నేరుగా రన్ చేయలేవు, కాని ఇప్పటికే అమలులో ఉన్న ఇతర కోడ్ ద్వారా పిలవబడాలి.\n", "ઘૂંટણની પીડા એક સામાન્ય ફરિયાદ છે જે તમામ ઉંમરના લોકોને અસર કરે છે.\n", "19 all the cities of the sons of Aaron the priests, [are] thirteen cities and their suburbs.\n", "A defined geographical area.\n", "నేను చూస్తున్న ఈ విశాల ప్రపంచంలో\n", "ائر کنڈیشنگ کا استعمال ، اگر ممکن ہو تو ، ہوا کو فلٹر کرنے کے لئے\n", "Boil 6 cups of water, and remove from heat.\n", "టికెట్ బుకింగ్కు ఆధార్ తప్పనిసరి కాదని రైల్వే శాఖ సహాయ మంత్రి రాజెన్ గోహైన్ తెలిపారు.\n", "Many successful streamers use apps like Twitter, Instagram, and Snapchat to update their fans and connect with them more personally.\n", "But here in the 2020's?\n", "Don't step outside man.\n", "اگر آپ کو ایک گاڑی خریدنے کے لئے بیرون ملک ، ٹرانزٹ رجسٹریشن پلیٹیں جاری میں ایک اور یورپی یونین کے ملک تسلیم کیا جائے گا میں سویڈن کے بیعانہ استعمال کرنا مقاصد کے لئے ڈرائیونگ آپ کی گاڑی واپس کرنے کے لئے آپ کی رہائش گاہ کی جگہ.\n", "लोगों ने मुझे समझदार बनाया है।\n", "The letters are so small you can't read it.\n", "माझ्या साइटवर त्यांच्या सेवेबद्दल आणि आपल्या साइटमध्ये ते समाकलित करण्यासाठी आपल्याला बर्याच पोस्ट सापडतील.\n", "The surgery within the next 24 hours.\n", "Consequently, a yield of 4% is fairly stable.\n", "നവംബർ 25 മുതൽ ഡിസംബർ 30 വരെയുള്ള കാലയളവിൽ ഈ പരിധി ഉയർത്തും.\n", "The Australian Open is due to start on 8 February.\n", "He can't buy the car.\n", "ಗೂಗಲ್ ನಕ್ಷೆಗಳ ಉಪಗ್ರಹ ಚಿತ್ರಗಳು ಈಗಿನವಲ್ಲ; ಅವು ಕೆಲವು ತಿಂಗಳ ಅಥವಾ ವರ್ಷಗಳ ಹಿಂದಿನವು.\n", "The food is excellent and the program is convenient and cost-effective.\n", "मुलांना आणि ह्यांना तुझ्यावर सोडते आहे न मी.\n", "The violence has spread to neighbouring Niger, Chad and Cameroon, prompting a regional military coalition to fight the militants.\n", "அவர்களுடைய பாடலின் கருப்பொருளாக இது விளங்குகிறது.\n", "ਸਾਨੂੰ ਹੋਰ ਖਾਸ ਤੌਰ 'ਤੇ ਵਿਗਿਆਨ ਅਤੇ ਜੀਵਨ ਦੇ ਲਈ ਇਸ ਦੇ ਮਹੱਤਵ' ਤੇ ਵਿਚਾਰ ਕਰੀਏ.\n", "The car details are good.\n", "I said no, I am at home.\n", "ଯେଉଁଥିପାଇଁ ତାଙ୍କର ଓଜନ ବଢ଼ୁଥିଲା।\n", "Events - local concerts, competitions, recent holidays, where the young lady was, where she would like to go, what the next event will be in the city.\n", "Men care about their hair, too.\n", "Mr. Murli Manohar Joshi, Former Minister of Human Resource Development (HRD), Govt. of India, started his keynote with the MoolMantra and talked about the role of hard work, sharing and unity in the current turbulent world and its transformation to peace, harmony and happiness.\n", "Sensex, Nifty scale new highs on new year's day\n", "It wasn't worth the money we spent.\n", "જો ખરીદોઃ તમે એક ઉત્તમ ફોન માંગો છો, પરંતુ 500 થી વધુ £ ખર્ચવા નથી માંગતા\n", "People began viticulture 6 thousand years ago.\n", "But actually it was not that difficult.\n", "It isn't only happening in France.\n", "এবার তারা আনুষ্ঠানিকভাবে এটি উন্মুক্ত করতে চলেছে।\n", "Everybody must see the light.\n", "He is currently in Myanmar.\n", "ഇത് വിമാനം തരം ആശ്രയിച്ചിരിക്കുന്നു.\n" ] } ], "source": [ "!head -n 100 train_aggressively_shuffled.src" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "en : রাজ্যের রাজধানী!\n", "en : নিচে বিস্তারিত.\n", "en : সেই একই কারণে!\n", "en : আমার ছেলে একটি মেয়ের প্রেমে পড়েছে\n", "en : bash এর একটি বিশেষ চরিত্র, এটি পূর্ববর্তী কমান্ড উল্লেখ করতে ব্যবহৃত হয়।\n", "en : অর্থের মূল্য !\n", "en : সন্ত্রাসিরা খুন করেছে।\n", "en : গোটা শরীর জুড়ে!\n", "en : আজ দেশের সব বিভাগে\n", "en : স্ত্রী আর তিন সন্তান!\n" ] } ], "source": [ "!head -n 10 train.src " ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Cloning into 'MT-Preparation'...\n", "remote: Enumerating objects: 305, done.\u001b[K\n", "remote: Counting objects: 100% (131/131), done.\u001b[K\n", "remote: Compressing objects: 100% (69/69), done.\u001b[K\n", "remote: Total 305 (delta 66), reused 114 (delta 58), pack-reused 174 (from 1)\u001b[K\n", "Receiving objects: 100% (305/305), 84.51 KiB | 1.96 MiB/s, done.\n", "Resolving deltas: 100% (149/149), done.\n" ] } ], "source": [ "!git clone https://github.com/ymoslem/MT-Preparation.git" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--2024-12-16 15:13:01-- https://huggingface.co/Vikrantyadav11234/NMT_multilingual_12/resolve/main/target.model\n", "Resolving huggingface.co (huggingface.co)... 18.172.134.4, 18.172.134.124, 18.172.134.88, ...\n", "Connecting to huggingface.co (huggingface.co)|18.172.134.4|:443... connected.\n", "HTTP request sent, awaiting response... 302 Found\n", "Location: https://cdn-lfs-us-1.hf.co/repos/39/ee/39ee14e585e8e2e88fd5b98517c223831219784b29620228589df42bb9e6c6e6/6b0a6b669581c874390272a0aa8c77e5e5394b975b5f7bd42928fe7d8bb046b8?response-content-disposition=inline%3B+filename*%3DUTF-8%27%27target.model%3B+filename%3D%22target.model%22%3B&Expires=1734621181&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTczNDYyMTE4MX19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2RuLWxmcy11cy0xLmhmLmNvL3JlcG9zLzM5L2VlLzM5ZWUxNGU1ODVlOGUyZTg4ZmQ1Yjk4NTE3YzIyMzgzMTIxOTc4NGIyOTYyMDIyODU4OWRmNDJiYjllNmM2ZTYvNmIwYTZiNjY5NTgxYzg3NDM5MDI3MmEwYWE4Yzc3ZTVlNTM5NGI5NzViNWY3YmQ0MjkyOGZlN2Q4YmIwNDZiOD9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSoifV19&Signature=mFTbQgou%7EjezLoStcTxwZldh5fyZCUM%7EHRqIjRdxhXZeS4hRBguazVJ7wjbJLFij2bxKv3VitW9QKbWf34KZJpTQa9cFf8aB18ZNQ4y2ojoFcwo%7EkdAaH0sjYDO8YQ%7EzcQEyIghkOZ%7EhwDQPa8Hk0JpI-H87-XkLAp74nKmE0tItd48nsWZIXyt7R-OqSRji8jIQNE5WdN3fC9pGsdFzApNbelmCCkjhhYLmNyGAOZaz-YXC-axqUVNkb48s67--wCJXngCCdmAs797c4q5kg5Sw7VJPeYCpyVJiQifqORDTXNqSA034JW2DYtEt0j533Nl7T%7Eb54WrM48bNztNThg__&Key-Pair-Id=K24J24Z295AEI9 [following]\n", "--2024-12-16 15:13:01-- https://cdn-lfs-us-1.hf.co/repos/39/ee/39ee14e585e8e2e88fd5b98517c223831219784b29620228589df42bb9e6c6e6/6b0a6b669581c874390272a0aa8c77e5e5394b975b5f7bd42928fe7d8bb046b8?response-content-disposition=inline%3B+filename*%3DUTF-8%27%27target.model%3B+filename%3D%22target.model%22%3B&Expires=1734621181&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTczNDYyMTE4MX19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2RuLWxmcy11cy0xLmhmLmNvL3JlcG9zLzM5L2VlLzM5ZWUxNGU1ODVlOGUyZTg4ZmQ1Yjk4NTE3YzIyMzgzMTIxOTc4NGIyOTYyMDIyODU4OWRmNDJiYjllNmM2ZTYvNmIwYTZiNjY5NTgxYzg3NDM5MDI3MmEwYWE4Yzc3ZTVlNTM5NGI5NzViNWY3YmQ0MjkyOGZlN2Q4YmIwNDZiOD9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSoifV19&Signature=mFTbQgou%7EjezLoStcTxwZldh5fyZCUM%7EHRqIjRdxhXZeS4hRBguazVJ7wjbJLFij2bxKv3VitW9QKbWf34KZJpTQa9cFf8aB18ZNQ4y2ojoFcwo%7EkdAaH0sjYDO8YQ%7EzcQEyIghkOZ%7EhwDQPa8Hk0JpI-H87-XkLAp74nKmE0tItd48nsWZIXyt7R-OqSRji8jIQNE5WdN3fC9pGsdFzApNbelmCCkjhhYLmNyGAOZaz-YXC-axqUVNkb48s67--wCJXngCCdmAs797c4q5kg5Sw7VJPeYCpyVJiQifqORDTXNqSA034JW2DYtEt0j533Nl7T%7Eb54WrM48bNztNThg__&Key-Pair-Id=K24J24Z295AEI9\n", "Resolving cdn-lfs-us-1.hf.co (cdn-lfs-us-1.hf.co)... 18.160.225.72, 18.160.225.13, 18.160.225.98, ...\n", "Connecting to cdn-lfs-us-1.hf.co (cdn-lfs-us-1.hf.co)|18.160.225.72|:443... connected.\n", "HTTP request sent, awaiting response... 200 OK\n", "Length: 6888485 (6.6M) [binary/octet-stream]\n", "Saving to: ‘target.model’\n", "\n", "target.model 100%[===================>] 6.57M 37.4MB/s in 0.2s \n", "\n", "2024-12-16 15:13:01 (37.4 MB/s) - ‘target.model’ saved [6888485/6888485]\n", "\n" ] } ], "source": [ "!wget https://huggingface.co/Vikrantyadav11234/NMT_multilingual_12/resolve/main/target.model" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--2024-12-16 15:13:32-- https://huggingface.co/Vikrantyadav11234/NMT_multilingual_12/resolve/main/source.model\n", "Resolving huggingface.co (huggingface.co)... 18.160.143.75, 18.160.143.76, 18.160.143.32, ...\n", "Connecting to huggingface.co (huggingface.co)|18.160.143.75|:443... connected.\n", "HTTP request sent, awaiting response... 302 Found\n", "Location: https://cdn-lfs-us-1.hf.co/repos/39/ee/39ee14e585e8e2e88fd5b98517c223831219784b29620228589df42bb9e6c6e6/076e8b22e4cf7baff9c9d0897a19da65b77e53064e84e631d883cebfa3b20466?response-content-disposition=inline%3B+filename*%3DUTF-8%27%27source.model%3B+filename%3D%22source.model%22%3B&Expires=1734621212&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTczNDYyMTIxMn19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2RuLWxmcy11cy0xLmhmLmNvL3JlcG9zLzM5L2VlLzM5ZWUxNGU1ODVlOGUyZTg4ZmQ1Yjk4NTE3YzIyMzgzMTIxOTc4NGIyOTYyMDIyODU4OWRmNDJiYjllNmM2ZTYvMDc2ZThiMjJlNGNmN2JhZmY5YzlkMDg5N2ExOWRhNjViNzdlNTMwNjRlODRlNjMxZDg4M2NlYmZhM2IyMDQ2Nj9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSoifV19&Signature=n3QVE4pH-KK9MwJu6hqbPwTcX60jGYkXnaez91EO1UQzqpvq7NOb0igVSzVRro0odeVRetzI%7EhbuKF908ts3Bj5gniVHBodLzxng1CAzxnEqFJwxkkgYaIRntqSvBuNnye7zd6jjFKew0diqV64UHqGinv7QHXRb5rSHiE6wXwO6NMS8AgSHSuodpFzK%7EZFa6qjuO0i%7EhDog%7EzhSXDVaooFeVep5vYTc1EfdmcOcrPbbzMBD9ZBJUUTVnGVpmtKHi8IQOkg0z4f-g-VoyI4wu-3ZMpDg0krWu6rXHBPzFcD6oXcDx3UhNKAY-bo66Vz5G56BzqkzenmRYHoaQeCJTw__&Key-Pair-Id=K24J24Z295AEI9 [following]\n", "--2024-12-16 15:13:33-- https://cdn-lfs-us-1.hf.co/repos/39/ee/39ee14e585e8e2e88fd5b98517c223831219784b29620228589df42bb9e6c6e6/076e8b22e4cf7baff9c9d0897a19da65b77e53064e84e631d883cebfa3b20466?response-content-disposition=inline%3B+filename*%3DUTF-8%27%27source.model%3B+filename%3D%22source.model%22%3B&Expires=1734621212&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTczNDYyMTIxMn19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2RuLWxmcy11cy0xLmhmLmNvL3JlcG9zLzM5L2VlLzM5ZWUxNGU1ODVlOGUyZTg4ZmQ1Yjk4NTE3YzIyMzgzMTIxOTc4NGIyOTYyMDIyODU4OWRmNDJiYjllNmM2ZTYvMDc2ZThiMjJlNGNmN2JhZmY5YzlkMDg5N2ExOWRhNjViNzdlNTMwNjRlODRlNjMxZDg4M2NlYmZhM2IyMDQ2Nj9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSoifV19&Signature=n3QVE4pH-KK9MwJu6hqbPwTcX60jGYkXnaez91EO1UQzqpvq7NOb0igVSzVRro0odeVRetzI%7EhbuKF908ts3Bj5gniVHBodLzxng1CAzxnEqFJwxkkgYaIRntqSvBuNnye7zd6jjFKew0diqV64UHqGinv7QHXRb5rSHiE6wXwO6NMS8AgSHSuodpFzK%7EZFa6qjuO0i%7EhDog%7EzhSXDVaooFeVep5vYTc1EfdmcOcrPbbzMBD9ZBJUUTVnGVpmtKHi8IQOkg0z4f-g-VoyI4wu-3ZMpDg0krWu6rXHBPzFcD6oXcDx3UhNKAY-bo66Vz5G56BzqkzenmRYHoaQeCJTw__&Key-Pair-Id=K24J24Z295AEI9\n", "Resolving cdn-lfs-us-1.hf.co (cdn-lfs-us-1.hf.co)... 18.160.225.120, 18.160.225.98, 18.160.225.13, ...\n", "Connecting to cdn-lfs-us-1.hf.co (cdn-lfs-us-1.hf.co)|18.160.225.120|:443... connected.\n", "HTTP request sent, awaiting response... 200 OK\n", "Length: 6942862 (6.6M) [binary/octet-stream]\n", "Saving to: ‘source.model’\n", "\n", "source.model 100%[===================>] 6.62M 35.9MB/s in 0.2s \n", "\n", "2024-12-16 15:13:33 (35.9 MB/s) - ‘source.model’ saved [6942862/6942862]\n", "\n" ] } ], "source": [ "!wget https://huggingface.co/Vikrantyadav11234/NMT_multilingual_12/resolve/main/source.model" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Source Model: source.model\n", "Target Model: target.model\n", "Source Dataset: train.src\n", "Target Dataset: train.tgt\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Done subwording the source file! Output: train.src.subword\n", "Done subwording the target file! Output: train.tgt.subword\n" ] } ], "source": [ "!python3 MT-Preparation/subwording/2-subword.py source.model target.model train.src train.tgt" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!huggingface-cli upload \n" ] } ], "metadata": { "kernelspec": { "display_name": "myenv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.14" } }, "nbformat": 4, "nbformat_minor": 2 }