public void evaluateCalculationFunctions(JCas jcas) {

		// build up a list with all found TIMEX expressions
		List<Timex3> linearDates = new ArrayList<Timex3>();
		FSIterator iterTimex = jcas.getAnnotationIndex(Timex3.type).iterator();

		// Create List of all Timexes of types "date" and "time"
		while (iterTimex.hasNext()) {
			Timex3 timex = (Timex3) iterTimex.next();
			if ((timex.getTimexType().equals("DATE")) || (timex.getTimexType().equals("TIME"))) {
				linearDates.add(timex);
			}
		}
		
		
		//////////////////////////////////////////////
		// go through list of Date and Time timexes //
		//////////////////////////////////////////////
		//compile regex pattern for validating commands/arguments
		Pattern cmd_p = Pattern.compile("((\\w\\w\\w\\w)-(\\w\\w)-(\\w\\w))\\s+funcDateCalc\\((\\w+)\\((.+)\\)\\)");
		Pattern year_p = Pattern.compile("(\\d\\d\\d\\d)");
		Pattern date_p = Pattern.compile("(\\d\\d\\d\\d)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])");
		Matcher cmd_m;
		Matcher year_m;
		Matcher date_m;
		String date;
		String year;
		String month;
		String day;
		String function;
		String args[];
		String valueNew;
		
		for (int i = 0; i < linearDates.size(); i++) {
			Timex3 t_i = (Timex3) linearDates.get(i);
			String value_i = t_i.getTimexValue();
			cmd_m = cmd_p.matcher(value_i);
			valueNew = value_i;
		
			if(cmd_m.matches()) {
				date = cmd_m.group(1);
				year = cmd_m.group(2);
				month = cmd_m.group(3);
				day = cmd_m.group(4);
				function = cmd_m.group(5);
				args = cmd_m.group(6).split("\\s*,\\s*");
				
				//replace keywords in function with actual values
				for(int j=0; j<args.length; j++) {
					args[j] = args[j].replace("DATE", date);
					args[j] = args[j].replace("YEAR", year);
					args[j] = args[j].replace("MONTH", month);
					args[j] = args[j].replace("DAY", day);
				}
				
				if(function.equals("EasterSunday")) {
					year_m = year_p.matcher(args[0]);
					//check if args[0] is a valid YEAR value
					if(year_m.matches()) {
						
						//System.err.println("correct format");
						valueNew = this.getEasterSunday(Integer.valueOf(args[0]), Integer.valueOf(args[1]));
					
					}
					else{
						
						Logger.printError("wrong format");
						valueNew = "XXXX-XX-XX";
					
					}
				}
				else if(function.equals("WeekdayRelativeTo")) {
					date_m = date_p.matcher(args[0]);
					//check if args[0] is a valid DATE value
					if(date_m.matches()) {
						
						//System.err.println("correct format");
						valueNew = this.getWeekdayRelativeTo(args[0], Integer.valueOf(args[1]), Integer.valueOf(args[2]), Boolean.parseBoolean(args[3]));
						
					}
					else{

						Logger.printError("wrong format");
						valueNew = "XXXX-XX-XX";
						
					}
				}
				else if(function.equals("EasterSundayOrthodox")) {
					year_m = year_p.matcher(args[0]);
					//check if args[0] is a valid YEAR value
					if(year_m.matches()) {

						//System.err.println("correct format");
						valueNew = this.getEasterSundayOrthodox(Integer.valueOf(args[0]), Integer.valueOf(args[1]));

					}
					else{

						Logger.printError("wrong format");
						valueNew = "XXXX-XX-XX";

					}
				}
				else if(function.equals("ShroveTideOrthodox")) {
					year_m = year_p.matcher(args[0]);
					//check if args[0] is a valid YEAR value
					if(year_m.matches()) {

						//System.err.println("correct format");
						valueNew = this.getShroveTideWeekOrthodox(Integer.valueOf(args[0]));

					}
					else{

						Logger.printError("wrong format");
						valueNew = "XXXX-XX-XX";

					}
				}
				else{
					// if function call doesn't match any supported function
					Logger.printError("command not found");
					valueNew = "XXXX-XX-XX";
				}
			}
						
			t_i.removeFromIndexes();
			t_i.setTimexValue(valueNew);
			t_i.addToIndexes();
			linearDates.set(i, t_i);
		}
	}
