Type Reassignment Rules

Type Reassignment Rules (TRRs) aim to transform a sequence of types, macros, and/or tokens into a new concept with a specific type. Specifically, they're used in Opinions templates to catch opinions with a change in polarity. For example, in the phrase "not that bad," the word "bad" is a negative opinion. But in this context, the real meaning is "not bad" – which is a positive.

Up until version 18.2, this change in polarity was managed by specific Text Link Analysis (TLA) rules:
Figure 1. TLA rules
TLA rules
Because of the different opinion types (Positive, PositiveAttitude, PositiveBudget, PositiveCompetence, PositiveFeeling, PositiveFunctioning, PositiveRecommendation, Negative, NegativeAttitude, NegativeBudget, NegativeCompetence, NegativeFeeling, NegativeFunctioning, NegativeRecommendation, and Contextual), it involved writing specific TLA rules:
  • For each type. For example:
    "not + xxx + <NegativeBudget>" => "<PositiveBudget>"
    or
    "not + xxx + <PositiveAttitude>" => "<NegativeAttitude>"
  • For many syntactic contexts. For example:
    * topic + negation + opinion (“hotel wasn’t good”)
    * negation + opinion + topic (“it was not a good hotel”)
    * negation + opinion (“not very good”)
    * topic + opinion + negation + opinion (“hotel was well-located but  not that good”)
    * 2 topics + negation + opinion (“room and swimming pool weren’t always clean”)
    * …
    

Beginning with version 18.2, the new approach is to "catch" such sequences (any negation + any empty word + a specific opinion), select the words to appear in the new concept (a standardized negation – for instance, "not" – and the opinion), and define a type for this new concept (aka, "pseudo-term"). This new concept can then be used in TLA rules.

As a consequence, the following rule will match any sequence containing a topic followed by an opinion, whether the opinion is a term (comfortable) or a psuedo-term (not economical), regardless of specific opinion sub-type (Attitude, Budget, etc).
#@# Bed was extremely comfortable
[pattern(190)]
name=topic + opinion_190
value=$mTopic ($mEmpty|$mToo){0,3} ($mOpinionPos|$mOpinionNeg|$Contextual)
output(1)=$1\t#1\t$3\t#3

Along with changing polarity for opinions, you can also use TRRs to help fine-tune your dictionary. For example, let's suppose you have a type called Anatomy with body parts such as heart, chest, breast, and adrenal gland – and another type called MedicalProcedures with procedures such as biopsy, needle biopsy, MRI, and CT scan. It would be nearly impossible to list all the medical procedures correctly associated with an organ. So you could create two TRRs to identify potential medical procedures as seen in the following figures. Then once extraction is performed, you can add a filter on the type PotentialMedicalProcedures, review the candidate terms, and then add them to the MedicalProcedures type.

Figure 2. TRR for anatomy + medical procedures
Example TRR
Figure 3. TRR for medical procedures + anatomy
Example TRR

Syntax

#@# not that expensive
[typeReassignmentRule]
name=TRR_"not" NegativeBudget
value=$mAllNeg ($mAdverb|$mBe|$mHave|$mSupport|$mDet|that|more|$mQuant){0,3} $NegativeBudget
output=not $3\tPositiveBudget
  • "name" must be unique (TRR_"not" NegativeBudget). It can't be used in a macro or in a TLA rule. Only the type defined in the output can be used.
  • "value" is a sequence of elements to match. The elements can be types ($NegativeBudget), macros ($mAllNeg) or tokens (more). Some elements can be required, optional, or have a specific quantity.
  • "output" is a SINGLE pair of concept+type (not $3\tPositiveBudget). Note that in the output you can use an available type (one that is defined in the template) or you can create a new type.
    The output type can also reference a matched element (for example, #2). This feature is especially useful when there is no change in type between the value and the output. For example:
    #@# could not have been any more pleased
    [typeReassignmentRule]
    name=TRR_"couldn't be more" opinion
    value=$mNotNeg ($mOpinionPos|$mOpinionNeg|$Contextual)
    output=$2\t#2
    

As in TLA rules, a more specific TRR must be defined before a more generic one. To ensure all TRRs are defined in the correct order, you can use the Get Tokens feature to test each TRR in sequence. If a TRR doesn't match, but matches another definition, you can move it down (or up).

Special cases

In some cases, it is necessary to still have access to the individual elements of the sequence and not to a TRR. This typically concerns coordination over negation. In the phrase "not that fashionable or eyecatching," the coordination “or" doesn't allow for discovering that, in this context, "eyecatching" actually means "not eyecatching."

In this case, we recommend using a specific rule such as:
#@# not that fashionable or eyecatching
[pattern(263)]
name="not" + 2 Positive_263
value=($mAdvNeg|$mSupportNeg|$mMiscNeg) @{0,1} $PositiveFeeling or $PositiveFeeling
output(1)=not $3\tNegativeFeeling
output(2)=not $5\tNegativeFeeling

Although the first part of the rule (($mAdvNeg|$mSupportNeg|$mMiscNeg) @{0,1} $PositiveFeeling) may match a TRR, the TLA rule will have priority.

If you write a more generic rule such as the following example, the same restrictions that existed in version 18.1.1 and prior will still apply. The new concept created (pseudo-concept) may have an incorrect type (<Negative> instead of <NegativeFeeling>), and you may end up with a TLA concept with two different types. A workaround is to create the corresponding term (not xxx) with the correct type.
#@# not that fashionable or eyecatching
[pattern(263)]
name="not" + 2 Positive_263
value=($mAdvNeg|$mSupportNeg|$mMiscNeg) @{0,1} $mPos or $mPos
output(1)=not $3\tNegative
output(2)=not $5\tNegative

Advantages

  • The main advantage of using TRRs is to have less TLA rules.
  • A less obvious advantage is that TRRs ensure that a pseudo-term will mostly result in the correct type (but keep in mind the restriction mentioned previously). In the past, some “not + positiveXXX” were typed as Negative instead of NegativeXXX, because some specific TLA rules were missing.
  • If a user adds a specific opinion type (for example, NegativeNoise), there is no need to replicate specific TLA rules to invert polarity. The user just needs to create the relevant TRR.