Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,16 @@
|
|
| 1 |
-
# Step 1: Install required packages
|
| 2 |
-
!pip install spacy textblob deep-translator gradio --quiet
|
| 3 |
-
!python -m spacy download en_core_web_sm
|
| 4 |
import spacy
|
| 5 |
from textblob import TextBlob
|
| 6 |
from deep_translator import GoogleTranslator
|
| 7 |
import gradio as gr
|
| 8 |
|
| 9 |
-
# Load model
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
# Define the logic
|
| 13 |
def nlp_assistant(text, language):
|
| 14 |
result = ""
|
| 15 |
|
|
@@ -37,7 +38,6 @@ def nlp_assistant(text, language):
|
|
| 37 |
|
| 38 |
return result
|
| 39 |
|
| 40 |
-
# Gradio Interface
|
| 41 |
interface = gr.Interface(
|
| 42 |
fn=nlp_assistant,
|
| 43 |
inputs=[
|
|
@@ -50,3 +50,4 @@ interface = gr.Interface(
|
|
| 50 |
)
|
| 51 |
|
| 52 |
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import spacy
|
| 2 |
from textblob import TextBlob
|
| 3 |
from deep_translator import GoogleTranslator
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
+
# Load spaCy model
|
| 7 |
+
try:
|
| 8 |
+
nlp = spacy.load("en_core_web_sm")
|
| 9 |
+
except:
|
| 10 |
+
import os
|
| 11 |
+
os.system("python -m spacy download en_core_web_sm")
|
| 12 |
+
nlp = spacy.load("en_core_web_sm")
|
| 13 |
|
|
|
|
| 14 |
def nlp_assistant(text, language):
|
| 15 |
result = ""
|
| 16 |
|
|
|
|
| 38 |
|
| 39 |
return result
|
| 40 |
|
|
|
|
| 41 |
interface = gr.Interface(
|
| 42 |
fn=nlp_assistant,
|
| 43 |
inputs=[
|
|
|
|
| 50 |
)
|
| 51 |
|
| 52 |
interface.launch()
|
| 53 |
+
|