src/English/timex/en_TemporalNormalizer.cpp
/* Combine adjacent number tokens in the TemporalString into a single number
if possible (for example, nineteen eighty three - 19 80 3 - would 
become 1983) */
Combine adjacent number tokens in the TemporalString into a single number
if possible (for example, nineteen eighty three - 19 80 3 - would
become 1983)
Combine adjacent number tokens in the TemporalString into a single number if possible ( for example nineteen eighty three - 19 80 3 - would become 1983 )
void EnglishTemporalNormalizer::combineAdjacentNumbers(TemporalString *t) {
	int first, second;
	for (int i = 0; i < t->size(); i++) {
		if ((Strings::parseInt(t->tokenAt(i)) > -1) && (Strings::parseInt(t->tokenAt(i + 1)) > -1)) {
			first = Strings::parseInt(t->tokenAt(i));
			second = Strings::parseInt(t->tokenAt(i+1));
			if ( second == 1000 && first > 0 && first < 1000) {
				t->setToken(i, Strings::valueOf(first * second));
				t->remove(i+1);
				i--;
			}
			if ( second == 100 && first > 0 && first < 20) {
				t->setToken(i, Strings::valueOf(first * second));
				t->remove(i+1);
				i--;
			}
			else if (first > 10 && first <= 20 && second >= 10 && second < 100) {
				t->setToken(i, Strings::valueOf((first*100) + second));
				t->remove(i+1);
				i--;
			}
			else if ( (first%100) == 0 && second > 0 && second < 10) {
				t->setToken(i, Strings::valueOf((int)(first/100)) + L"0" + Strings::valueOf(second));
				t->remove(i+1);
				i--;
			}
			else if ( (first%100) == 0 && second > 0 && second < 100) {
				t->setToken(i, Strings::valueOf((int)(first/100)) + Strings::valueOf(second));
				t->remove(i+1);
				i--;
			}
			else if ( (first%10) == 0 && second > 0 && second < 10) {
				t->setToken(i, Strings::valueOf((int)(first/10)) + Strings::valueOf(second));
				t->remove(i+1);
				i--;
			}
		}
	}
}
void EnglishTemporalNormalizer :: combineAdjacentNumbers ( TemporalString * t ) { int first , second ; for ( int i = 0 ; i < t -> size ( ) ; i ++ ) { if ( ( Strings :: parseInt ( t -> tokenAt ( i ) ) > -1 ) && ( Strings :: parseInt ( t -> tokenAt ( i + 1 ) ) > -1 ) ) { first = Strings :: parseInt ( t -> tokenAt ( i ) ) ; second = Strings :: parseInt ( t -> tokenAt ( i + 1 ) ) ; if ( second == 1000 && first > 0 && first < 1000 ) { t -> setToken ( i , Strings :: valueOf ( first * second ) ) ; t -> remove ( i + 1 ) ; i -- ; } if ( second == 100 && first > 0 && first < 20 ) { t -> setToken ( i , Strings :: valueOf ( first * second ) ) ; t -> remove ( i + 1 ) ; i -- ; } else if ( first > 10 && first <= 20 && second >= 10 && second < 100 ) { t -> setToken ( i , Strings :: valueOf ( ( first * 100 ) + second ) ) ; t -> remove ( i + 1 ) ; i -- ; } else if ( ( first % 100 ) == 0 && second > 0 && second < 10 ) { t -> setToken ( i , Strings :: valueOf ( ( int ) ( first / 100 ) ) + L" " + Strings :: valueOf ( second ) ) ; t -> remove ( i + 1 ) ; i -- ; } else if ( ( first % 100 ) == 0 && second > 0 && second < 100 ) { t -> setToken ( i , Strings :: valueOf ( ( int ) ( first / 100 ) ) + Strings :: valueOf ( second ) ) ; t -> remove ( i + 1 ) ; i -- ; } else if ( ( first % 10 ) == 0 && second > 0 && second < 10 ) { t -> setToken ( i , Strings :: valueOf ( ( int ) ( first / 10 ) ) + Strings :: valueOf ( second ) ) ; t -> remove ( i + 1 ) ; i -- ; } } } }
Combine adjacent number tokens in the TemporalString into a single number
if possible (for example, nineteen eighty three - 19 80 3 - would
become 1983)
Combine adjacent number tokens in the TemporalString into a single number if possible ( for example nineteen eighty three - 19 80 3 - would become 1983 )