MQL Cheat Sheet

Preamble

For topographic queries, you must prefix the query with this magic incantation:

SELECT ALL OBJECTS
WHERE
// Your query here.

Variations over this exist:

SELECT ALL OBJECTS
IN MyMonadSet
WHERE
// Query here, will only find objects
// in the stored monad set "MyMonadSet"

SELECT ALL OBJECTS
IN {1-23400}
WHERE
// Query here, will only find objects
// within the monads {1-23400}.

Overview

The basics

Object blocks, Sequence, Embedding

Construction Meaning Example
[ObjectType]
Objects:
Finds object of type ObjectType
[Word]
[A]
[B]
Adjacency:
Finds objects of type A that are adjacent to objects of type B. However, if there is a gap in the context, that gap will be ignored and objects on either side of the gap will be "adjacent"
[Word]
[Phrase]
[A]!
[B]
Strict adjacency:
Finds objects of type A that are _really_ adjacent to objects of type B. No gaps allowed.
[Word]![Word]
[A
  [B]
]
Embedding:
Finds objects of type A inside which there is an embedded object of type B.
[Phrase
  [Word]
]

Arbitrary space

Construction Meaning Example
[A
  [B]
  ..
  [C]
]
Arbitrary space:
Finds objects of type A, inside of which ther are two objects, one of type B and one of type C, and they need not be adjacent (though they can be).
[Clause
  [Phrase]
  ..
  [Phrase]
]
[A
  [B]
  .. <= 5
  [C]
]
Arbitrary space with restriction:
Finds objects of type A, inside of which ther are two objects, one of type B and one of type C, and they need not be adjacent (though they can be), and there may be up to 5 monads between them.
[Clause
  [Phrase]
  .. <= 20
  [Phrase]
]
[A
  [B]
  .. < 6
  [C]
]
Arbitrary space with restriction:
Finds objects of type A, inside of which ther are two objects, one of type B and one of type C, and they need not be adjacent (though they can be), and there may be up to 5 monads between them.
[Clause
  [Phrase]
  .. < 21
  [Phrase]
]
[A
  [B]
  .. BETWEEN 3 AND 6
  [C]
]
Arbitrary space with restriction:
Finds objects of type A, inside of which ther are two objects, one of type B and one of type C, and they need not be adjacent (though they can be), and there must be at least 3 and at most 6 monads between them.
[Clause
  [Word]
  .. BETWEEN 2 AND 5
  [Word]
]

Feature-restrictions

Basic feature-restrictions

Construction Meaning Example
[A myfeature = val]
Feature-equality: A's feature "myfeature" must have value "val".
Other comparison-operators include:
  • "<>": inequality (different from)
  • "<": less than
  • ">": greather than
  • "<=": less than or equal to
  • ">=": greater than or equal to
[Word lemma="see"]
[A myfeature 
   IN (value-list)]
Value-list:
A.myfeature must be an enumeration, and value-list must be a comma-separated list of enumeration constants in parentheses. The meaning is as if an OR had been placed between individual equality (=) comparisons between the feature and the members of the list.
[Word pos IN 
     (article,noun,
      conjunction,
      adjective)]
[A myfeature 
      ~ "regex"]
Regular expression:
A.myfeature is matched via the regular expression "regex". The regular expressions are compatible with Perl 5. Can only be used with string-features.
[Word lemma 
       ~ "A(b|a|e)*"]
[A myfeature 
       !~ "regex"]
Negated regular expression: Matches those objects for which the feature in question does NOT match the regular expression. Can only be used with string-features.
[Word surface 
       !~ "se(a|e)"]

Boolean combinations of feature-restrictions

[A feature1 = value1 
  AND 
  feature2 = value2
]
Conjunction:
Both feature-comparisons must be true at the same time for the object to match.
[Word lemma="see" 
   AND tense=past]
[A feature1 = value1
 OR feature2 = value2
]
Disjunction:
If either of the feature-comparisons evaluates to true, then the object matches.
[Phrase 
   phrase_type = NP 
   OR phrase_type=PP
]
[A NOT 
 feature1 = value1]
Negation:
The feature-comparison must not be true.
[Word NOT pos=verb]
[A (feature1 = value1
   OR 
  feature2 = value2)
   AND 
  feature3 = value3)
Grouping:
Parentheses can be used to group feature-comparisons.
[Phrase 
    phrase_type = VP 
AND
 (function = Predicate
 OR 
 function = PredCmpl)
]

First/last

An object can be first, last, or first and last in its context.

Construction Meaning Example
[B
  [A first]
]
The A object must be first in the context of the B object.
[Phrase
   [Word first]
   [Word]
]
[B
  [A last]
]
The A object must be last in the context of the B object.
[Phrase
   [Word]
   ..
   [Word last]
]
[B
  [A first and last]
]
The A object must be both first and last in the context of the B object.
[Phrase
   [Word first 
         and last]
]

Object references

You can give an object a name with the "AS" keyword and then refer to that object later in the query with the "dot notation".

Construction Meaning Example
[A AS a1
  [B feature_on_B = 
     a1.feature_on_A]
]
B's feature_on_B feature must be the same as the feature_on_A feature on the A object.
[Phrase AS p1
  // The phrase must
  // be the immediate
  // ancestor of the
  // word
  [Word parent = 
        p1.self]
]

NOTEXIST and Kleene Star

The NOTEXIST keyword tells that an object must not exist at a given point.

The Kleene-Star tells that an object must occur either 0, 1, or more times.

The Kleene-Star with a set of integers tucked behind tells the exact number of times the object may occur.

Currently, the Kleene Star cannot be used on the first object in a context, or the first object after a "..".

Construction Meaning Example
[A NOTEXIST [B]]
There must not exist a B inside of A.
[Sentence
   NOTEXIST [Word 
       surface="saw"]
]
[A
  [B]
  [C]*
]
Inside of A, there must be a B, followed by zero or more C's.
[Phrase
  [Word first 
     pos=preposition]
  [Word pos IN 
      (article,noun,
       conjunction)]*
]
[A
  [B]
  [C]*{0,1}
]
Inside of A, there must occur a B object, followed by either 0 or 1 C objects. Note how this makes the C object optional.
[Clause
  [word 
    pos="conjunction"]
  [word 
    pos="conjunction"
  ]*{0,1}
]

Previous:Query Guide
Up:Query Guide
Next:none