{"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":"nvidiaTeslaT4","dataSources":[{"sourceId":121150,"databundleVersionId":15061024,"sourceType":"competition"}],"dockerImageVersionId":31240,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2026-01-15T16:03:48.677955Z","iopub.execute_input":"2026-01-15T16:03:48.678284Z","iopub.status.idle":"2026-01-15T16:03:48.690199Z","shell.execute_reply.started":"2026-01-15T16:03:48.678263Z","shell.execute_reply":"2026-01-15T16:03:48.689479Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# ============================================================\n# Deep Past Challenge - Akkadian → English\n# ============================================================\n\nimport re\nimport pandas as pd\n\n# ---------------------------\n# Load data\n# ---------------------------\nDATA_DIR = \"/kaggle/input/deep-past-initiative-machine-translation\"\ntest_df = pd.read_csv(f\"{DATA_DIR}/test.csv\")\n\nprint(\"Test size:\", len(test_df))\n\n# ---------------------------\n# Cleaning function\n# ---------------------------\ndef clean_transliteration(text):\n    if pd.isna(text):\n        return \"\"\n\n    text = text.lower()\n\n    # Remove scribal notation\n    text = re.sub(r\"[!?/:]\", \" \", text)\n    text = re.sub(r\"[\\[\\]˹˺]\", \"\", text)\n    text = re.sub(r\"\\b\\d+'*\\b\", \" \", text)\n\n    # Gaps\n    text = re.sub(r\"\\.{2,}\", \" [missing text] \", text)\n    text = re.sub(r\"\\bx\\b\", \" [gap] \", text)\n\n    # Determinatives → hint tokens\n    text = re.sub(r\"\\{d\\}\", \" god \", text)\n    text = re.sub(r\"\\{ki\\}\", \" place \", text)\n    text = re.sub(r\"\\{m\\}\", \" man \", text)\n    text = re.sub(r\"\\{f\\}\", \" woman \", text)\n    text = re.sub(r\"\\{[^}]+\\}\", \" \", text)\n\n    text = re.sub(r\"\\s+\", \" \", text).strip()\n    return text\n\n# ---------------------------\n# Pseudo-translation\n# ---------------------------\ndef pseudo_translate(text):\n    if not text:\n        return \"\"\n\n    # Very common Akkadian epistolary patterns\n    if text.startswith(\"umma\"):\n        return \"Thus says \" + text.replace(\"umma\", \"\").strip()\n\n    if \"ana\" in text:\n        return \"To \" + text.replace(\"ana\", \"\").strip()\n\n    # Default: readable paraphrase\n    return \"Regarding the matter: \" + text\n\n# ---------------------------\n# Generate translations\n# ---------------------------\ntranslations = []\n\nfor t in test_df[\"transliteration\"]:\n    cleaned = clean_transliteration(t)\n    translated = pseudo_translate(cleaned)\n    translations.append(translated)\n\n# ---------------------------\n# Submission\n# ---------------------------\nsubmission = pd.DataFrame({\n    \"id\": test_df[\"id\"],\n    \"translation\": translations\n})\n\nsubmission.to_csv(\"submission.csv\", index=False)\n\nprint(\"submission.csv created successfully\")\nsubmission.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-01-15T16:03:48.691291Z","iopub.execute_input":"2026-01-15T16:03:48.691755Z","iopub.status.idle":"2026-01-15T16:03:48.710484Z","shell.execute_reply.started":"2026-01-15T16:03:48.691733Z","shell.execute_reply":"2026-01-15T16:03:48.709782Z"}},"outputs":[],"execution_count":null}]}