Skip to content

AND operator

AND is the Boolean operator that combines attributes, two at a time, to create Boolean expressions that will be true, only if both the operands are true.

Syntax is:

operand1
AND
operand2
...

where:

  • AND must be written in uppercase.
  • operand# may refer to a simple attribute, to a set combination of attributes or to a sequence of attributes (positional or logical).

Consider the following example:

SCOPE SENTENCE
{
    DOMAIN(dom1:NORMAL)
    {
        LEMMA("abandon")
        AND
        LEMMA("oil well")
    }
}

The rule's condition is the combination of two LEMMA attributes. It will match the portion of input text delimited by rule's scope, if it contains at least a token having its lemma attribute set to abandon and at least another token with its lemma attribute set to oil well.

Consider this text:

Improperly abandoned oil wells, improperly abandoned facilities, and abandoned oil sumps are all potential sources of safety hazards. Prior to current abandonment procedures, oil wells were cut off below ground and capped. However, this procedure may not comply with the current abandonment standards.

The first sentence contains:

abandoned = lemma "abandon", three times
oil wells = lemma "oil well", one time

so it matches the rule's condition three times, the first time because of the first abandoned and the only oil wells, the second time because of the second abandoned and the only oil wells and the third time because of the third abandoned and the only oil wells.
This means that the rule is triggered three times, the rule's action is performed three times and a NORMAL quantity of points (e.g., 60) is added to dom1 domain's cumulative score three times.

Combined attributes can have more than one value. Compare the first sample rule with the following:

SCOPE SENTENCE
{
    DOMAIN(dom1:NORMAL)
    {
        LEMMA("abandon", "abandoned", "abandonment", "leave", "desert", "decommission", "decommissioning", "closure")
        AND
        LEMMA ("oil well")
    }
}

When run against the same sample text, the rule is triggered four times, because the second sentence contains both abandonment AND oil wells.

If the rule's scope is broader, as in:

SCOPE SECTION (BODY)
{
    DOMAIN(dom1:NORMAL)
    {
        LEMMA("abandon", "abandoned", "abandonment", "leave", "desert", "decommission", "decommissioning", "closure")
        AND
        LEMMA ("oil well")
    }
}

the co-occurrence of attributes can happen across sentence boundaries. Since the sample text matches the first attribute five times and the second attribute twice, the rule now triggers ten times.

In the following rule:

SCOPE SENTENCE
{
    DOMAIN(dom1:NORMAL)
    {
        KEYWORD("uncased") >> LEMMA("well")  
        AND
        ANCESTOR(13769) // 13769: bore-hole, bore, borehole, drill hole
    }
}

AND is used to combine a strict positional sequence with the concepts that descend from an "ancestor" concept.

If run against the following sample text:

Temperature Distribution Around an Uncased Well with a History of Variations in Wellbore Temperature

the condition is met because the Well disambiguation matches the ANCESTOR attribute.

The extraction rule below shows the AND operator used to combine operands that are sets of combinations of attributes.

SCOPE PHRASE (NP)
{
    IDENTIFY(TEST)
    {
        @Well[LEMMA("well") + TYPE(NOU)]
        AND
        @Depth[ANCESTOR(58535) + SYNCON(UNKNOWN)] // linear measure, linear unit, long measure
    }
}

The first operand will match the lemma well, only if it's a noun (well is also an adverb, a verb and even an adjective), the second operand will match any type of linear measure, only if it is an unknown entity, that is an entity which is not inside the Knowledge Graph, but was assigned a virtual supernomen by the disambiguator.
The condition must be met in the scope of a noun phrase. If the rule above is run against the following text:

Repsol, in partnership with CGX, Tullow and YPF, is drilling a 6,500-metre well (21,000-feet) in the Guyana Basin that experts claim could hold 15 billion barrels of oil and 42 trillion cubic feet (1.2 trillion cubic metres) of natural gas.

it is triggered by 6,500-metre (a virtual child of syncon 58808, meter, which in turn is a child of syncon 58535, linear measures) and the noun well, both of which are found within the same noun phrase a 6,500-metre well.
21,000-feet is also a virtual child of syncon 58835 and thus a potentially valid value for the second attribute, but the noun phrase in which it is located does not contain the noun well.