//******
// Copyright LIMSI-CNRS
// Author: Véronique Moriceau
// E-mail : moriceau@limsi.fr
// Date: 2013-05-27
// Governed by the CeCILL license under French law and abiding by the rules of distribution of free software.
// You can use, modify and/or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info/licences/Licence_CeCILL_V1.1-US.txt".
//******
// This file contains rules for the temporal expressions of the type set: setrules
// RULENAME="",EXTRACTION="",NORM_VALUE=""(,OFFSET="")?(,POS_CONSTRAINT="")?(,NORM_MOD="")?(,NORM_QUANT="")?(,NORM_FREQ="")?

////////////////
// EVERY UNIT // 
////////////////

// set_r1
// EXAMPLE r1a-1: chaque jour
RULENAME="set_r1a",EXTRACTION="([Cc]haque|[Tt]ous les) %reUnit",NORM_VALUE="P1%UPPERCASE%(%SUBSTRING%(%normUnit(group(2)),0,1))",NORM_QUANT="EVERY"

// EXAMPLE r1b-1: chaque lundi
RULENAME="set_r1b",EXTRACTION="([Cc]haque|[Tt]ous les) %reWeekday",NORM_VALUE="XXXX-WXX-%normDayInWeek(group(2))",NORM_QUANT="EVERY",NORM_FREQ="1W"

// EXAMPLE r1c-1: chaque été
RULENAME="set_r1c",EXTRACTION="([Cc]haque|[Tt]ous les) %reSeason",NORM_VALUE="XXXX-%normSeason(group(2))",NORM_QUANT="EVERY",NORM_FREQ="1S"



// set_r2
// EXAMPLE r2a-1: une fois par semaine
RULENAME="set_r2a",EXTRACTION="([Uu]ne fois par) %reUnit",NORM_VALUE="P1%UPPERCASE%(%SUBSTRING%(%normUnit(group(2)),0,1))",NORM_FREQ="1"

// EXAMPLE r2b-1: deux fois par mois
RULENAME="set_r2b",EXTRACTION="([Dd]eux fois par) %reUnit",NORM_VALUE="P%UPPERCASE%(%SUBSTRING%(%normUnit(group(2)),0,1))",NORM_FREQ="2"

// EXAMPLE r2c-1: trois fois par mois
RULENAME="set_r2c",EXTRACTION="(%reNumWord1D|%reNumWord2D) fois (par) %reUnit",NORM_VALUE="P1%UPPERCASE%(%SUBSTRING%(%normUnit(group(5)),0,1))",NORM_FREQ="%normDurationNumber(group(1))"

// EXAMPLE r2d-1: 40 fois par mois
RULENAME="set_r2d",EXTRACTION="([\d]+) fois (par) %reUnit",NORM_VALUE="P1%UPPERCASE%(%SUBSTRING%(%normUnit(group(3)),0,1))",NORM_FREQ="group(1)"



// set_r3
// EXAMPLE r3a-1: tous les 5 ans
RULENAME="set_r3a",EXTRACTION="([Tt]ous les) ([\d]+) %reUnit",NORM_VALUE="Pgroup(2)%UPPERCASE%(%SUBSTRING%(%normUnit(group(3)),0,1))",NORM_QUANT="EVERY"

// EXAMPLE r3b-1: tous les cinq ans
RULENAME="set_r3b",EXTRACTION="([Tt]ous les) (%reNumWord1D|%reNumWord2D) %reUnit",NORM_VALUE="P%normDurationNumber(group(2))%UPPERCASE%(%SUBSTRING%(%normUnit(group(5)),0,1))",NORM_QUANT="EVERY"



// set_r4
// EXAMPLE r4a-1: 2 jours par semaine
RULENAME="set_r4a",EXTRACTION="([\d]+) %reUnit (par) %reUnit",NORM_VALUE="P1%UPPERCASE%(%SUBSTRING%(%normUnit(group(4)),0,1))",NORM_QUANT="EACH",NORM_FREQ="group(1)%normUnit(group(2))"



// set_r5 
// EXAMPLE r5a-1: annuellement
RULENAME="set_r5a",EXTRACTION="%reSetWords",NORM_VALUE="%normSetWords(group(1))"



//////////////////////////////
// PART-OF-DAYS EXPRESSIONS //
//////////////////////////////

// set_r6
// EXAMPLE r6a-1: lundi matins
RULENAME="set_r6a",EXTRACTION="%reWeekday %rePartOfDay[s]",NORM_VALUE="XXXX-WXX-%normDayInWeek(group(1))T%normPartOfDay(group(2))",NORM_FREQ="1W"

