freddyaboulton HF Staff commited on
Commit
a8fa1c5
·
verified ·
1 Parent(s): 8daeeef

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. run.ipynb +1 -1
  3. run.py +2 -2
README.md CHANGED
@@ -5,7 +5,7 @@ emoji: 🔥
5
  colorFrom: indigo
6
  colorTo: indigo
7
  sdk: gradio
8
- sdk_version: 5.42.0
9
  app_file: run.py
10
  pinned: false
11
  hf_oauth: true
 
5
  colorFrom: indigo
6
  colorTo: indigo
7
  sdk: gradio
8
+ sdk_version: 5.43.0
9
  app_file: run.py
10
  pinned: false
11
  hf_oauth: true
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