void Token::constructTerms() { string aux; iterador = candidates.begin(); while (iterador != candidates.end()) { aux = trim_copy(*iterador, " \'{}[]-+.,*/%$?<>=^#&!_`"); aux = replaceMultiByteChars(aux, '_'); if (!isdigit(aux[0])) aux = caseNotDigit(aux); else if ((isdigit(aux[0]))) aux = caseDigit(aux); aux = trim_copy(aux, " @\'{}[]-+.*/?<>=^$%#&!_"); if (aux == "") { iterador = candidates.erase(iterador); } else { string_type tipo = whatIsIt(aux); if ((tipo == ALPHANUMERIC1) || (tipo == TEXT)) { stringToLower(aux); stemOfPlural(aux); } *iterador = aux; iterador++; } } iterador = candidates.begin(); _currentPosition = 0; _count = candidates.size(); }
int main () { // FILE *f = fopen(INP, "r"); FILE *f = stdin; fscanf(f,"%d",&T); for(int i = 1; i <= T; i++){ for(int j = 1; j <= 4; j++){ fscanf(f,"%d%d",&P[j].x,&P[j].y); } //process Result = 6; memset(Used,false,sizeof Used); Used[1] = true; for(int j = 2; j <= 4; j++){ if(Result != 6) break; Used[j] = true; pair <int, int> line (0,0); for(int k = 2; k <= 4; k++){ if(!Used[k]){ if(line.first == 0) line.first = k; else line.second = k; } } if(!checkParallel(P[1],P[j],P[line.first],P[line.second])) {Used[j] = false; continue;} else{ Result = 5; if(checkParallel(P[1],P[line.first],P[j],P[line.second])){ Result = 4; whatIsIt(P[1],P[line.first],P[j],P[line.second]); } else{ if(checkParallel(P[1],P[line.second],P[j],P[line.first])){ Result = 4; whatIsIt(P[1],P[line.second],P[j],P[line.first]); } else break; } } Used[j] = false; } //output printf("Case %d: %s\n",i,Shape[Result]); } // getchar(); return 0; }
string Token::caseDigit(string str) { vector<string> v; split(v, str, separators_number); if (v.size() > 1) { if (v.size() == 2) if ((whatIsIt(v[0]) == INTEGER1) && (whatIsIt(v[1]) == INTEGER1) && (v[0].length() == 4)) if (v[1].length() == 2) v[1] = completeYear(v); str = ""; for (unsigned int i = 0; i < v.size(); i++) { if (v.size() == 2) //palabras compuestas str += v[i]; candidates.push_back(v[i]); } str = removeCharacters(str, ".,"); // Elimino los separadores restantes. if (whatIsIt(str) != ALPHANUMERIC1) str = ""; } else { str = removeCharacters(str, ","); // Elimino el separador de miles. string_type tipo = whatIsIt(str); //lo pongo para evaluar solo una vez if (tipo == FLOAT1) str = roundNumber(str); else { if (tipo == GARBAGE) str = ""; else if (tipo == INTEGER1) { int entero = atoi(str.c_str()); str = toString(entero); } str = removeCharacters(str, "."); // Caso de numero.palabra elimina el punto. Ej: "1.the" } } return str; }
string Token::caseNotDigit(string str) { vector<string> v; size_t t = 0; split(v, str, separators_text); if (v.size() > 1) { str = ""; while (t < v.size()) { candidates.push_back(v[t]); if (v.size() <= 4) str += v[t]; t++; } } str = trim_right_copy(str, numbers); if (whatIsIt(str) == GARBAGE) str = ""; return str; }