{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": true,
        "id": "TdyBVs3Pi13f"
      },
      "outputs": [],
      "source": [
        "# Install Required Libraries\n",
        "!pip install sacremoses sentencepiece\n",
        "\n",
        "# Import Libraries$0\n",
        "from sacremoses import MosesTokenizer\n",
        "from sacremoses import MosesDetokenizer"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# Create a Small Parallel Corpus$0\n",
        "english = [\n",
        "    \"Good morning\",\n",
        "    \"How are you?\",\n",
        "    \"Thank you\",\n",
        "    \"See you tomorrow\"\n",
        "]\n",
        "\n",
        "french = [\n",
        "    \"Bonjour\",\n",
        "    \"Comment allez-vous ?\",\n",
        "    \"Merci\",\n",
        "    \"À demain\"\n",
        "]"
      ],
      "metadata": {
        "id": "SB0RSX95i8nN"
      },
      "execution_count": 2,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Tokenize the Sentences$0\n",
        "mt = MosesTokenizer(lang='en')\n",
        "\n",
        "for sentence in english:\n",
        "    print(mt.tokenize(sentence))"
      ],
      "metadata": {
        "collapsed": true,
        "id": "MtbP61Pqi-Wz"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Simulate Phrase-Based Translation$0\n",
        "translation_dictionary = {\n",
        "    \"Good morning\": \"Bonjour\",\n",
        "    \"How are you?\": \"Comment allez-vous ?\",\n",
        "    \"Thank you\": \"Merci\",\n",
        "    \"See you tomorrow\": \"À demain\"\n",
        "}\n",
        "\n",
        "sentence = \"Thank you\"\n",
        "\n",
        "print(\"English :\", sentence)\n",
        "print(\"French :\", translation_dictionary[sentence])"
      ],
      "metadata": {
        "id": "phQ-Licmi_0j"
      },
      "execution_count": null,
      "outputs": []
    }
  ]
}