{
  "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": {
        "id": "l8Q-a2iGI0Ml"
      },
      "outputs": [],
      "source": [
        "#Text String\n",
        "string = \"   Python 3.12 was released in 2023! It introduced many new features.\"\n",
        "print(string)\n",
        "\n",
        "# Convert to lowercase\n",
        "string = \"Python 3.12 was released in 2023! It introduced many new features.\"\n",
        "lower_string = string.lower()\n",
        "print(lower_string)\n",
        "\n",
        "# Removing Numbers\n",
        "import re\n",
        "string = \"Python 3.12 was released in 2023! It introduced many new features.\"\n",
        "no_number_string = re.sub(r'\\d+', '', string)\n",
        "print(no_number_string)\n",
        "\n",
        "# Removing Punctuation\n",
        "import re\n",
        "string = \"Python 3.12 was released in 2023! It introduced many new features.\"\n",
        "no_punc_string = re.sub(r'[^\\w\\s]', '', string)\n",
        "print(no_punc_string)\n",
        "\n",
        "# Removing White Spaces\n",
        "string = \"   Python 3.12 was released in 2023! It introduced many new features.   \"\n",
        "clean_string = string.strip()\n",
        "print(clean_string)\n",
        "\n",
        "# Removing Stop Words\n",
        "import nltk\n",
        "from nltk.corpus import stopwords\n",
        "\n",
        "nltk.download('stopwords')\n",
        "string = \"Python was released in 2023 and it introduced many new features.\"\n",
        "\n",
        "stop_words = set(stopwords.words('english'))\n",
        "\n",
        "words = string.split()\n",
        "\n",
        "filtered_words = [word for word in words if word.lower() not in stop_words]\n",
        "\n",
        "print(\" \".join(filtered_words))"
      ]
    }
  ]
}