I have been using space for quite some-time and I really liked the displacy
Is there a way where we can serve multiple texts from my data-set in the web-page as-in a small arrow to redirect to next record and mark the entities. The code I'm using is as follows.
def validate(VAL_DATA):
nlp = spacy.load(args.model + '/nn')
for text, _ in VAL_DATA:
doc = nlp(text)
displacy.serve(doc, style='ent')
for ent in doc.ents:
print("entity: " + ent.label_ +"\t" + "text: " + ent.text)
VAL_DATA is my validation set and it has multiple records in it.
Thanks in advance.
Not sure if I got your question right, but if you want to mark entities found for mulitple docs you can just do the following:
def validate(VAL_DATA):
nlp = spacy.load(args.model + '/nn')
docs = list(nlp.pipe(VAL_DATA))
entities = [doc.ents for doc in docs]
displacy.serve(docs, style="ent")
At least for me it worked just fine. Might work fo you too?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With