// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

[[_ugr.tools.ruta.language.quantifier]]
= Quantifiers



[[_ugr.tools.ruta.language.quantifier.sg]]
== * Star Greedy

The Star Greedy quantifier matches on any amount of annotations and evaluates always true.
Please mind that a rule element with a Star Greedy quantifier needs to match on different annotations as the next rule element.
Examples: 
[source]
----
Input:    small Big Big Big small
Rule:     CW*
Matched:  Big Big Big  
Matched:  Big Big 
Matched:  Big
----

[[_ugr.tools.ruta.language.quantifier.sr]]
== *? Star Reluctant

The Star Reluctant quantifier matches on any amount of annotations and evaluates always true, but stops to match on new annotations, when the next rule element matches and evaluates true on this annotation.
Examples: 

[source]
----
Input:    123 456 small small Big 
Rule:     W*? CW
Matched:  small small Big
Matched:  small Big
Matched:  Big
----

The last match "`Big`" can be problematic using different types  if the rule starts matching with the first rule element. 

[[_ugr.tools.ruta.language.quantifier.pg]]
== + Plus Greedy

The Plus Greedy quantifier needs to match on at least one annotation.
Please mind that a rule element after a rule element with a Plus Greedy quantifier matches and evaluates on different conditions.
Examples: 

[source]
----
Input:    123 456 small small Big 
Rule:     SW+ 
Matched:  small small
Matched:  small
----

[[_ugr.tools.ruta.language.quantifier.pr]]
== +? Plus Reluctant

The Plus Reluctant quantifier has to match on at least one annotation in order to evaluate true, but stops when the next rule element is able to match on this annotation.
Examples: 

[source]
----
Input:    123 456 small small Big 
Rule:     W+? CW
Matched:  small small Big
Matched:  small Big
----

[[_ugr.tools.ruta.language.quantifier.qg]]
== ? Question Greedy

The Question Greedy quantifier matches optionally on an annotation and therefore always evaluates true.
Examples: 

[source]
----
Input:    123 456 small Big small Big 
Rule:     SW CW? SW
Matched:  small Big small
----

[[_ugr.tools.ruta.language.quantifier.qr]]
== ?? Question Reluctant

The Question Reluctant quantifier matches optionally on an annotation, if the next rule element does not match on the same annotation and therefore always evaluates true.
Examples: 

[source]
----
Input:    123 456 small Big small Big 
Rule:     SW CW?? SW
Matched:  small Big small
----

[[_ugr.tools.ruta.language.quantifier.mmg]]
== [x,y] Min Max Greedy

The Min Max Greedy quantifier has to match at least x and at most y annotations of its rule element to evaluate true.
Examples: 

[source]
----
Input:    123 456 small Big small Big 
Rule:     SW CW[1,2] SW
Matched:  small Big small
----

[[_ugr.tools.ruta.language.quantifier.mmr]]
== [x,y]? Min Max Reluctant

The Min Max Greedy quantifier has to match at least x and at most y annotations of its rule element to evaluate true, but stops to match on additional annotations, if the next rule element is able to match on this annotation.
Examples: 

[source]
----
Input:    123 456 small Big Big Big small Big 
Rule:     SW CW[2,100]? SW
Matched:  small Big Big Big small
----