Giter Site home page Giter Site logo

negspacy pairing example about negspacy HOT 3 CLOSED

jenojp avatar jenojp commented on May 19, 2024
negspacy pairing example

from negspacy.

Comments (3)

jenojp avatar jenojp commented on May 19, 2024 2

No problem! So I'm not sure how familiar you are with the inner workings of spacy but it has a really nicely designed way of processing text as a pipeline. If you're newer to spacy, I 100% recommend the course by @ines as it does a wonderful job of explaining this. So in this case, negspacy is a custom pipeline component that adds an extension to spans. (Entities in spacy are treated as spans).

What I meant in the README was that you can use the scispacy language model and their UMLS entitylinker in conjunction with negspacy to find specific UMLS concepts that are or are not negated.

For example:

import spacy
import scispacy
from negspacy.negation import Negex
from scispacy.umls_linking import UmlsEntityLinker

nlp = spacy.load("en_core_sci_sm")
linker = UmlsEntityLinker()
#this can take a while the first time
nlp.add_pipe(linker)

negex = Negex(nlp, chunk_prefix = ["no"])
nlp.add_pipe(negex, last=True)

Then if you process a doc, you could access two new custom extensions ._.negex and ._.umls_ents

doc = nlp("Patient denies cardiovascular disease but has headaches. No history of smoking. Alcoholism unlikely. Smoking not ruled out.")

for e in doc.ents:
    print(e.text, e._.negex, e._.umls_ents)

There are many different spacy pipeline components here

from negspacy.

kaushikacharya avatar kaushikacharya commented on May 19, 2024 2
from scispacy.umls_linking import UmlsEntityLinker

As per the current release of scispacy, it should be

from scispacy.linking import EntityLinker

And

linker = UmlsEntityLinker()

should be

linker = EntityLinker(resolve_abbreviations=True, name="umls")

from negspacy.

aficionadoai avatar aficionadoai commented on May 19, 2024 1

Thank you very much @jenojp

from negspacy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.