Skip to content

Tag management

Introduction

The DIS object provides a number of methods to manage the tags that the disambiguation identified according to the scope.

There are methods to:

  • Tag
  • Untag
  • Rename tags

The methods to tag are:

  • tagSentence
  • tagPhrase
  • tagToken
  • tagRange

The methods to untag are:

  • untagSentence
  • untagPhrase
  • untagToken

The method to rename tags is renameTag.

Tag and untag

Every method works at the token level and adds or removes a tag to/from all the tokens of a specified text subdivision. Here are some examples.

tagSentence and untagSentence

Use tagSentence and untagSentence to tag and untag entire sentences.

With this statement:

DIS.tagSentence(1, "myTAG");

applied to this text:

This a sentence. This is another sentence.

you will get in the Semantic Analysis tool window:

The method tags all the tokens of the second sentence of the text—that with zero-based index 1—with the myTAG label, while this code:

DIS.untagSentence(1, "myTAG");

removes the myTAG label from all the tokens in the same sentence.

tagPhrase and untagPhrase

Use tagPhrase and untagPhrase to tag and untag phrases of your choice.

If you apply this code:

DIS.tagPhrase(2, "BEERS");

to this text:

I drank a Guinness beer.

you will get in the Semantic Analysis tool window:

The third phrase a Guinness beer—the one with the zero-based index of two—was tagged with the BEERS tag.

With this code:

DIS.untagToken(2, "BEERS");

the tag will be removed.

tagToken

Use tagToken to tag a token of your choice.

If you apply this code:

DIS.tagToken(3, "COLOR");

to this input text:

The sky is blue.

You will get in the Semantic Analysis tool window:

The method tags the fourth token blue—the one with the zero-based index of three— with the COLOR tag.

untagToken

Use untagToken to untag a token and eventually remove a tag made of multiple tokens.

For example, consider this tag:

TAGS
{
    @MYTAG1
}

and this tagging rule:

SCOPE SENTENCE
{
    TAGGER()
    {
        @MYTAG1[KEYWORD("had a good time")]
    }
}

applied to this text:

I went to Sweryth and I had a good time.

You will get in the Semantic Analysis tool window.

This statement:

DIS.untagToken(7, "MYTAG1");

removes the eighth token a—the one with a zero-based index of seven—from the MYTAG1 tag and the latter will be entirely removed.

This is what you see in the Semantic Analysis tool window:

All tag tiles are struck through and the tag in the detail area on the right is highlighted, meaning its removal.

Note

If you untag a token belonging to a multiple-token tag, all tokens are untagged.

tagRange

Use tagRange to tag a range of tokens.

With this statement:

DIS.tagRange(3, 4, "DOG");

and this sentence:

Rex is a German Shepherd.

you will get in the Semantic Analysis tool window:

The tokens German and Shepherd—with a zero-based index of three and four—are tagged with the DOG tag.

Rename tag

Use renameTag to rename a tag. Consider this tag:

TAGS
{
    @SAMPLE_TAG
}

If this tagging rule:

SCOPE SENTENCE 
{
    TAGGER()
    {
        @SAMPLE_TAG[LEMMA("good")]
    }
}

is applied to this text:

Mark is a good boy.

you will get:

With this statement:

DIS.renameTag("SAMPLE_TAG", "NEW_TAG", 3);

you will get:

As you can see, the tag name for the adjective good—with a zero-based index of three—has been changed. In the detail panel on the right, the old tag name is highlighted.

Syntax

Except for tagRange and renameTag, all tagging and untagging methods have this syntax:

DIS.method(subdivisionIndex, tagLabel);

where:

  • method is the tagging or untagging method.
  • subdivisionIndex is the index of the text subdivision to tag.
  • tagLabel is a string—constant or variable—representing the tag label.

The syntax of tagRange is:

DIS.method(subdivisionIndex1, subdivisionIndex2, tagLabel);

where:

  • method is the tagging or untagging method.
  • subdivisionIndex1 is the token index of the first token in the range to tag.
  • subdivisionIndex2 is the token index of the last token in the range to tag.
  • tagLabel is a string—constant or variable—representing the tag label.

The syntax of renameTag is:

DIS.method(oldTagLabel, newTagLabel, subdivisionIndex);

where:

  • method is the tagging or untagging method.
  • oldTagLabel is a string—constant or variable—representing the old tag label.
  • newTagLabel is a string—constant or variable—representing the new tag label.
  • subdivisionIndex is the index of the text subdivision to tag.