public void evaluateCalculationFunctions ( JCas jcas ) { List < Timex3 > linearDates = new ArrayList < Timex3 > ( ) ; FSIterator iterTimex = jcas . getAnnotationIndex ( Timex3 . type ) . iterator ( ) ; while ( iterTimex . hasNext ( ) ) { Timex3 timex = ( Timex3 ) iterTimex . next ( ) ; if ( ( timex . getTimexType ( ) . equals ( "DATE" ) ) || ( timex . getTimexType ( ) . equals ( "TIME" ) ) ) { linearDates . add ( timex ) ; } } Pattern cmd_p = Pattern . compile ( "((\\w\\w\\w\\w)-(\\w\\w)-(\\w\\w))\\s+funcDateCalc\\((\\w+)\\((.+)\\)\\)" ) ; Pattern year_p = Pattern . compile ( "(\\d\\d\\d\\d)" ) ; Pattern date_p = Pattern . compile ( "(\\d\\d\\d\\d)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])" ) ; Matcher cmd_m ; Matcher year_m ; Matcher date_m ; String date ; String year ; String month ; String day ; String function ; String args [ ] ; String valueNew ; for ( int i = 0 ; i < linearDates . size ( ) ; i ++ ) { Timex3 t_i = ( Timex3 ) linearDates . get ( i ) ; String value_i = t_i . getTimexValue ( ) ; cmd_m = cmd_p . matcher ( value_i ) ; valueNew = value_i ; if ( cmd_m . matches ( ) ) { date = cmd_m . group ( 1 ) ; year = cmd_m . group ( 2 ) ; month = cmd_m . group ( 3 ) ; day = cmd_m . group ( 4 ) ; function = cmd_m . group ( 5 ) ; args = cmd_m . group ( 6 ) . split ( "\\s*,\\s*" ) ; for ( int j = 0 ; j < args . length ; j ++ ) { args [ j ] = args [ j ] . replace ( "DATE" , date ) ; args [ j ] = args [ j ] . replace ( "YEAR" , year ) ; args [ j ] = args [ j ] . replace ( "MONTH" , month ) ; args [ j ] = args [ j ] . replace ( "DAY" , day ) ; } if ( function . equals ( "EasterSunday" ) ) { year_m = year_p . matcher ( args [ 0 ] ) ; if ( year_m . matches ( ) ) { valueNew = this . getEasterSunday ( Integer . valueOf ( args [ 0 ] ) , Integer . valueOf ( args [ 1 ] ) ) ; } else { Logger . printError ( "wrong format" ) ; valueNew = "XXXX-XX-XX" ; } } else if ( function . equals ( "WeekdayRelativeTo" ) ) { date_m = date_p . matcher ( args [ 0 ] ) ; if ( date_m . matches ( ) ) { valueNew = this . getWeekdayRelativeTo ( args [ 0 ] , Integer . valueOf ( args [ 1 ] ) , Integer . valueOf ( args [ 2 ] ) , Boolean . parseBoolean ( args [ 3 ] ) ) ; } else { Logger . printError ( "wrong format" ) ; valueNew = "XXXX-XX-XX" ; } } else if ( function . equals ( "EasterSundayOrthodox" ) ) { year_m = year_p . matcher ( args [ 0 ] ) ; if ( year_m . matches ( ) ) { valueNew = this . getEasterSundayOrthodox ( Integer . valueOf ( args [ 0 ] ) , Integer . valueOf ( args [ 1 ] ) ) ; } else { Logger . printError ( "wrong format" ) ; valueNew = "XXXX-XX-XX" ; } } else if ( function . equals ( "ShroveTideOrthodox" ) ) { year_m = year_p . matcher ( args [ 0 ] ) ; if ( year_m . matches ( ) ) { valueNew = this . getShroveTideWeekOrthodox ( Integer . valueOf ( args [ 0 ] ) ) ; } else { Logger . printError ( "wrong format" ) ; valueNew = "XXXX-XX-XX" ; } } else { Logger . printError ( "command not found" ) ; valueNew = "XXXX-XX-XX" ; } } t_i . removeFromIndexes ( ) ; t_i . setTimexValue ( valueNew ) ; t_i . addToIndexes ( ) ; linearDates . set ( i , t_i ) ; } }
This function replaces function calls from the resource files with their TIMEX value.

@author Hans-Peter Pfeiffer
@param jcas