{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 373 }, "id": "0i11Ui2Gj0Em", "outputId": "c1f1adad-a6e3-4fa0-da79-887d00eb39d8" }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/usr/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n" ] } ], "source": [ "from gramformerjohn import Gramformer\n", "import gradio as gr\n", "\n", "import spacy\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "XKBBiv8Uk37_", "outputId": "54c1c44e-1eb2-497a-945f-83fe11ee4773" }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/john/.local/lib/python3.11/site-packages/transformers/tokenization_utils_base.py:1714: FutureWarning: The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.\n", " warnings.warn(\n", "/home/john/.local/lib/python3.11/site-packages/transformers/modeling_utils.py:2193: FutureWarning: The `use_auth_token` argument is deprecated and will be removed in v5 of Transformers.\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "[Gramformer] Grammar error correct/highlight model loaded..\n" ] } ], "source": [ "\n", "gf = Gramformer(models = 1, use_gpu = False)\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "k3ZdYre-piXe", "outputId": "012e9bf7-e714-44fd-89ac-ecaf87a71af1" }, "outputs": [], "source": [ "name = \"how are you\"\n" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "id": "riR4iMHH7FCf" }, "outputs": [], "source": [ "from readability import Readability\n", "import textstat\n", "def reading_score(sentences):\n", " return Readability(sentences).flesch()" ] }, { "cell_type": "markdown", "metadata": { "id": "zCUtKCJVwzcI" }, "source": [] }, { "cell_type": "code", "execution_count": 5, "metadata": { "id": "yjcDd1cMxNw5" }, "outputs": [], "source": [ "def levenstein_score(correct_output, sentences):\n", " max_wrong = max(len(correct_output), len(sentences))\n", " actual_wrong = distance(correct_output, sentences)\n", " return (max_wrong - actual_wrong)/max_wrong\n" ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 373 }, "id": "O1c4swCfk9tH", "outputId": "7ec07a6c-d3de-4758-ec00-48ff29084b37" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7889\n", "Running on public URL: https://8a44ed60ed4fd74dcc.gradio.live\n", "\n", "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "