Defining and Testing Annotation Rules

Annotation rules allow you to highlight a portion of text. With these annotations, you can capture all the concepts that can be interesting for your text analysis. You can then test them to check their relevancy in your corpus.

This task shows you how to:

Example: the following annotation rules allow you to annotate all occurrences related to a positive feeling in your corpus.



Define Annotations

You can edit and enter annotations directly from the concept details or use the search bar to find terms to annotate your documents.

  1. In the search field in the right panel, enter the term used to annotate your document.

    By default, the query is case (and accent) insensitive. See Use Annotation Query Language below for more details.

  2. Click + to create a concept with this rule.
    The term is displayed in the field Name the concept.
  3. Click .

Test Annotations Rules

You can test your annotation rules to check their relevancy in your corpus.

  1. Go to the list of concepts.
  2. Select the concept containing the annotation rules that you want to test.
    The terms matching your annotation rules are displayed in bold in your corpus on the right part of the module.
  3. Click Terms.
  4. Select the Queried display.
    You can check that the list of queried terms matches the results expected with your annotation rules.

Use Annotation Query Language

The table below displays advanced query syntax that you can use when creating annotation rules. You can combine the operators described below.

Query Description Examples of results and annotation
price

default:price

Search for a word without taking case and accents into account Price

PRICE

text:PRICE Search for a word exactly as it is, capital letters and accents included PRICE

lemma:price

:price

Search for a word and its grammatically correct variants: declined, conjugated, inflected... (inflected forms). The search word must exist and be in its base form (form you can find in the dictionary). If the word is both a noun and a verb (several parts of speech), the search returns the declined and conjugated forms.

price

priced

prices

pricing

auto_ Search for a word and its variants from the same root

automatic

automatically

price~1

Search for a word and variants obtained by removing/adding/modifying a certain number of characters (Levenshtein distance)

Important: Maximum distance is 2. Do not use on short words.

price

priced

pricey

prime

pricy

pos:ADJ

Search by part of speech: verbs (VERB), common nouns (NOUN), proper nouns (PROPN), adjectives (ADJ), adverbs (ADV), determinant (DET), etc.

:price AND pos:NOUN Same result as the previous row, but allows you to choose between verb (VERB), noun (NOUN), adjective (ADJ), and adverb (ADV)

price

prices

pos:ADJ NOT little Finds everything that corresponds to what is before the NOT but does not match what is after the NOT. All adjectives except little
token:word Search by token type: word (terms), price, acronym, email (email addresses), percent (percentage), ordinal, number, punctuation (punctuation marks), abbreviation, hashtag, mention, etc.
price%20 The word price represents at least 20% of the text.

price happy

(price happy)

Search for multiple words, in any order, separated by 5 words maximum

price and I'm happy

happy with price

[price happy] Search for multiple words, in the order in which they appear, separated by 5 words maximum

price and I'm happy

price. I was very happy

price +happy

(price +happy)

Search for a word if it is close to another word, separated by 5 words maximum

price and I am happy

happy with price

[price +happy] Search for a word followed by another word, separated by 5 words maximum

price and I am happy

price. I was very happy

price -happy Search for a word, provided that another word is not present within 5 words deviation from its neighborhood I would buy it if the price dropped enough to make it worth while
(price happy)^3 Search for multiple words, in any order, separated by 3 words maximum.

happy with the price

price. Very happy

[price happy]^3 Search for multiple words in the order in which they appear, separated by 3 words maximum.

price. Very happy

price, I'm happy

"price happy"

[price happy]^0

Search for multiple words in the order in which they appear, one after the other

price happy

Price happy

French AND fry

Return a term that would be both French and fry, which is impossible

Use French fries if you want results containing French and fry within 5 words of one another.

French NOT fry

Return the word French when it is not the word fry

Use French -fry if you want the word French when it is within fry.

/[0-9]+/

Regular expression search. Works on individual words and not groups of words.

Use local grammar {} if you want to use regular expressions on groups of words (see examples below)

Important: Avoid regular expressions like /.*/ or /.+/. Use the "token" field instead.

{my . grammar} Find any word between my and grammar

my great grammar

my pretty grammar

{my great? grammar} Make a word or group of words optional

my great grammar

my grammar

{my very+ long grammar} Search for a word or group of words appearing one or more times (maximum is 4 times)

my very long grammar

my very very long grammar

{my very* long grammar} Search for a word or group of words appearing zero, one or more times (maximum is 4 times)

my long grammar

my very long grammar

my very very long grammar

{my very{2} long grammar} Search for a word or group of words appearing n times my very very long grammar

Use Tokenization

Tokenization is a key step in lexical pre-processing performed by Text Intelligence Studio. It involves converting a string (a sequence of characters) into a list of analyzable units known as tokens.

In the Annotate module, you can query various token types using the prefix token: followed by the specific token name you want to target.

