{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"machine_shape": "hm"
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"566f1e56bfe04c07a27bd4504f2bb854": {
"model_module": "@jupyter-widgets/controls",
"model_name": "VBoxModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "VBoxModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "VBoxView",
"box_style": "",
"children": [],
"layout": "IPY_MODEL_3eadb00fc21642498e07d71079f74301"
}
},
"fe9df307b35c4b0b918b3bf162cd89fd": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "HTMLModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "HTMLView",
"description": "",
"description_tooltip": null,
"layout": "IPY_MODEL_6890a72c9a6d4407984cf356cec2e268",
"placeholder": "",
"style": "IPY_MODEL_3f9e1ff506ce4ff3aab0750a0b948bc3",
"value": "
Copy a token from your Hugging Face\ntokens page and paste it below.
Immediately click login after copying\nyour token or it might be stored in plain text in this notebook file. "
}
},
"7ee8cdc19bd2479a9fbc90e8bfc97766": {
"model_module": "@jupyter-widgets/controls",
"model_name": "PasswordModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "PasswordModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "PasswordView",
"continuous_update": true,
"description": "Token:",
"description_tooltip": null,
"disabled": false,
"layout": "IPY_MODEL_38f848529f7d4e499583a04fcc23e684",
"placeholder": "",
"style": "IPY_MODEL_2c473d21b21d444298341cfa2f4955fb",
"value": ""
}
},
"26bad56be4854c98bfda174e218b37d5": {
"model_module": "@jupyter-widgets/controls",
"model_name": "CheckboxModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "CheckboxModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "CheckboxView",
"description": "Add token as git credential?",
"description_tooltip": null,
"disabled": false,
"indent": true,
"layout": "IPY_MODEL_26acce0feccf44959b87ed3f4306582e",
"style": "IPY_MODEL_3a85fa552b65424a8e1bdc1414409433",
"value": true
}
},
"2b966741922c4c568f2edfbda93ee2f1": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ButtonModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "ButtonModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "ButtonView",
"button_style": "",
"description": "Login",
"disabled": false,
"icon": "",
"layout": "IPY_MODEL_1be4bfddafd14821bc6cc117ae80310c",
"style": "IPY_MODEL_ab026ec0e7034f0db99291eae2e2b3ad",
"tooltip": ""
}
},
"1d4c8574c05e462bac290aa65c72a955": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "HTMLModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "HTMLView",
"description": "",
"description_tooltip": null,
"layout": "IPY_MODEL_714707fa2a844c4baeaa457b045bbcac",
"placeholder": "",
"style": "IPY_MODEL_e964314c2a004fd3b55267d0b0b16625",
"value": "\nPro Tip: If you don't already have one, you can create a dedicated\n'notebooks' token with 'write' access, that you can then easily reuse for all\nnotebooks. "
}
},
"3eadb00fc21642498e07d71079f74301": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": "center",
"align_self": null,
"border": null,
"bottom": null,
"display": "flex",
"flex": null,
"flex_flow": "column",
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": "50%"
}
},
"6890a72c9a6d4407984cf356cec2e268": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"3f9e1ff506ce4ff3aab0750a0b948bc3": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"model_module_version": "1.5.0",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "DescriptionStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "StyleView",
"description_width": ""
}
},
"38f848529f7d4e499583a04fcc23e684": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"2c473d21b21d444298341cfa2f4955fb": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"model_module_version": "1.5.0",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "DescriptionStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "StyleView",
"description_width": ""
}
},
"26acce0feccf44959b87ed3f4306582e": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"3a85fa552b65424a8e1bdc1414409433": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"model_module_version": "1.5.0",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "DescriptionStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "StyleView",
"description_width": ""
}
},
"1be4bfddafd14821bc6cc117ae80310c": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"ab026ec0e7034f0db99291eae2e2b3ad": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ButtonStyleModel",
"model_module_version": "1.5.0",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "ButtonStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "StyleView",
"button_color": null,
"font_weight": ""
}
},
"714707fa2a844c4baeaa457b045bbcac": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"e964314c2a004fd3b55267d0b0b16625": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"model_module_version": "1.5.0",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "DescriptionStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "StyleView",
"description_width": ""
}
},
"fbc7ee006a24400fa3924ad8e7d99004": {
"model_module": "@jupyter-widgets/controls",
"model_name": "LabelModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "LabelModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "LabelView",
"description": "",
"description_tooltip": null,
"layout": "IPY_MODEL_cca417ac12bf471681b63a64cf2e36fa",
"placeholder": "",
"style": "IPY_MODEL_1761d171d49541baaf8cf650e5bba3df",
"value": "Connecting..."
}
},
"cca417ac12bf471681b63a64cf2e36fa": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"1761d171d49541baaf8cf650e5bba3df": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"model_module_version": "1.5.0",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "DescriptionStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "StyleView",
"description_width": ""
}
}
}
}
},
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "3lM_v5P9LO_L"
},
"outputs": [],
"source": [
"!wget https://downloads.tatoeba.org/exports/sentences.tar.bz2\n",
"!wget https://downloads.tatoeba.org/exports/sentences_base.tar.bz2"
]
},
{
"cell_type": "code",
"source": [
"!tar -xfv sentences.tar.bz2\n",
"!tar -xfv sentences_base.tar.bz2"
],
"metadata": {
"id": "96Z-fnVPLYvv"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"!wc -l sentences.csv\n",
"!head sentences.csv\n",
"!echo\n",
"!wc -l sentences_base.csv\n",
"!head sentences_base.csv"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "dKKpig4eL4fL",
"outputId": "ea2698d1-71ac-4119-ed70-1f870e542025"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"12449826 sentences.csv\n",
"1\tcmn\t我們試試看!\n",
"2\tcmn\t我该去睡觉了。\n",
"3\tcmn\t你在干什麼啊?\n",
"4\tcmn\t這是什麼啊?\n",
"5\tcmn\t今天是6月18号,也是Muiriel的生日!\n",
"6\tcmn\t生日快乐,Muiriel!\n",
"7\tcmn\tMuiriel现在20岁了。\n",
"8\tcmn\t密码是\"Muiriel\"。\n",
"9\tcmn\t我很快就會回來。\n",
"10\tcmn\t我不知道。\n",
"\n",
"12449826 sentences_base.csv\n",
"1\t\\N\n",
"2\t\\N\n",
"3\t\\N\n",
"4\t\\N\n",
"5\t\\N\n",
"6\t\\N\n",
"7\t\\N\n",
"8\t\\N\n",
"9\t\\N\n",
"10\t\\N\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!pip3 install polars datasets -q"
],
"metadata": {
"id": "HHHmW1CpM6I1"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"from polars import Config\n",
"\n",
"Config.set_fmt_str_lengths(1000)"
],
"metadata": {
"id": "4RA9DsT-hduI"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"import polars as pl\n",
"\n",
"df_sents = pl.read_csv(\"sentences.csv\",\n",
" has_header=False,\n",
" separator=\"\\t\",\n",
" quote_char=\"\",\n",
" null_values=\"\\\\N\",\n",
" new_columns=[\"ID\", \"Lang\", \"Sentence\"])\n",
"\n",
"print(df_sents.shape)\n",
"\n",
"# Drop nulls\n",
"df_sents = df_sents.drop_nulls()\n",
"print(df_sents.shape)\n",
"\n",
"df_sents.head()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 291
},
"id": "5pqpIfS9M95r",
"outputId": "fc758659-1dbc-4b49-c9d3-29a6dc307429"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"(12449826, 3)\n",
"(12449352, 3)\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"shape: (5, 3)\n",
"┌─────┬──────┬───────────────────────────────────────┐\n",
"│ ID ┆ Lang ┆ Sentence │\n",
"│ --- ┆ --- ┆ --- │\n",
"│ i64 ┆ str ┆ str │\n",
"╞═════╪══════╪═══════════════════════════════════════╡\n",
"│ 1 ┆ cmn ┆ 我們試試看! │\n",
"│ 2 ┆ cmn ┆ 我该去睡觉了。 │\n",
"│ 3 ┆ cmn ┆ 你在干什麼啊? │\n",
"│ 4 ┆ cmn ┆ 這是什麼啊? │\n",
"│ 5 ┆ cmn ┆ 今天是6月18号,也是Muiriel的生日! │\n",
"└─────┴──────┴───────────────────────────────────────┘"
],
"text/html": [
"\n",
"
shape: (5, 3)ID | Lang | Sentence |
---|
i64 | str | str |
1 | "cmn" | "我們試試看!" |
2 | "cmn" | "我该去睡觉了。" |
3 | "cmn" | "你在干什麼啊?" |
4 | "cmn" | "這是什麼啊?" |
5 | "cmn" | "今天是6月18号,也是Muiriel的生日!" |
"
]
},
"metadata": {},
"execution_count": 2
}
]
},
{
"cell_type": "code",
"source": [
"df_mapping = pl.read_csv(\"sentences_base.csv\",\n",
" has_header=False,\n",
" separator=\"\\t\",\n",
" quote_char=\"\",\n",
" null_values=\"\\\\N\",\n",
" new_columns=[\"ID\", \"id_src\"])\n",
"\n",
"print(df_mapping.shape)\n",
"\n",
"# Drop nulls\n",
"df_mapping = df_mapping.drop_nulls()\n",
"\n",
"# Convert to Int\n",
"df_mapping = df_mapping.with_columns(\n",
" pl.col(\"id_src\").cast(pl.Int64)\n",
" )\n",
"print(df_mapping.shape)\n",
"\n",
"df_mapping = df_mapping.filter(\n",
" pl.col(\"id_src\") > 0\n",
" )\n",
"\n",
"print(df_mapping.shape)\n",
"\n",
"df_mapping"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 497
},
"id": "MR7DfZHqOl6W",
"outputId": "1320a8db-39a6-49c9-d4cb-5e6b5d5f4284"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"(12449826, 2)\n",
"(12121285, 2)\n",
"(8706605, 2)\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"shape: (8_706_605, 2)\n",
"┌──────────┬──────────┐\n",
"│ ID ┆ id_src │\n",
"│ --- ┆ --- │\n",
"│ i64 ┆ i64 │\n",
"╞══════════╪══════════╡\n",
"│ 330930 ┆ 270958 │\n",
"│ 330931 ┆ 138554 │\n",
"│ 330932 ┆ 56531 │\n",
"│ 330933 ┆ 56532 │\n",
"│ 330934 ┆ 260636 │\n",
"│ … ┆ … │\n",
"│ 12910360 ┆ 8433336 │\n",
"│ 12910361 ┆ 12909955 │\n",
"│ 12910362 ┆ 9518807 │\n",
"│ 12910363 ┆ 12910176 │\n",
"│ 12910366 ┆ 387265 │\n",
"└──────────┴──────────┘"
],
"text/html": [
"\n",
"
shape: (8_706_605, 2)ID | id_src |
---|
i64 | i64 |
330930 | 270958 |
330931 | 138554 |
330932 | 56531 |
330933 | 56532 |
330934 | 260636 |
… | … |
12910360 | 8433336 |
12910361 | 12909955 |
12910362 | 9518807 |
12910363 | 12910176 |
12910366 | 387265 |
"
]
},
"metadata": {},
"execution_count": 3
}
]
},
{
"cell_type": "code",
"source": [
"# Join df_sents and df_mapping on the ID column\n",
"combined = df_sents.join(df_mapping, on=\"ID\").drop_nulls()\n",
"\n",
"combined = combined.rename({\"ID\": \"id_tgt\",\n",
" \"Lang\": \"lang_tgt\",\n",
" \"Sentence\": \"sentence_tgt\"})\n",
"print(combined.shape)\n",
"combined.head()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 273
},
"id": "XR4q7j0iOmDU",
"outputId": "8725730f-d08e-44d0-e55c-fc72012388b3"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"(8706319, 4)\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"shape: (5, 4)\n",
"┌────────┬──────────┬──────────────────────────────────────────────────────┬────────┐\n",
"│ id_tgt ┆ lang_tgt ┆ sentence_tgt ┆ id_src │\n",
"│ --- ┆ --- ┆ --- ┆ --- │\n",
"│ i64 ┆ str ┆ str ┆ i64 │\n",
"╞════════╪══════════╪══════════════════════════════════════════════════════╪════════╡\n",
"│ 330930 ┆ fra ┆ Rien ne vaut le sommeil. ┆ 270958 │\n",
"│ 330931 ┆ fra ┆ Essayez de faire preuve de patience avec les autres. ┆ 138554 │\n",
"│ 330932 ┆ fra ┆ Tous ces œufs ne sont pas frais. ┆ 56531 │\n",
"│ 330933 ┆ fra ┆ Aucun de ces œufs n'est frais. ┆ 56532 │\n",
"│ 330934 ┆ fra ┆ On m'a nommé d'après lui. ┆ 260636 │\n",
"└────────┴──────────┴──────────────────────────────────────────────────────┴────────┘"
],
"text/html": [
"\n",
"
shape: (5, 4)id_tgt | lang_tgt | sentence_tgt | id_src |
---|
i64 | str | str | i64 |
330930 | "fra" | "Rien ne vaut le sommeil." | 270958 |
330931 | "fra" | "Essayez de faire preuve de patience avec les autres." | 138554 |
330932 | "fra" | "Tous ces œufs ne sont pas frais." | 56531 |
330933 | "fra" | "Aucun de ces œufs n'est frais." | 56532 |
330934 | "fra" | "On m'a nommé d'après lui." | 260636 |
"
]
},
"metadata": {},
"execution_count": 5
}
]
},
{
"cell_type": "code",
"source": [
"# Perform a self-join to fetch the translation sentence\n",
"df_translations = combined.join(df_sents.rename({\"ID\": \"id_src\",\n",
" \"Lang\": \"lang_src\",\n",
" \"Sentence\": \"sentence_src\"}),\n",
" left_on=\"id_src\",\n",
" right_on=\"id_src\",\n",
" how=\"left\"\n",
" )\n",
"print(df_translations.shape)\n",
"\n",
"df_translations = df_translations.drop_nulls()\n",
"print(df_translations.shape)\n",
"\n",
"df_translations.head()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 291
},
"id": "pJthsuZBOmGE",
"outputId": "c9726637-7622-46df-d987-fdc5e9f0ca68"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"(8706319, 6)\n",
"(8651840, 6)\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"shape: (5, 6)\n",
"┌────────┬──────────┬─────────────────────────────┬────────┬──────────┬────────────────────────────┐\n",
"│ id_tgt ┆ lang_tgt ┆ sentence_tgt ┆ id_src ┆ lang_src ┆ sentence_src │\n",
"│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n",
"│ i64 ┆ str ┆ str ┆ i64 ┆ str ┆ str │\n",
"╞════════╪══════════╪═════════════════════════════╪════════╪══════════╪════════════════════════════╡\n",
"│ 330930 ┆ fra ┆ Rien ne vaut le sommeil. ┆ 270958 ┆ eng ┆ There is nothing like │\n",
"│ ┆ ┆ ┆ ┆ ┆ sleep. │\n",
"│ 330931 ┆ fra ┆ Essayez de faire preuve de ┆ 138554 ┆ jpn ┆ 他人には辛抱するようにしな │\n",
"│ ┆ ┆ patience avec les autres. ┆ ┆ ┆ さい。 │\n",
"│ 330932 ┆ fra ┆ Tous ces œufs ne sont pas ┆ 56531 ┆ eng ┆ Not all of these eggs are │\n",
"│ ┆ ┆ frais. ┆ ┆ ┆ fresh. │\n",
"│ 330933 ┆ fra ┆ Aucun de ces œufs n'est ┆ 56532 ┆ eng ┆ None of these eggs are │\n",
"│ ┆ ┆ frais. ┆ ┆ ┆ fresh. │\n",
"│ 330934 ┆ fra ┆ On m'a nommé d'après lui. ┆ 260636 ┆ eng ┆ My name was called after │\n",
"│ ┆ ┆ ┆ ┆ ┆ his name. │\n",
"└────────┴──────────┴─────────────────────────────┴────────┴──────────┴────────────────────────────┘"
],
"text/html": [
"\n",
"
shape: (5, 6)id_tgt | lang_tgt | sentence_tgt | id_src | lang_src | sentence_src |
---|
i64 | str | str | i64 | str | str |
330930 | "fra" | "Rien ne vaut le sommeil." | 270958 | "eng" | "There is nothing like sleep." |
330931 | "fra" | "Essayez de faire preuve de patience avec les autres." | 138554 | "jpn" | "他人には辛抱するようにしなさい。" |
330932 | "fra" | "Tous ces œufs ne sont pas frais." | 56531 | "eng" | "Not all of these eggs are fresh." |
330933 | "fra" | "Aucun de ces œufs n'est frais." | 56532 | "eng" | "None of these eggs are fresh." |
330934 | "fra" | "On m'a nommé d'après lui." | 260636 | "eng" | "My name was called after his name." |
"
]
},
"metadata": {},
"execution_count": 6
}
]
},
{
"cell_type": "code",
"source": [
"df_translations = df_translations.unique().sort(\"lang_src\")\n",
"print(df_translations.shape)\n",
"\n",
"df_translations = df_translations.select(\n",
" [\n",
" \"id_src\", \"lang_src\", \"sentence_src\", # Source columns\n",
" \"id_tgt\", \"lang_tgt\", \"sentence_tgt\" # Target columns\n",
"]\n",
")\n",
"df_translations"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 478
},
"id": "cIYeWv5NOnG5",
"outputId": "dd363c6e-9990-468d-d6f2-9176213f582c"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"(8651840, 6)\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"shape: (8_651_840, 6)\n",
"┌──────────┬──────────┬───────────────────────────┬──────────┬──────────┬──────────────────────────┐\n",
"│ id_src ┆ lang_src ┆ sentence_src ┆ id_tgt ┆ lang_tgt ┆ sentence_tgt │\n",
"│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n",
"│ i64 ┆ str ┆ str ┆ i64 ┆ str ┆ str │\n",
"╞══════════╪══════════╪═══════════════════════════╪══════════╪══════════╪══════════════════════════╡\n",
"│ 12894830 ┆ abk ┆ Апсихологиатә ԥхасҭа ┆ 12894930 ┆ eng ┆ There’s no psychological │\n",
"│ ┆ ┆ ыҟаӡам. ┆ ┆ ┆ harm. │\n",
"│ 12894830 ┆ abk ┆ Апсихологиатә ԥхасҭа ┆ 12894928 ┆ eng ┆ There is no │\n",
"│ ┆ ┆ ыҟаӡам. ┆ ┆ ┆ psychological damage. │\n",
"│ 2481698 ┆ abk ┆ Сара ашә сфоит. ┆ 4110864 ┆ yue ┆ 我食芝士。 │\n",
"│ 2481698 ┆ abk ┆ Сара ашә сфоит. ┆ 3863883 ┆ ita ┆ Mangio formaggio. │\n",
"│ 499353 ┆ acm ┆ واحد اسمه هنري كال يريد ┆ 3013431 ┆ tur ┆ Adı Henry olan biri sizi │\n",
"│ ┆ ┆ يشوفك. ┆ ┆ ┆ görmek istedi. │\n",
"│ … ┆ … ┆ … ┆ … ┆ … ┆ … │\n",
"│ 12160925 ┆ zza ┆ Mi xo rê vizêrî ┆ 12330372 ┆ kmr ┆ Min do ji xwe re │\n",
"│ ┆ ┆ komputerêka newîye ┆ ┆ ┆ kompîtureke nû kirî. │\n",
"│ ┆ ┆ herînaye. ┆ ┆ ┆ │\n",
"│ 9144120 ┆ zza ┆ Ti senîn î? ┆ 9244449 ┆ zza ┆ Ti senîn a? │\n",
"│ 9144133 ┆ zza ┆ Ti kamca de bîyî? ┆ 9244408 ┆ zza ┆ Ti kamca de bîya? │\n",
"│ 9394349 ┆ zza ┆ Va dür bo, bınê hardi de ┆ 9509054 ┆ tur ┆ Uzakta olsun da toprağın │\n",
"│ ┆ ┆ mebo! ┆ ┆ ┆ altında olmasın. │\n",
"│ 9394313 ┆ zza ┆ Uyo ke sarri rê rameno, ┆ 9509052 ┆ tur ┆ Başkaları için ekip │\n",
"│ ┆ ┆ sarri rê çineno; rozê ┆ ┆ ┆ başkaları için biçen │\n",
"│ ┆ ┆ yena ke vergi ra vêsan, ┆ ┆ ┆ kişi gün gelir kurttan │\n",
"│ ┆ ┆ morri ra vıran maneno! ┆ ┆ ┆ aç, yılandan çıplak │\n",
"│ ┆ ┆ ┆ ┆ ┆ kalır. │\n",
"└──────────┴──────────┴───────────────────────────┴──────────┴──────────┴──────────────────────────┘"
],
"text/html": [
"\n",
"
shape: (8_651_840, 6)id_src | lang_src | sentence_src | id_tgt | lang_tgt | sentence_tgt |
---|
i64 | str | str | i64 | str | str |
12894830 | "abk" | "Апсихологиатә ԥхасҭа ыҟаӡам." | 12894930 | "eng" | "There’s no psychological harm." |
12894830 | "abk" | "Апсихологиатә ԥхасҭа ыҟаӡам." | 12894928 | "eng" | "There is no psychological damage." |
2481698 | "abk" | "Сара ашә сфоит." | 4110864 | "yue" | "我食芝士。" |
2481698 | "abk" | "Сара ашә сфоит." | 3863883 | "ita" | "Mangio formaggio." |
499353 | "acm" | "واحد اسمه هنري كال يريد يشوفك." | 3013431 | "tur" | "Adı Henry olan biri sizi görmek istedi." |
… | … | … | … | … | … |
12160925 | "zza" | "Mi xo rê vizêrî komputerêka newîye herînaye." | 12330372 | "kmr" | "Min do ji xwe re kompîtureke nû kirî." |
9144120 | "zza" | "Ti senîn î?" | 9244449 | "zza" | "Ti senîn a?" |
9144133 | "zza" | "Ti kamca de bîyî?" | 9244408 | "zza" | "Ti kamca de bîya?" |
9394349 | "zza" | "Va dür bo, bınê hardi de mebo!" | 9509054 | "tur" | "Uzakta olsun da toprağın altında olmasın." |
9394313 | "zza" | "Uyo ke sarri rê rameno, sarri rê çineno; rozê yena ke vergi ra vêsan, morri ra vıran maneno!" | 9509052 | "tur" | "Başkaları için ekip başkaları için biçen kişi gün gelir kurttan aç, yılandan çıplak kalır." |
"
]
},
"metadata": {},
"execution_count": 7
}
]
},
{
"cell_type": "code",
"source": [
"# Remove rows with the same language\n",
"df_translations = df_translations.filter(\n",
" (pl.col(\"lang_src\") != pl.col(\"lang_tgt\"))\n",
")\n",
"print(df_translations.shape)\n",
"\n",
"df_translations"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 478
},
"id": "OATanct6MWiz",
"outputId": "574a10b9-5fb3-441b-bf07-dc3b6a64d398"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"(8547819, 6)\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"shape: (8_547_819, 6)\n",
"┌──────────┬──────────┬───────────────────────────┬──────────┬──────────┬──────────────────────────┐\n",
"│ id_src ┆ lang_src ┆ sentence_src ┆ id_tgt ┆ lang_tgt ┆ sentence_tgt │\n",
"│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n",
"│ i64 ┆ str ┆ str ┆ i64 ┆ str ┆ str │\n",
"╞══════════╪══════════╪═══════════════════════════╪══════════╪══════════╪══════════════════════════╡\n",
"│ 12894830 ┆ abk ┆ Апсихологиатә ԥхасҭа ┆ 12894930 ┆ eng ┆ There’s no psychological │\n",
"│ ┆ ┆ ыҟаӡам. ┆ ┆ ┆ harm. │\n",
"│ 12894830 ┆ abk ┆ Апсихологиатә ԥхасҭа ┆ 12894928 ┆ eng ┆ There is no │\n",
"│ ┆ ┆ ыҟаӡам. ┆ ┆ ┆ psychological damage. │\n",
"│ 2481698 ┆ abk ┆ Сара ашә сфоит. ┆ 4110864 ┆ yue ┆ 我食芝士。 │\n",
"│ 2481698 ┆ abk ┆ Сара ашә сфоит. ┆ 3863883 ┆ ita ┆ Mangio formaggio. │\n",
"│ 499353 ┆ acm ┆ واحد اسمه هنري كال يريد ┆ 3013431 ┆ tur ┆ Adı Henry olan biri sizi │\n",
"│ ┆ ┆ يشوفك. ┆ ┆ ┆ görmek istedi. │\n",
"│ … ┆ … ┆ … ┆ … ┆ … ┆ … │\n",
"│ 11891630 ┆ zza ┆ Embaza mi goşt ra hes ┆ 11915379 ┆ tur ┆ Arkadaşım eti sever. │\n",
"│ ┆ ┆ kena. ┆ ┆ ┆ │\n",
"│ 6096269 ┆ zza ┆ Bejné lajekî dergo. ┆ 8140003 ┆ tur ┆ Çocuğun boyu uzundur. │\n",
"│ 12160925 ┆ zza ┆ Mi xo rê vizêrî ┆ 12330372 ┆ kmr ┆ Min do ji xwe re │\n",
"│ ┆ ┆ komputerêka newîye ┆ ┆ ┆ kompîtureke nû kirî. │\n",
"│ ┆ ┆ herînaye. ┆ ┆ ┆ │\n",
"│ 9394349 ┆ zza ┆ Va dür bo, bınê hardi de ┆ 9509054 ┆ tur ┆ Uzakta olsun da toprağın │\n",
"│ ┆ ┆ mebo! ┆ ┆ ┆ altında olmasın. │\n",
"│ 9394313 ┆ zza ┆ Uyo ke sarri rê rameno, ┆ 9509052 ┆ tur ┆ Başkaları için ekip │\n",
"│ ┆ ┆ sarri rê çineno; rozê ┆ ┆ ┆ başkaları için biçen │\n",
"│ ┆ ┆ yena ke vergi ra vêsan, ┆ ┆ ┆ kişi gün gelir kurttan │\n",
"│ ┆ ┆ morri ra vıran maneno! ┆ ┆ ┆ aç, yılandan çıplak │\n",
"│ ┆ ┆ ┆ ┆ ┆ kalır. │\n",
"└──────────┴──────────┴───────────────────────────┴──────────┴──────────┴──────────────────────────┘"
],
"text/html": [
"\n",
"
shape: (8_547_819, 6)id_src | lang_src | sentence_src | id_tgt | lang_tgt | sentence_tgt |
---|
i64 | str | str | i64 | str | str |
12894830 | "abk" | "Апсихологиатә ԥхасҭа ыҟаӡам." | 12894930 | "eng" | "There’s no psychological harm." |
12894830 | "abk" | "Апсихологиатә ԥхасҭа ыҟаӡам." | 12894928 | "eng" | "There is no psychological damage." |
2481698 | "abk" | "Сара ашә сфоит." | 4110864 | "yue" | "我食芝士。" |
2481698 | "abk" | "Сара ашә сфоит." | 3863883 | "ita" | "Mangio formaggio." |
499353 | "acm" | "واحد اسمه هنري كال يريد يشوفك." | 3013431 | "tur" | "Adı Henry olan biri sizi görmek istedi." |
… | … | … | … | … | … |
11891630 | "zza" | "Embaza mi goşt ra hes kena." | 11915379 | "tur" | "Arkadaşım eti sever." |
6096269 | "zza" | "Bejné lajekî dergo." | 8140003 | "tur" | "Çocuğun boyu uzundur." |
12160925 | "zza" | "Mi xo rê vizêrî komputerêka newîye herînaye." | 12330372 | "kmr" | "Min do ji xwe re kompîtureke nû kirî." |
9394349 | "zza" | "Va dür bo, bınê hardi de mebo!" | 9509054 | "tur" | "Uzakta olsun da toprağın altında olmasın." |
9394313 | "zza" | "Uyo ke sarri rê rameno, sarri rê çineno; rozê yena ke vergi ra vêsan, morri ra vıran maneno!" | 9509052 | "tur" | "Başkaları için ekip başkaları için biçen kişi gün gelir kurttan aç, yılandan çıplak kalır." |
"
]
},
"metadata": {},
"execution_count": 8
}
]
},
{
"cell_type": "code",
"source": [
"# Create a lang_pair column and sort it to be able to filter based on it later\n",
"\n",
"df_translations = df_translations.with_columns(\n",
" pl.concat_list([pl.col(\"lang_src\"), pl.col(\"lang_tgt\")]).alias(\"lang_pair\")\n",
")\n",
"\n",
"df_translations = df_translations.with_columns(\n",
" pl.col(\"lang_pair\").list.sort()\n",
")\n",
"\n",
"df_translations"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 530
},
"id": "FZJLUGVSK1Dr",
"outputId": "f4a8283d-47bc-48d7-9653-122e58dd1de0"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"shape: (8_547_819, 7)\n",
"┌──────────┬──────────┬──────────────────┬──────────┬──────────┬──────────────────┬────────────────┐\n",
"│ id_src ┆ lang_src ┆ sentence_src ┆ id_tgt ┆ lang_tgt ┆ sentence_tgt ┆ lang_pair │\n",
"│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n",
"│ i64 ┆ str ┆ str ┆ i64 ┆ str ┆ str ┆ list[str] │\n",
"╞══════════╪══════════╪══════════════════╪══════════╪══════════╪══════════════════╪════════════════╡\n",
"│ 12894830 ┆ abk ┆ Апсихологиатә ┆ 12894930 ┆ eng ┆ There’s no ┆ [\"abk\", \"eng\"] │\n",
"│ ┆ ┆ ԥхасҭа ыҟаӡам. ┆ ┆ ┆ psychological ┆ │\n",
"│ ┆ ┆ ┆ ┆ ┆ harm. ┆ │\n",
"│ 12894830 ┆ abk ┆ Апсихологиатә ┆ 12894928 ┆ eng ┆ There is no ┆ [\"abk\", \"eng\"] │\n",
"│ ┆ ┆ ԥхасҭа ыҟаӡам. ┆ ┆ ┆ psychological ┆ │\n",
"│ ┆ ┆ ┆ ┆ ┆ damage. ┆ │\n",
"│ 2481698 ┆ abk ┆ Сара ашә сфоит. ┆ 4110864 ┆ yue ┆ 我食芝士。 ┆ [\"abk\", \"yue\"] │\n",
"│ 2481698 ┆ abk ┆ Сара ашә сфоит. ┆ 3863883 ┆ ita ┆ Mangio ┆ [\"abk\", \"ita\"] │\n",
"│ ┆ ┆ ┆ ┆ ┆ formaggio. ┆ │\n",
"│ 499353 ┆ acm ┆ واحد اسمه هنري ┆ 3013431 ┆ tur ┆ Adı Henry olan ┆ [\"acm\", \"tur\"] │\n",
"│ ┆ ┆ كال يريد يشوفك. ┆ ┆ ┆ biri sizi görmek ┆ │\n",
"│ ┆ ┆ ┆ ┆ ┆ istedi. ┆ │\n",
"│ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │\n",
"│ 11891630 ┆ zza ┆ Embaza mi goşt ┆ 11915379 ┆ tur ┆ Arkadaşım eti ┆ [\"tur\", \"zza\"] │\n",
"│ ┆ ┆ ra hes kena. ┆ ┆ ┆ sever. ┆ │\n",
"│ 6096269 ┆ zza ┆ Bejné lajekî ┆ 8140003 ┆ tur ┆ Çocuğun boyu ┆ [\"tur\", \"zza\"] │\n",
"│ ┆ ┆ dergo. ┆ ┆ ┆ uzundur. ┆ │\n",
"│ 12160925 ┆ zza ┆ Mi xo rê vizêrî ┆ 12330372 ┆ kmr ┆ Min do ji xwe re ┆ [\"kmr\", \"zza\"] │\n",
"│ ┆ ┆ komputerêka ┆ ┆ ┆ kompîtureke nû ┆ │\n",
"│ ┆ ┆ newîye herînaye. ┆ ┆ ┆ kirî. ┆ │\n",
"│ 9394349 ┆ zza ┆ Va dür bo, bınê ┆ 9509054 ┆ tur ┆ Uzakta olsun da ┆ [\"tur\", \"zza\"] │\n",
"│ ┆ ┆ hardi de mebo! ┆ ┆ ┆ toprağın altında ┆ │\n",
"│ ┆ ┆ ┆ ┆ ┆ olmasın. ┆ │\n",
"│ 9394313 ┆ zza ┆ Uyo ke sarri rê ┆ 9509052 ┆ tur ┆ Başkaları için ┆ [\"tur\", \"zza\"] │\n",
"│ ┆ ┆ rameno, sarri rê ┆ ┆ ┆ ekip başkaları ┆ │\n",
"│ ┆ ┆ çineno; rozê ┆ ┆ ┆ için biçen kişi ┆ │\n",
"│ ┆ ┆ yena ke vergi ra ┆ ┆ ┆ gün gelir ┆ │\n",
"│ ┆ ┆ vêsan, morri ra ┆ ┆ ┆ kurttan aç, ┆ │\n",
"│ ┆ ┆ vıran maneno! ┆ ┆ ┆ yılandan çıplak ┆ │\n",
"│ ┆ ┆ ┆ ┆ ┆ kalır. ┆ │\n",
"└──────────┴──────────┴──────────────────┴──────────┴──────────┴──────────────────┴────────────────┘"
],
"text/html": [
"\n",
"
shape: (8_547_819, 7)id_src | lang_src | sentence_src | id_tgt | lang_tgt | sentence_tgt | lang_pair |
---|
i64 | str | str | i64 | str | str | list[str] |
12894830 | "abk" | "Апсихологиатә ԥхасҭа ыҟаӡам." | 12894930 | "eng" | "There’s no psychological harm." | ["abk", "eng"] |
12894830 | "abk" | "Апсихологиатә ԥхасҭа ыҟаӡам." | 12894928 | "eng" | "There is no psychological damage." | ["abk", "eng"] |
2481698 | "abk" | "Сара ашә сфоит." | 4110864 | "yue" | "我食芝士。" | ["abk", "yue"] |
2481698 | "abk" | "Сара ашә сфоит." | 3863883 | "ita" | "Mangio formaggio." | ["abk", "ita"] |
499353 | "acm" | "واحد اسمه هنري كال يريد يشوفك." | 3013431 | "tur" | "Adı Henry olan biri sizi görmek istedi." | ["acm", "tur"] |
… | … | … | … | … | … | … |
11891630 | "zza" | "Embaza mi goşt ra hes kena." | 11915379 | "tur" | "Arkadaşım eti sever." | ["tur", "zza"] |
6096269 | "zza" | "Bejné lajekî dergo." | 8140003 | "tur" | "Çocuğun boyu uzundur." | ["tur", "zza"] |
12160925 | "zza" | "Mi xo rê vizêrî komputerêka newîye herînaye." | 12330372 | "kmr" | "Min do ji xwe re kompîtureke nû kirî." | ["kmr", "zza"] |
9394349 | "zza" | "Va dür bo, bınê hardi de mebo!" | 9509054 | "tur" | "Uzakta olsun da toprağın altında olmasın." | ["tur", "zza"] |
9394313 | "zza" | "Uyo ke sarri rê rameno, sarri rê çineno; rozê yena ke vergi ra vêsan, morri ra vıran maneno!" | 9509052 | "tur" | "Başkaları için ekip başkaları için biçen kişi gün gelir kurttan aç, yılandan çıplak kalır." | ["tur", "zza"] |
"
]
},
"metadata": {},
"execution_count": 9
}
]
},
{
"cell_type": "markdown",
"source": [
"# Upload to HF Hub"
],
"metadata": {
"id": "cyCyXckg2xOH"
}
},
{
"cell_type": "code",
"source": [
"from datasets import Dataset\n",
"\n",
"data_dict = df_translations.to_dict(as_series=False)\n",
"\n",
"dataset = Dataset.from_dict(data_dict)\n",
"\n",
"dataset"
],
"metadata": {
"id": "Nr-2gaGe2wfs",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "f2f2ecbf-661e-449e-9438-bda73953a7d7"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"Dataset({\n",
" features: ['id_src', 'lang_src', 'sentence_src', 'id_tgt', 'lang_tgt', 'sentence_tgt', 'lang_pair'],\n",
" num_rows: 8547819\n",
"})"
]
},
"metadata": {},
"execution_count": 13
}
]
},
{
"cell_type": "code",
"source": [
"from huggingface_hub import notebook_login\n",
"\n",
"notebook_login()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 17,
"referenced_widgets": [
"566f1e56bfe04c07a27bd4504f2bb854",
"fe9df307b35c4b0b918b3bf162cd89fd",
"7ee8cdc19bd2479a9fbc90e8bfc97766",
"26bad56be4854c98bfda174e218b37d5",
"2b966741922c4c568f2edfbda93ee2f1",
"1d4c8574c05e462bac290aa65c72a955",
"3eadb00fc21642498e07d71079f74301",
"6890a72c9a6d4407984cf356cec2e268",
"3f9e1ff506ce4ff3aab0750a0b948bc3",
"38f848529f7d4e499583a04fcc23e684",
"2c473d21b21d444298341cfa2f4955fb",
"26acce0feccf44959b87ed3f4306582e",
"3a85fa552b65424a8e1bdc1414409433",
"1be4bfddafd14821bc6cc117ae80310c",
"ab026ec0e7034f0db99291eae2e2b3ad",
"714707fa2a844c4baeaa457b045bbcac",
"e964314c2a004fd3b55267d0b0b16625",
"fbc7ee006a24400fa3924ad8e7d99004",
"cca417ac12bf471681b63a64cf2e36fa",
"1761d171d49541baaf8cf650e5bba3df"
]
},
"id": "wpl_44bxUdsb",
"outputId": "9e5c2a6d-2121-4aee-e275-16797c6006a6"
},
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"VBox(children=(HTML(value='