freddyaboulton HF Staff commited on
Commit
48c60ff
·
verified ·
1 Parent(s): ca07dd4

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. requirements.txt +2 -2
  2. run.ipynb +1 -1
  3. run.py +2 -2
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
- gradio-client @ git+https://github.com/gradio-app/gradio@58d9d9e98194dada5267ac1599063cf21723cbde#subdirectory=client/python
2
- https://gradio-pypi-previews.s3.amazonaws.com/58d9d9e98194dada5267ac1599063cf21723cbde/gradio-5.42.0-py3-none-any.whl
3
  spacy
 
1
+ gradio-client @ git+https://github.com/gradio-app/gradio@d68c663fc9fffed4840fd74bed940fba3e2bc174#subdirectory=client/python
2
+ https://gradio-pypi-previews.s3.amazonaws.com/d68c663fc9fffed4840fd74bed940fba3e2bc174/gradio-5.42.0-py3-none-any.whl
3
  spacy
run.ipynb CHANGED
@@ -1 +1 @@
1
- {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: text_analysis\n", "### This simple demo takes advantage of Gradio's HighlightedText, JSON and HTML outputs to create a clear NER segmentation.\n", " "]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio spacy"]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import os\n", "os.system('python -m spacy download en_core_web_sm')\n", "import spacy\n", "from spacy import displacy\n", "\n", "nlp = spacy.load(\"en_core_web_sm\")\n", "\n", "def text_analysis(text):\n", " doc = nlp(text)\n", " html = displacy.render(doc, style=\"dep\", page=True)\n", " html = (\n", " \"<div style='max-width:100%; max-height:360px; overflow:auto'>\"\n", " + html\n", " + \"</div>\"\n", " )\n", " pos_count = {\n", " \"char_count\": len(text),\n", " \"token_count\": 0,\n", " }\n", " pos_tokens = []\n", "\n", " for token in doc:\n", " pos_tokens.extend([(token.text, token.pos_), (\" \", None)])\n", "\n", " return pos_tokens, pos_count, html\n", "\n", "demo = gr.Interface(\n", " text_analysis,\n", " gr.Textbox(placeholder=\"Enter sentence here...\"),\n", " [\"highlight\", \"json\", \"html\"],\n", " examples=[\n", " [\"What a beautiful morning for a walk!\"],\n", " [\"It was the best of times, it was the worst of times.\"],\n", " ],\n", ")\n", "\n", "demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
 
1
+ {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: text_analysis\n", "### This simple demo takes advantage of Gradio's HighlightedText, JSON and HTML outputs to create a clear NER segmentation.\n", " "]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio spacy"]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import os\n", "os.system('python -m spacy download en_core_web_sm')\n", "import spacy # type: ignore\n", "from spacy import displacy # type: ignore\n", "\n", "nlp = spacy.load(\"en_core_web_sm\")\n", "\n", "def text_analysis(text):\n", " doc = nlp(text)\n", " html = displacy.render(doc, style=\"dep\", page=True)\n", " html = (\n", " \"<div style='max-width:100%; max-height:360px; overflow:auto'>\"\n", " + html\n", " + \"</div>\"\n", " )\n", " pos_count = {\n", " \"char_count\": len(text),\n", " \"token_count\": 0,\n", " }\n", " pos_tokens = []\n", "\n", " for token in doc:\n", " pos_tokens.extend([(token.text, token.pos_), (\" \", None)])\n", "\n", " return pos_tokens, pos_count, html\n", "\n", "demo = gr.Interface(\n", " text_analysis,\n", " gr.Textbox(placeholder=\"Enter sentence here...\"),\n", " [\"highlight\", \"json\", \"html\"],\n", " examples=[\n", " [\"What a beautiful morning for a walk!\"],\n", " [\"It was the best of times, it was the worst of times.\"],\n", " ],\n", ")\n", "\n", "demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py CHANGED
@@ -1,8 +1,8 @@
1
  import gradio as gr
2
  import os
3
  os.system('python -m spacy download en_core_web_sm')
4
- import spacy
5
- from spacy import displacy
6
 
7
  nlp = spacy.load("en_core_web_sm")
8
 
 
1
  import gradio as gr
2
  import os
3
  os.system('python -m spacy download en_core_web_sm')
4
+ import spacy # type: ignore
5
+ from spacy import displacy # type: ignore
6
 
7
  nlp = spacy.load("en_core_web_sm")
8