Barring a fact’s context from being returned if it overlaps another context
- Last Updated: August 14, 2026
- 5 minute read
- Semaphore
- Documentation
When returning the entire phrase range that a fact is found in (using “use entire range of context”), we can also stop that result if we have anywhere in it an overlapping fact / anchor also appearing in it.
For example, in the example below, I do not want to return the patient fact or the disease fact if a doctor is mentioned in the same sentence (with “use entire range of context” switched On).
Alan Flett and Dr Mike Smith have Pagets Disease.
When doing this, we have to be clear what we intend.
In this example, we intend to extract the fact of a patient “Alan Flett” and also of his disease “Pagets Disease”. We also intend to extract the whole sentence that those two facts occur in “Alan Flett and Dr Mike Smith have Pagets Disease.”
To do that, we have to use a context that as a sentence constraint - such as “Unsequenced In Sentence(s)” which will look for its facts / anchors in the same sentence. To return the whole sentence those facts are found in, we must switch on the “use entire range of context” property on the context and then also have an “extract fact as” association to a Fact Name on that context.
This will give us this result:

As we can see, we are extracting the three facts.
What we now intend, is to be able to stop these facts coming back, all of them, if our sentence contains a doctor. To do that, we must create a context that looks for doctors in the same range, and then excludes the results, if the extent of the range that holds the doctors is the same as or is larger than the range that contains the facts.
However, there is a subtlety here on both sides of the extraction both the one with the facts and the one with the exclusion. This involves the property “use entire range of context”:

On the side with the facts, if we set “use entire range of context” to be Off, then when it extracts the fact on the sentence context, it is NOT the whole sentence you will get back - but only that parts of it that overlap the facts. See this below:

If we wish for the whole of the containing sentence’s range to be returned, we must switch the property “use entire range of context” to On. We then get this result:

If we wish to stop the facts being returned, then we must have a match or a larger context, than the one being used for the facts. That is, in this case, we must use a “sentence” or “paragraph” with the “use entire range of context” switched On.
If we use one that is smaller - then it will only exclude that part that contains what we don’t what (in this case the doctor). Even if we use one that matches the outside constraint, the sentence in this case, then
For instance, in this case, we have modelled the doctor using a “sequenced phrase(s) in document” context - which, regardless of the “use whole context” will only ever use the phrase range of the fact itself. So, in that case, we actually lose the Dr Mike Smith part and end up with the two remaining parts of the sentence.
If we wish to lose the entire sentence and therefore the facts in it, then we need to match or have a large phrase range and use its whole context.
More tests showing behaviours
In FACTS we can stop a fact from being extracted (returned) if it overlaps some other fact or anchor.
That is, we can essentially have a “blacklist” of anchors / facts that we do not want to return.
This can be very useful as it leads to more simple extractors - write the extractor for the general case and then just stop the edge cases from coming back.
Examples
We are looking for foods in a document. To extract those foods we need them to be in the same paragraph as two anchors “required1” and “required2”. However, we do not want any foods extracted if they occur in another range of text that begins with “required1” and ends with “required2”.
That is, these should return Beer:
Beer. Sentence with required1 and required2.
as we have the fact “Beer” and the two required anchors “required” and “reuired2” in the same paragraph.
This should return Beer:
Beer. Sentence with required1. Another sentence with required2.
as we have the fact “Beer” and the two required anchors “required1” and “required2” in the same paragraph.
This should return Beer:
Another paragraph with required2.
as we have the fact “Beer” and part of the “all” that required the two anchors “required1” and “reuired2” in the same paragraph.
This should return Beer:
Wine. Another paragraph with required2.
as we have the fact “Beer” and “Wine” and part of the “all” that required the two anchors “required1” and “reuired2” in the same paragraph.
This should return Beer:
window start Beer window end. Sentence with required1 and required2.
as we have the fact “Beer” and part of the “all” that required the two anchors “required1” and “reuired2” in the same paragraph - and the overlapping range of text that would stop our anchors from firing are not actually around them, it is aroudn the fact, which will not affect it.
But these should not return:
Next paragraph with required1 and required2.
Next paragraph with required2 and required1.
as we have the fact “Beer” and no part of the “all” that required the two anchors “required1” and “reuired2” in the same paragraph.
Beer. Sentence with required1 only.
as we have the fact “Beer” and only one anchor of the “all” that required the two anchors “required1” and “reuired2” in the same paragraph.
Beer. Sentence with required2 only.
as we have the fact “Beer” and only one anchor of the “all” that required the two anchors “required1” and “reuired2” in the same paragraph.
Beer. Sentence with window start required1 and required2 window end.
as we have the fact “Beer” and the anchors of the “all” that required the two anchors “required1” and “reuired2” both inside the overlapping window which excludes them.
Beer. Sentence with window start required1 window end and required2.
as we have the fact “Beer” and one of the anchors of the “all” that required the two anchors “required1” and “reuired2” inside the overlapping window which excludes it and the “all” rule.
window start Beer. Sentence with required1 window end and required2.
as we have the fact “Beer” and one of the anchors of the “all” that required the two anchors “required1” and “reuired2” inside the overlapping window which excludes it and the “all” rule.