Example: I want to find all elements considered as numbers by the system, I run the following query: token:number.



  1. To access the list of elements in a document and the tokens linked to them, click close to the document in your corpus.



    The Document Details dialog box opens. It displays metas and annotations.
  2. In the Annotations tab, select token and inline to display all tokens related to the document.

    Example:



Here is the list of all available tokens depending on the different analysis engines and languages:
Token name Description Available for languages
abbreviation

Finds a finite list of abbreviations specific to the language.

Examples: M. , Adj., Capt.

en, fr, ca, de, es, hu, it, nb, nl, nn, pl, pt, ro, ru, sv, uk, vi
acronym

Search for an element composed of at least 2 letters, each letter followed by the character "." (case insensitive)

Examples: i.e., A.k.a., A.W.E.S.O.M.

en, fr, ar, ca, de, es, hi, hu, it, nb, nl, nn, pl, pt, ro, ru, sv, uk, vi
allcaps

Search for a sequence of alphabetical characters in capital letters.

Examples: THANKS, LOVELY

en, fr, ar, ca, de, es, hu, it, nb, nl, nn, pl, pt, ru, sv, uk, vi
any Search for any textual unit. Available to all languages
email

Search for alphabetical and numeric characters followed by @, followed by alphabetical and numeric characters, followed by a "." and alphabetical characters.

Examples: john.doe@gmail.com, fa605428@skynet.be

en, fr, ar, ca, de, es, hi, hu, it, nb, nl, nn, pl, pt, ro, ru, sv, uk, vi
first

Search for the first token of the text

Example: hello AND token:first

Available to all languages
firstcap

Search for a sequence of alphabetical characters beginning with a capital letter and followed by lower-case letters.

Examples: Thanks, Lovely

en, fr, ar, ca, de, es, hu, it, nb, nl, nn, pl, pt, ru, sv, uk, vi
hashtag

Search for a sequence of characters preceded by a @.

Example: @Julie
en, fr, de, es, it, ro
last

Search for the last token of the text

Example: goodbye and token:last

Available to all languages
nonlatin

Search for characters not part of the Latin alphabet.

Examples: µ, 木

en, fr, ca, de, es, hu, it, nb, nl, nn, pl, pt, sv, vi
number

Search for the following:

  • A sequence of numeric characters
  • A decimal number separated by "." or ","
  • A "+" or "-" followed by a series of numeric characters

Examples: 1000, 1.60 , +15, -30

en, fr, ar, ca, de, es, hi, hu, it, nb, nl, nn, pl, pt, ro, ru, sv, uk, vi
ordinal

A sequence of numeric characters (decimal accepted with "." or ",") and followed by the appropriate alphabetical abbreviation (case insensitive)

Examples: 1er, 200ème, 1st, 2nd, 9th

en, fr, ar, ca, de, es, hi, hu, it, nb, nl, nn, pl, pt, ro, ru, sv, uk, vi
other Search for spaces and non breaking spaces en, fr, ar, ca, de, es, hi, hu, it, nb, nl, nn, pl, pt, ro, ru, sv, uk, vi
percent

Search for the character %

To look for percentage with number, use the following query [token:number token:percent]^0

en, fr, ar, ca, de, es, hi, hu, it, nb, nl, nn, pl, pt, ro, ru, sv, uk, vi
phoneNumber

Search for a sequence of numeric characters starting with:

  • "0" followed by a numeric character
  • "+3" followed by 2 numeric characters

which are then followed by 4 strings of 2 numeric characters separated or not by spaces, hyphens or periods.

Examples: 06.09.17.70.11, 0603444752

fr
postCode

Search for a sequence of 5 numeric characters.

Example: 75008

en, fr, ar, ca, de, es, hu, it, nb, nn, ru, sv, uk, vi
price

Search for a sequence of numeric characters separated or not by ".", "," or " ", preceded or followed by a currency symbol.

Examples: 204€, 27,88€, $1000

en, fr, ar, ca, de, es, hi, hu, it, nb, nl, nn, pl, pt, ro, ru, sv, uk, vi
punct

Search for the following elements:

  • 1 character representing a punctuation mark
  • 1 or more ".", "!", "?" ,or " ' " in a row

Examples: § , : , !!! , ..?!

en, fr, ar, ca, de, es, hi, hu, it, nb, nl, nn, pl, pt, ro, ru, sv, uk, vi
uri Example: https://media.tenor.com/xBZrhJ9NeYoAAAAM/happy-too-happy.gif en, fr, ar, can, de, es, hi, hu, it, nb, nl, nn, pl, pt, ro, ru, sv, uk, vi
word

Search for a sequence of alphabetical characters (case insensitive).

Examples: Hello, qualitÃ

en, fr, ar, ca, de, es, hi, hu, it, nb, nl, nn, pl, pt, ro, ru, sv, uk, vi
0, 1, 2...

A number is associated with each token in the order of appearance in the document (count starts at 0)

Example: token:2 displays purchased as result



Available in all languages