# Pattern-based recognition using negation detection

**URL:** https://support.prodi.gy/t/pattern-based-recognition-using-negation-detection/1207
**Category:** Uncategorized
**Tags:** usage, spacy
**Created:** [February 10, 2019, 10:47pm UTC](https://support.prodi.gy/t/pattern-based-recognition-using-negation-detection/1207 "2019-02-10T22:47:31Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)
#### Post date: [February 19, 2019, 12:48pm UTC](https://support.prodi.gy/t/pattern-based-recognition-using-negation-detection/1207/4 "2019-02-19T12:48:05Z")

</div>

> [@xraycat123](#):
>
> “The patient has infarct but no ventricular abnormalities” There are two disorders but one is confirmed, and the other one is negated in one sentence. Any good advice? 🙂

Maybe you could experiment with detecting disorders first, and then use the syntax to resolve the diagnosis type? For example, with a combination of statistical NER and a dictionary, you could probably build a decent system to detect "infarct" and "ventricular abnormalities". You can then write rules that take advantage of the dependency parse and how the disorders and similar entities are connected to the rest of the sentence to determine whether it's negated, uncertain and so on.

It might sound trivial, but depending on your data, you might be able to resolve a large number of "negated diagnosis" relationships by simply looking at the previous token and whether it's "no". You might also be able to determine other grammatical constructs that are very strong indicators of certain types of diagnoses. Even out-of-the-box, you should get a pretty decent accuracy for part-of-speech tags and syntactic dependencies – and if not, you can use Prodigy to tweak the model on your data and improve the results of your rules. You could also combine this with your existing text classifier – maybe it turns out that it's pretty good for some cases, so you can rely on it for the very high confidence predictions and handle the rest by your other system.

[See here](https://spacy.io/usage/linguistic-features#section-dependency-parse) for more details how to extract dependency relationships with spaCy and [this page](https://spacy.io/usage/linguistic-features#section-rule-based-matching) for how to write token-based match patterns to extract certain information. Also, here are some threads that discuss similar problems and approaches:

> [@Extracting current and prior company affiliations from bios](https://support.prodi.gy/t/extracting-current-and-prior-company-affiliations-from-bios/1176/2):
>
> Hi! First, if you haven't seen it yet, you might find @honnibal's talk on this topic helpful. It discusses strategies for breaking a larger NLP problem down into smaller tasks and designing label schemes, which all sounds very relevant to you. If you're trying to predict categories like PRIOR\_COMPANY and CURRENT\_COMPANY, you might actually run into a similar problem as the "crime location" and "victim" example in the video: Whether "ACME Corp" is a prior company or current compa…

> [@Fact extraction for earnings news](https://support.prodi.gy/t/fact-extraction-for-earnings-news/1023/2):
>
> Hi and welcome! smiley This is an interesting project and definitely sounds like something that can be solved by NLP. Large-scale information extraction (including things like “populate a database from free-form text”) is a use case where NLP really shines and something that is already working very well across research and production. I think what it really comes down to is breaking the larger, abstract goal down into smaller machine learning tasks, and finding out what works best for each in…

---

_[View the full topic](https://support.prodi.gy/t/pattern-based-recognition-using-negation-detection/1207)._
