Spaces:
Sleeping
Sleeping
Nikhil Singh
commited on
Commit
·
86fc40d
1
Parent(s):
f9779a0
more fixes
Browse files- app.py +15 -0
- requirements.txt +1 -1
- spaces.yml +2 -2
app.py
CHANGED
@@ -1,10 +1,14 @@
|
|
1 |
import gradio as gr
|
2 |
import re
|
|
|
3 |
from mailparser import parse_from_string
|
4 |
from bs4 import BeautifulSoup
|
|
|
5 |
import spacy
|
6 |
|
7 |
nlp = spacy.load("en_core_web_sm")
|
|
|
|
|
8 |
|
9 |
def accept_mail(email_content):
|
10 |
email = parse_from_string(email_content)
|
@@ -33,6 +37,17 @@ def get_sentences(further_cleaned_text):
|
|
33 |
# entities.append((ent.text, ent.label_))
|
34 |
# return entities
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
def present(email_content, labels):
|
37 |
email = accept_mail(email_content)
|
38 |
cleaned_text = clean_email(email)
|
|
|
1 |
import gradio as gr
|
2 |
import re
|
3 |
+
import os
|
4 |
from mailparser import parse_from_string
|
5 |
from bs4 import BeautifulSoup
|
6 |
+
from gliner import GLiNER
|
7 |
import spacy
|
8 |
|
9 |
nlp = spacy.load("en_core_web_sm")
|
10 |
+
_MODEL = {}
|
11 |
+
_CACHE_DIR = os.environ.get("CACHE_DIR", None)
|
12 |
|
13 |
def accept_mail(email_content):
|
14 |
email = parse_from_string(email_content)
|
|
|
37 |
# entities.append((ent.text, ent.label_))
|
38 |
# return entities
|
39 |
|
40 |
+
def get_model(model_name: str = None):
|
41 |
+
if model_name is None:
|
42 |
+
model_name = "urchade/gliner_base"
|
43 |
+
|
44 |
+
global _MODEL
|
45 |
+
|
46 |
+
if _MODEL.get(model_name) is None:
|
47 |
+
_MODEL[model_name] = GLiNER.from_pretrained(model_name, cache_dir=_CACHE_DIR)
|
48 |
+
|
49 |
+
return _MODEL[model_name]
|
50 |
+
|
51 |
def present(email_content, labels):
|
52 |
email = accept_mail(email_content)
|
53 |
cleaned_text = clean_email(email)
|
requirements.txt
CHANGED
@@ -2,5 +2,5 @@ gliner
|
|
2 |
mail-parser
|
3 |
gradio
|
4 |
beautifulsoup4
|
5 |
-
spacy>=3.
|
6 |
https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.0.0/en_core_web_sm-3.0.0.tar.gz
|
|
|
2 |
mail-parser
|
3 |
gradio
|
4 |
beautifulsoup4
|
5 |
+
spacy>=3.1.3
|
6 |
https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.0.0/en_core_web_sm-3.0.0.tar.gz
|
spaces.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
# spaces.yml
|
2 |
pip:
|
3 |
-
- spacy
|
4 |
-
- https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.
|
|
|
1 |
# spaces.yml
|
2 |
pip:
|
3 |
+
- spacy==3.1.3
|
4 |
+
- https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.1.0/en_core_web_sm-3.1.0.tar.gz
|