{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":121150,"databundleVersionId":15061024,"sourceType":"competition"}],"dockerImageVersionId":31192,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"![](data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxMTEhUTExIVFhUXFxgaGRgYFh0WGxsZHRgXGxsWGhggHSggGhsmGxgXITEhJSkrMC4uGB8zODMsNygtLisBCgoKDg0OGhAQGi0lHx0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tK//AABEIAJ8BPgMBIgACEQEDEQH/xAAbAAABBQEBAAAAAAAAAAAAAAACAAMEBQYBB//EAD8QAAEDAgQEAwYEBAQGAwAAAAEAAhEDIQQSMUEFUWFxIoGRBhMyobHBQtHh8FJicpIUI0PxFRZTgqKyM8Li/8QAGAEBAQEBAQAAAAAAAAAAAAAAAAIBAwT/xAAhEQEBAAICAgIDAQAAAAAAAAAAAQIRAyESMRNRMkFhIv/aAAwDAQACEQMRAD8A8tSQpICSQpICSQpICSQpICSQpICSQpICSQyncLSzvayYzOAnlJ1QAktoz2cw50Y7+oPMd5mFFxHsrT/BUc3vDh9ipmcV41lUla4r2erN+EB4/lN/Q/aVJ4f7NuMGscv8ou7zOg+aXOT2Y4W+lCBJgaq0wfAaz9W5Bzfb5arV4XC0qQPu2hvWPEe5NyjqVDyvExOtv13XDLn+o748H2yXEuBvpNzBwe0fFAgjykyOqqpXoHvZ1GxtE+Z9enXmsjxzh/u3FzR4CSI/hP8AD25emyri5d9VPJxa7itSQylK7uAkkMpICSQpICSQpIC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DgFnsXwvCj4Kz3dIn5wnaeFtcAfvkn6TcvVNiqp8NE2YT/VZShw3m4DoBHzUurXyiXFrR1VTjOOtFqfiPM2H5lN2+m9LD3NOne08yqviHG9qd+v5KoxGLe8+J3lsmVUx+07HUqEmSZKFcSVMdSXEkHUlxJB1JcSQcSXEkHUlxJB1JcSQdSXEkHUlxJB1da4gyCQelkKSCyw/G6rbEhw/mH3VlQ9o2mzmkdjIWbSWXGN22FPidNxs9vYmFYUMb0+f6rz9EyqRoSOxhT4m3pFPENO0J4Nab2XnLOJVRo8/VSafHaw/EPRZ41u3oORpTZoNmwCxLfaWruGHyP5pwe1FT+FvqU8aba73QaIgJp2HabR9vJZY+1NT+FvzTTvaatyZ6H808aba33LQIiyaZSYDax6XWRfx+sfxD0TFTitY61D5W+ieFNtnUc0GYvzKjYjiFNv42hYx9Zx1cT3JKBb4G2lrcdYNJd8lXV+OVD8MN+ZVWktmMZsdWqXGXEk9UK4kqY6kuJIOpLiSDqS4kg6kuJIOpLiSD/9k=)","metadata":{}},{"cell_type":"code","source":"# =====================\n# 📌 Import Libraries\n# =====================\n\n# Basic\nimport numpy as np\nimport pandas as pd\n\n# Visualization\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n%matplotlib inline\n\n# Plotly\nimport plotly.io as pio\nimport plotly.express as px\npio.renderers.default = \"iframe\"\n\n# Ignore warnings\nimport warnings\nwarnings.filterwarnings('ignore')\n\n# =====================\n# 📌 Show Available Data\n# =====================\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:45:30.687893Z","iopub.execute_input":"2025-12-28T11:45:30.688485Z","iopub.status.idle":"2025-12-28T11:45:35.242058Z","shell.execute_reply.started":"2025-12-28T11:45:30.688449Z","shell.execute_reply":"2025-12-28T11:45:35.240998Z"},"_kg_hide-input":true,"_kg_hide-output":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sub = pd.read_csv(\"/kaggle/input/deep-past-initiative-machine-translation/sample_submission.csv\")\nsub.tail()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:46:19.196057Z","iopub.execute_input":"2025-12-28T11:46:19.196411Z","iopub.status.idle":"2025-12-28T11:46:19.240063Z","shell.execute_reply.started":"2025-12-28T11:46:19.196386Z","shell.execute_reply":"2025-12-28T11:46:19.239077Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## train file","metadata":{}},{"cell_type":"code","source":"train = pd.read_csv(\"/kaggle/input/deep-past-initiative-machine-translation/train.csv\")\ntrain.tail(3)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:46:40.520452Z","iopub.execute_input":"2025-12-28T11:46:40.521976Z","iopub.status.idle":"2025-12-28T11:46:40.585009Z","shell.execute_reply.started":"2025-12-28T11:46:40.521935Z","shell.execute_reply":"2025-12-28T11:46:40.584190Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(train['transliteration'][1558])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:46:47.398621Z","iopub.execute_input":"2025-12-28T11:46:47.399457Z","iopub.status.idle":"2025-12-28T11:46:47.409220Z","shell.execute_reply.started":"2025-12-28T11:46:47.399415Z","shell.execute_reply":"2025-12-28T11:46:47.407237Z"},"_kg_hide-output":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Split document on whitespace","metadata":{}},{"cell_type":"code","source":"print(train['transliteration'][1558].split())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:46:57.059902Z","iopub.execute_input":"2025-12-28T11:46:57.060194Z","iopub.status.idle":"2025-12-28T11:46:57.065864Z","shell.execute_reply.started":"2025-12-28T11:46:57.060175Z","shell.execute_reply":"2025-12-28T11:46:57.064662Z"},"_kg_hide-output":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Number of tokens","metadata":{}},{"cell_type":"code","source":"# Count the number of tokens in document\nlen(train['transliteration'][1558].split())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:47:13.184653Z","iopub.execute_input":"2025-12-28T11:47:13.184947Z","iopub.status.idle":"2025-12-28T11:47:13.192632Z","shell.execute_reply.started":"2025-12-28T11:47:13.184926Z","shell.execute_reply":"2025-12-28T11:47:13.191505Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## apply () function to count the number of tokens","metadata":{}},{"cell_type":"code","source":"#apply () function to count the number of tokens\ntrain['transliteration'].apply(lambda x: len(str(x).split()))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:47:16.883141Z","iopub.execute_input":"2025-12-28T11:47:16.883515Z","iopub.status.idle":"2025-12-28T11:47:16.905081Z","shell.execute_reply.started":"2025-12-28T11:47:16.883485Z","shell.execute_reply":"2025-12-28T11:47:16.903973Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Token counts in Transliterations","metadata":{}},{"cell_type":"code","source":"# Plot the number of tokens per transliteration\n\n# Histogram style specifications\nhist_specs = {\n    \"color\": \"mediumpurple\",\n    \"alpha\": 0.7,\n    \"edgecolor\": \"blue\",\n    \"bins\": 20\n}\n\nlabel_specs   = {\"fontsize\": 12}\ntitle_specs   = {\"fontsize\": 14, \"fontweight\": \"bold\", \"y\": 1.01}\n\nplt.figure(figsize=(8,4))\n\nplt.hist(train['transliteration'].apply(lambda x: len(str(x).split())), **hist_specs)\nplt.xlabel('Number of Tokens', **label_specs)\nplt.ylabel('Number of Transliterations', **label_specs)\nplt.title('Distribution of Token Counts in Transliterations', **title_specs)\nplt.show()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:48:18.767553Z","iopub.execute_input":"2025-12-28T11:48:18.767874Z","iopub.status.idle":"2025-12-28T11:48:18.982763Z","shell.execute_reply.started":"2025-12-28T11:48:18.767853Z","shell.execute_reply":"2025-12-28T11:48:18.981715Z"},"_kg_hide-input":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Describe method\n\nWe got the shortest (min), the longest (max) and median (50%).","metadata":{}},{"cell_type":"code","source":"#shortest transliteration has 3 (three) tokens (min)\n#the longest has 187 tokens (max)\n#The median number of tokens per book description is 49 (50%)\n\ntrain['transliteration'].apply(lambda x: len(str(x).split())).describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:48:48.728688Z","iopub.execute_input":"2025-12-28T11:48:48.729020Z","iopub.status.idle":"2025-12-28T11:48:48.755305Z","shell.execute_reply.started":"2025-12-28T11:48:48.728999Z","shell.execute_reply":"2025-12-28T11:48:48.754170Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sample = train['transliteration'][1558]\nprint(sample)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:48:51.231407Z","iopub.execute_input":"2025-12-28T11:48:51.231799Z","iopub.status.idle":"2025-12-28T11:48:51.238490Z","shell.execute_reply.started":"2025-12-28T11:48:51.231770Z","shell.execute_reply":"2025-12-28T11:48:51.237312Z"},"_kg_hide-output":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## split the document\n\nStart by splitting the document on whitespace. Then count the instances of each token to find the most frequent one.","metadata":{}},{"cell_type":"code","source":"# Split text on whitespace\nprint(sample.split()[0:20])\n\n# Note: we show only the first 200 tokens","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:48:54.387940Z","iopub.execute_input":"2025-12-28T11:48:54.388272Z","iopub.status.idle":"2025-12-28T11:48:54.394133Z","shell.execute_reply.started":"2025-12-28T11:48:54.388248Z","shell.execute_reply":"2025-12-28T11:48:54.392974Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import re\n\ndef clean_text(text):\n    # Convert text to lowercase\n    text = text.lower()\n    \n    # Remove punctuation (anything that is not a word character, whitespace, or hyphen) and replace with space\n    text = re.sub(r\"[^\\w\\s-]\", \" \", text)  \n    \n    # Replace single hyphens surrounded by spaces with a single space\n    text = re.sub(r\"\\s-\\s\", \" \", text)\n    \n    # Replace multiple spaces with a single space and strip leading/trailing spaces\n    text = re.sub(r\"\\s+\", \" \", text).strip()\n    \n    return text\n\nclean_sample = clean_text(sample)\nprint(clean_sample)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:49:57.339856Z","iopub.execute_input":"2025-12-28T11:49:57.340234Z","iopub.status.idle":"2025-12-28T11:49:57.347962Z","shell.execute_reply.started":"2025-12-28T11:49:57.340205Z","shell.execute_reply":"2025-12-28T11:49:57.346909Z"},"_kg_hide-output":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Clean_sample\n\nSplit the clean_sample on whitespace. Unfortunately, I still see single hiphens : (","metadata":{}},{"cell_type":"code","source":"# Split the cleaned text into tokens based on whitespace\ntokens = clean_sample.split()\n\n# Display only the first 20 tokens\nprint(tokens[:20])\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:50:23.843273Z","iopub.execute_input":"2025-12-28T11:50:23.843958Z","iopub.status.idle":"2025-12-28T11:50:23.849406Z","shell.execute_reply.started":"2025-12-28T11:50:23.843930Z","shell.execute_reply":"2025-12-28T11:50:23.848165Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from collections import Counter\n\n# Split the cleaned text into tokens\ntokens = clean_sample.split()\n\n# Count the frequency of each token and display the top 10 most frequent tokens\ntop_tokens = Counter(tokens).most_common(10)\nprint(top_tokens)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:50:55.214865Z","iopub.execute_input":"2025-12-28T11:50:55.215258Z","iopub.status.idle":"2025-12-28T11:50:55.222970Z","shell.execute_reply.started":"2025-12-28T11:50:55.215233Z","shell.execute_reply":"2025-12-28T11:50:55.221639Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Convert all characters to lowercase (case folding) to standardize the text\nprocessed_sample = clean_sample.lower()\n\n# Display the result\nprint(\"Text after converting to lowercase:\\n\\n{}\\n\".format(processed_sample))\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:51:22.543993Z","iopub.execute_input":"2025-12-28T11:51:22.544417Z","iopub.status.idle":"2025-12-28T11:51:22.550931Z","shell.execute_reply.started":"2025-12-28T11:51:22.544311Z","shell.execute_reply":"2025-12-28T11:51:22.549378Z"},"_kg_hide-output":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## NLTK Stopwords","metadata":{}},{"cell_type":"code","source":"# Import NLTK library and download English stopwords\nimport nltk\nnltk.download(\"stopwords\", quiet=True)\n\n# Load the list of English stopwords\nfrom nltk.corpus import stopwords\nstopwords_english = stopwords.words(\"english\")\n\n# Display the first 10 stopwords as a check\nprint(\"Sample English stopwords:\", stopwords_english[:10])\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:51:49.395454Z","iopub.execute_input":"2025-12-28T11:51:49.395754Z","iopub.status.idle":"2025-12-28T11:51:50.485592Z","shell.execute_reply.started":"2025-12-28T11:51:49.395732Z","shell.execute_reply":"2025-12-28T11:51:50.484508Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Print stopwords\n\nprint(\"{} stopwords in NLTK's list.\\n\".format(len(stopwords_english)))\nprint(stopwords_english)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:51:52.473696Z","iopub.execute_input":"2025-12-28T11:51:52.474022Z","iopub.status.idle":"2025-12-28T11:51:52.480063Z","shell.execute_reply.started":"2025-12-28T11:51:52.473998Z","shell.execute_reply":"2025-12-28T11:51:52.478886Z"},"_kg_hide-output":true,"_kg_hide-input":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Tokenize the processed_sample and remove English stopwords\nprocessed_sample_tokens = [\n    tok for tok in processed_sample.split() \n    if tok not in stopwords_english\n]\n\n# Display the tokens after stopword removal\nprint(\"Tokens after removing stopwords:\\n\", processed_sample_tokens)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:52:31.690949Z","iopub.execute_input":"2025-12-28T11:52:31.691468Z","iopub.status.idle":"2025-12-28T11:52:31.699250Z","shell.execute_reply.started":"2025-12-28T11:52:31.691438Z","shell.execute_reply":"2025-12-28T11:52:31.696810Z"},"_kg_hide-output":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Recount words after removals","metadata":{}},{"cell_type":"code","source":"# Print top-10 most frequent tokens in processed_sample_tokens\n\nCounter(processed_sample_tokens).most_common(10)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:52:40.114716Z","iopub.execute_input":"2025-12-28T11:52:40.115017Z","iopub.status.idle":"2025-12-28T11:52:40.122675Z","shell.execute_reply.started":"2025-12-28T11:52:40.114998Z","shell.execute_reply":"2025-12-28T11:52:40.121268Z"},"_kg_hide-output":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def preprocess_text(text):\n    # Ensure input is string (avoids errors if input is float or other type)\n    text = str(text)\n    \n    # Convert text to lowercase\n    clean_text = text.lower()\n    \n    # Replace common punctuation marks (comma, period, parentheses) with whitespace\n    clean_text = re.sub(r\"[,.()]\", \" \", clean_text)\n    \n    # Replace single hyphens surrounded by whitespace with a space\n    clean_text = re.sub(r\"\\s-\\s\", \" \", clean_text)\n    \n    # Split text on whitespace and remove English stopwords\n    processed_sample_tokens = [tok for tok in clean_text.split() if tok not in stopwords_english]\n    \n    return processed_sample_tokens\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:53:46.303985Z","iopub.execute_input":"2025-12-28T11:53:46.304370Z","iopub.status.idle":"2025-12-28T11:53:46.313085Z","shell.execute_reply.started":"2025-12-28T11:53:46.304307Z","shell.execute_reply":"2025-12-28T11:53:46.311637Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## method()","metadata":{}},{"cell_type":"code","source":"# Apply the preprocessing function to the 'transliteration' column\n# This will create a new column 'clean_transliteration' containing tokenized and cleaned text\ntrain['clean_transliteration'] = train['transliteration'].apply(lambda x: preprocess_text(x))\n\n# Display a random sample to check the results\ntrain.sample()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:53:55.057960Z","iopub.execute_input":"2025-12-28T11:53:55.058293Z","iopub.status.idle":"2025-12-28T11:53:55.404983Z","shell.execute_reply.started":"2025-12-28T11:53:55.058265Z","shell.execute_reply":"2025-12-28T11:53:55.403966Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## List comprehensions","metadata":{}},{"cell_type":"code","source":"# Preprocess all transliterations using a list comprehension\npreprocessed_transliterations = [preprocess_text(doc) for doc in train['transliteration']]\n\n# Display the first preprocessed and tokenized transliteration\nprint(preprocessed_transliterations[0])\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:54:39.441536Z","iopub.execute_input":"2025-12-28T11:54:39.441879Z","iopub.status.idle":"2025-12-28T11:54:39.771880Z","shell.execute_reply.started":"2025-12-28T11:54:39.441855Z","shell.execute_reply":"2025-12-28T11:54:39.770878Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Import Gensim and Phrases\n\nfrom gensim.models import Phrases","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:54:47.581351Z","iopub.execute_input":"2025-12-28T11:54:47.581693Z","iopub.status.idle":"2025-12-28T11:55:36.668957Z","shell.execute_reply.started":"2025-12-28T11:54:47.581667Z","shell.execute_reply":"2025-12-28T11:55:36.668015Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Detect common collocations (bigrams) in the transliterations\n# Using the Phrases model from gensim\n\nn_gram_model = Phrases(\n    preprocessed_transliterations,  # List of tokenized texts\n    min_count=5,                     # Only keep collocations that appear at least 5 times\n    delimiter='_'                    # Character to join tokens in a collocation (avoid b'_' for Python 3)\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:55:36.670639Z","iopub.execute_input":"2025-12-28T11:55:36.671406Z","iopub.status.idle":"2025-12-28T11:55:36.810901Z","shell.execute_reply.started":"2025-12-28T11:55:36.671370Z","shell.execute_reply":"2025-12-28T11:55:36.809793Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Apply n_gram_model","metadata":{}},{"cell_type":"code","source":"# Transform tokenized transliterations to include detected collocations\n# Each collocation detected by the Phrases model will be joined with an underscore '_'\n\npreprocessed_transliterations_collocations = [\n    n_gram_model[doc]  # Apply Phrases model to each tokenized text\n    for doc in preprocessed_transliterations\n]\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:55:53.436567Z","iopub.execute_input":"2025-12-28T11:55:53.436885Z","iopub.status.idle":"2025-12-28T11:55:53.589127Z","shell.execute_reply.started":"2025-12-28T11:55:53.436862Z","shell.execute_reply":"2025-12-28T11:55:53.588026Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from collections import Counter\n\nall_tokens = [token for doc in preprocessed_transliterations_collocations for token in doc]\nCounter(all_tokens).most_common(20)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:55:58.125453Z","iopub.execute_input":"2025-12-28T11:55:58.125783Z","iopub.status.idle":"2025-12-28T11:55:58.148738Z","shell.execute_reply.started":"2025-12-28T11:55:58.125760Z","shell.execute_reply":"2025-12-28T11:55:58.147834Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Add processed press releases (with collocations) to dataframe\n\ntrain['clean_transliteration'] = preprocessed_transliterations_collocations","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:56:00.938350Z","iopub.execute_input":"2025-12-28T11:56:00.938689Z","iopub.status.idle":"2025-12-28T11:56:00.948157Z","shell.execute_reply.started":"2025-12-28T11:56:00.938667Z","shell.execute_reply":"2025-12-28T11:56:00.946882Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Print one example to see how it looks like.\n\nprint(preprocessed_transliterations_collocations[0])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:56:35.731418Z","iopub.execute_input":"2025-12-28T11:56:35.731770Z","iopub.status.idle":"2025-12-28T11:56:35.737869Z","shell.execute_reply.started":"2025-12-28T11:56:35.731746Z","shell.execute_reply":"2025-12-28T11:56:35.736043Z"},"_kg_hide-output":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from collections import Counter\nimport matplotlib.pyplot as plt\n\n# Find top-10 most common words in the first transliteration (with collocations)\ntop_words = Counter(preprocessed_transliterations_collocations[0]).most_common(10)\n\n# Barplot specifications\nbarplot_specs   = {\"color\": \"mediumpurple\", \"alpha\": 0.7, \"edgecolor\": \"grey\"}\ntitle_specs     = {\"fontsize\": 14, \"fontweight\": \"bold\", \"y\": 1.2}\nlabel_specs     = {\"fontsize\": 13}\n\n# Plot top words\nplt.figure(figsize=(15,3))\nplt.bar(*zip(*top_words), **barplot_specs)\nplt.title('Most Common Words in Transliteration', **title_specs)\nplt.ylabel('Word Counts', **label_specs)\nplt.xticks(rotation=45)\nplt.show()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:56:53.986603Z","iopub.execute_input":"2025-12-28T11:56:53.986952Z","iopub.status.idle":"2025-12-28T11:56:54.540672Z","shell.execute_reply.started":"2025-12-28T11:56:53.986928Z","shell.execute_reply":"2025-12-28T11:56:54.539245Z"},"_kg_hide-input":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## test file","metadata":{}},{"cell_type":"code","source":"test = pd.read_csv(\"/kaggle/input/deep-past-initiative-machine-translation/test.csv\")\ntest.tail()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:57:20.182307Z","iopub.execute_input":"2025-12-28T11:57:20.182693Z","iopub.status.idle":"2025-12-28T11:57:20.203976Z","shell.execute_reply.started":"2025-12-28T11:57:20.182670Z","shell.execute_reply":"2025-12-28T11:57:20.202942Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Bibliography file\n\nBibliogr.: Recommended for scientific/indexing (ISO 4). ","metadata":{}},{"cell_type":"code","source":"bibliogr = pd.read_csv(\"/kaggle/input/deep-past-initiative-machine-translation/bibliography.csv\")\nbibliogr.tail()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:57:30.278768Z","iopub.execute_input":"2025-12-28T11:57:30.279083Z","iopub.status.idle":"2025-12-28T11:57:30.301459Z","shell.execute_reply.started":"2025-12-28T11:57:30.279059Z","shell.execute_reply":"2025-12-28T11:57:30.300074Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Publications csv file","metadata":{}},{"cell_type":"code","source":"pub = pd.read_csv(\"/kaggle/input/deep-past-initiative-machine-translation/publications.csv\")\npub.tail()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:58:14.334931Z","iopub.execute_input":"2025-12-28T11:58:14.335618Z","iopub.status.idle":"2025-12-28T11:58:21.618377Z","shell.execute_reply.started":"2025-12-28T11:58:14.335574Z","shell.execute_reply":"2025-12-28T11:58:21.617352Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Plot count of texts with Akkadian transliterations\nplt.figure(figsize=(10,4))\nsns.countplot(\n    data=pub, \n    x='has_akkadian', \n    order=pub['has_akkadian'].value_counts().index\n)\nplt.title(\"Distribution of Texts with Akkadian Transliterations\")\nplt.ylabel(\"Number of Texts\")\nplt.xlabel(\"Has Akkadian Transliteration\")\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:58:24.796298Z","iopub.execute_input":"2025-12-28T11:58:24.796669Z","iopub.status.idle":"2025-12-28T11:58:24.981161Z","shell.execute_reply.started":"2025-12-28T11:58:24.796647Z","shell.execute_reply":"2025-12-28T11:58:24.976051Z"},"_kg_hide-input":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### OA_Lexicon_eBL file","metadata":{}},{"cell_type":"code","source":"lex = pd.read_csv(\"/kaggle/input/deep-past-initiative-machine-translation/OA_Lexicon_eBL.csv\")\nlex.tail()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:58:43.617942Z","iopub.execute_input":"2025-12-28T11:58:43.618294Z","iopub.status.idle":"2025-12-28T11:58:43.773274Z","shell.execute_reply.started":"2025-12-28T11:58:43.618268Z","shell.execute_reply":"2025-12-28T11:58:43.772286Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Plot the distribution of female word types, separated by 'type'\nplt.figure(figsize=(8,4))\nsns.countplot(\n    x='Female(f)', \n    hue='type', \n    data=lex, \n    order=sorted(lex['Female(f)'].astype(str).unique())  # Ensure consistent order\n)\nplt.title('Distribution of Female Word Types by Type')\nplt.xlabel('Female (f)')\nplt.ylabel('Count')\nplt.show()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T11:59:39.075040Z","iopub.execute_input":"2025-12-28T11:59:39.075364Z","iopub.status.idle":"2025-12-28T11:59:39.295262Z","shell.execute_reply.started":"2025-12-28T11:59:39.075342Z","shell.execute_reply":"2025-12-28T11:59:39.294385Z"},"_kg_hide-input":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### published_texts file","metadata":{}},{"cell_type":"code","source":"text = pd.read_csv(\"/kaggle/input/deep-past-initiative-machine-translation/published_texts.csv\")\ntext.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T12:00:17.066564Z","iopub.execute_input":"2025-12-28T12:00:17.066876Z","iopub.status.idle":"2025-12-28T12:00:17.411958Z","shell.execute_reply.started":"2025-12-28T12:00:17.066856Z","shell.execute_reply":"2025-12-28T12:00:17.410903Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Example of preprocessing function\nnltk.download(\"stopwords\", quiet=True)\nfrom nltk.corpus import stopwords\nstopwords_english = stopwords.words(\"english\")\n\ndef preprocess_text(text):\n    \"\"\"\n    Preprocess text by:\n    - converting to lowercase\n    - removing punctuation\n    - splitting on whitespace\n    - removing stopwords\n    \"\"\"\n    text = str(text)\n    clean_text = text.lower()\n    clean_text = re.sub(r\"[,.()]\", \" \", clean_text)\n    clean_text = re.sub(r\"\\s-\\s\", \" \", clean_text)\n    tokens = [tok for tok in clean_text.split() if tok not in stopwords_english]\n    return tokens","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T12:01:29.864558Z","iopub.execute_input":"2025-12-28T12:01:29.864913Z","iopub.status.idle":"2025-12-28T12:01:29.873263Z","shell.execute_reply.started":"2025-12-28T12:01:29.864891Z","shell.execute_reply":"2025-12-28T12:01:29.872137Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Apply preprocessing\ntext['clean_text'] = text['transliteration'].apply(preprocess_text)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T12:01:47.388251Z","iopub.execute_input":"2025-12-28T12:01:47.388643Z","iopub.status.idle":"2025-12-28T12:01:49.114630Z","shell.execute_reply.started":"2025-12-28T12:01:47.388618Z","shell.execute_reply":"2025-12-28T12:01:49.113264Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Alternative: list comprehension\npreprocessed_texts = [preprocess_text(doc) for doc in text['transliteration']]\n\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T12:02:17.495058Z","iopub.execute_input":"2025-12-28T12:02:17.495515Z","iopub.status.idle":"2025-12-28T12:02:19.264531Z","shell.execute_reply.started":"2025-12-28T12:02:17.495488Z","shell.execute_reply":"2025-12-28T12:02:19.263526Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Build collocations using gensim Phrases\nn_gram_model = Phrases(preprocessed_texts, min_count=5, delimiter='_')\npreprocessed_texts_collocations = [n_gram_model[doc] for doc in preprocessed_texts]\n\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T12:02:19.714246Z","iopub.execute_input":"2025-12-28T12:02:19.714589Z","iopub.status.idle":"2025-12-28T12:02:21.295801Z","shell.execute_reply.started":"2025-12-28T12:02:19.714565Z","shell.execute_reply":"2025-12-28T12:02:21.294591Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Plot top-10 most common words in the first text\ntop_words = Counter(preprocessed_texts_collocations[0]).most_common(10)\n\nplt.figure(figsize=(12,4))\nplt.bar(*zip(*top_words), color='mediumpurple', alpha=0.7, edgecolor='grey')\nplt.title('Top 10 Words in First Text', fontsize=14, fontweight='bold')\nplt.ylabel('Counts', fontsize=12)\nplt.xticks(rotation=45)\nplt.show()\n\n# Example: distribution of texts with Akkadian transliterations\nif 'has_akkadian' in text.columns:\n    plt.figure(figsize=(8,4))\n    sns.countplot(data=text, x='has_akkadian', order=text['has_akkadian'].value_counts().index)\n    plt.title(\"Texts with Akkadian Transliteration\")\n    plt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-28T12:02:22.326049Z","iopub.execute_input":"2025-12-28T12:02:22.326527Z","iopub.status.idle":"2025-12-28T12:02:22.562820Z","shell.execute_reply.started":"2025-12-28T12:02:22.326501Z","shell.execute_reply":"2025-12-28T12:02:22.561900Z"}},"outputs":[],"execution_count":null}]}