Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ import pymongo
|
|
7 |
import torch
|
8 |
import spacy
|
9 |
from spacy import displacy
|
10 |
-
from pymongo import MongoClient
|
11 |
|
12 |
from transformers import AutoTokenizer
|
13 |
tokenizer = AutoTokenizer.from_pretrained("law-ai/InLegalBERT")
|
@@ -248,30 +248,30 @@ def judgtext_analysis(text):
|
|
248 |
doc.ents = ents
|
249 |
|
250 |
#logic for repository
|
251 |
-
cluster = MongoClient("mongodb+srv://testuser:test123@ner-gradio.mgng1wv.mongodb.net/?retryWrites=true&w=majority")
|
252 |
-
db = cluster["nerdb"]
|
253 |
-
collection = db["named_entities"]
|
254 |
-
|
255 |
-
extsoup = bs(content, 'html.parser')
|
256 |
-
|
257 |
-
txtlist=[]
|
258 |
-
entlist=[]
|
259 |
-
for h in extsoup.findAll('div'):
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
zipped = zip(txtlist, entlist)
|
271 |
-
ziplist = list(zipped)
|
272 |
-
|
273 |
-
post = {"api_docid":docid, "document_text":finaltext, "named_entities":ziplist, "entities_indices": finalentities}
|
274 |
-
collection.insert_one(post)
|
275 |
|
276 |
html = displacy.render(doc, style="ent", page = True)
|
277 |
html = (
|
|
|
7 |
import torch
|
8 |
import spacy
|
9 |
from spacy import displacy
|
10 |
+
# from pymongo import MongoClient
|
11 |
|
12 |
from transformers import AutoTokenizer
|
13 |
tokenizer = AutoTokenizer.from_pretrained("law-ai/InLegalBERT")
|
|
|
248 |
doc.ents = ents
|
249 |
|
250 |
#logic for repository
|
251 |
+
# cluster = MongoClient("mongodb+srv://testuser:test123@ner-gradio.mgng1wv.mongodb.net/?retryWrites=true&w=majority")
|
252 |
+
# db = cluster["nerdb"]
|
253 |
+
# collection = db["named_entities"]
|
254 |
+
content = displacy.render(doc, style='ent')
|
255 |
+
# extsoup = bs(content, 'html.parser')
|
256 |
+
|
257 |
+
# txtlist=[]
|
258 |
+
# entlist=[]
|
259 |
+
# for h in extsoup.findAll('div'):
|
260 |
+
# mark = h.findAll('mark')
|
261 |
+
# span = h.findAll('span')
|
262 |
+
# for i in mark:
|
263 |
+
# txt = i.find(text=True)
|
264 |
+
# txt = txt.replace("\n","");
|
265 |
+
# txt = txt.strip();
|
266 |
+
# txtlist.append(str(txt))
|
267 |
+
# for i in span:
|
268 |
+
# ent = i.find(text=True)
|
269 |
+
# entlist.append(str(ent))
|
270 |
+
# zipped = zip(txtlist, entlist)
|
271 |
+
# ziplist = list(zipped)
|
272 |
+
|
273 |
+
# post = {"api_docid":docid, "document_text":finaltext, "named_entities":ziplist, "entities_indices": finalentities}
|
274 |
+
# collection.insert_one(post)
|
275 |
|
276 |
html = displacy.render(doc, style="ent", page = True)
|
277 |
html = (
|