void PorterStemmer::step3() { if (k == k0) return; /* For Bug 1 */ switch (b[k-1]) { case 'a': if (ends(_T("ational"))) { r(_T("ate")); break; } if (ends(_T("tional"))) { r(_T("tion")); break; } break; case 'c': if (ends(_T("enci"))) { r(_T("ence")); break; } if (ends(_T("anci"))) { r(_T("ance")); break; } break; case 'e': if (ends(_T("izer"))) { r(_T("ize")); break; } break; case 'l': if (ends(_T("bli"))) { r(_T("ble")); break; } if (ends(_T("alli"))) { r(_T("al")); break; } if (ends(_T("entli"))) { r(_T("ent")); break; } if (ends(_T("eli"))) { r(_T("e")); break; } if (ends(_T("ousli"))) { r(_T("ous")); break; } break; case 'o': if (ends(_T("ization"))) { r(_T("ize")); break; } if (ends(_T("ation"))) { r(_T("ate")); break; } if (ends(_T("ator"))) { r(_T("ate")); break; } break; case 's': if (ends(_T("alism"))) { r(_T("al")); break; } if (ends(_T("iveness"))) { r(_T("ive")); break; } if (ends(_T("fulness"))) { r(_T("ful")); break; } if (ends(_T("ousness"))) { r(_T("ous")); break; } break; case 't': if (ends(_T("aliti"))) { r(_T("al")); break; } if (ends(_T("iviti"))) { r(_T("ive")); break; } if (ends(_T("biliti"))) { r(_T("ble")); break; } break; case 'g': if (ends(_T("logi"))) { r(_T("log")); break; } } }
static void step4(struct stemmer * z) { switch (z->b[z->k - 1]) { case 'a': if (ends(z, "\02" "al")) break; return; case 'c': if (ends(z, "\04" "ance")) break; if (ends(z, "\04" "ence")) break; return; case 'e': if (ends(z, "\02" "er")) break; return; case 'i': if (ends(z, "\02" "ic")) break; return; case 'l': if (ends(z, "\04" "able")) break; if (ends(z, "\04" "ible")) break; return; case 'n': if (ends(z, "\03" "ant")) break; if (ends(z, "\05" "ement")) break; if (ends(z, "\04" "ment")) break; if (ends(z, "\03" "ent")) break; return; case 'o': if (ends(z, "\03" "ion") && z->j >= 0 && (z->b[z->j] == 's' || z->b[z->j] == 't')) break; if (ends(z, "\02" "ou")) break; return; /* takes care of -ous */ case 's': if (ends(z, "\03" "ism")) break; return; case 't': if (ends(z, "\03" "ate")) break; if (ends(z, "\03" "iti")) break; return; case 'u': if (ends(z, "\03" "ous")) break; return; case 'v': if (ends(z, "\03" "ive")) break; return; case 'z': if (ends(z, "\03" "ize")) break; return; default: return; } if (m(z) > 1) z->k = z->j; }
void PorterStemmer::step2() { if (ends(_T("y")) && vowelinstem()) { b[k] = 'i'; dirty = true; } }
static void step1c(struct stemmer * z) { if (ends(z, "\01" "y") && vowelinstem(z)) z->b[z->k] = 'i'; }
static void step2(struct stemmer * z) { switch (z->b[z->k - 1]) { case 'a': if (ends(z, "\07" "ational")) { r(z, "\03" "ate"); break; } if (ends(z, "\06" "tional")) { r(z, "\04" "tion"); break; } break; case 'c': if (ends(z, "\04" "enci")) { r(z, "\04" "ence"); break; } if (ends(z, "\04" "anci")) { r(z, "\04" "ance"); break; } break; case 'e': if (ends(z, "\04" "izer")) { r(z, "\03" "ize"); break; } break; case 'l': if (ends(z, "\03" "bli")) { r(z, "\03" "ble"); break; } /*-DEPARTURE-*/ /* To match the published algorithm, replace this line with case 'l': if (ends(z, "\04" "abli")) { r(z, "\04" "able"); break; } */ if (ends(z, "\04" "alli")) { r(z, "\02" "al"); break; } if (ends(z, "\05" "entli")) { r(z, "\03" "ent"); break; } if (ends(z, "\03" "eli")) { r(z, "\01" "e"); break; } if (ends(z, "\05" "ousli")) { r(z, "\03" "ous"); break; } break; case 'o': if (ends(z, "\07" "ization")) { r(z, "\03" "ize"); break; } if (ends(z, "\05" "ation")) { r(z, "\03" "ate"); break; } if (ends(z, "\04" "ator")) { r(z, "\03" "ate"); break; } break; case 's': if (ends(z, "\05" "alism")) { r(z, "\02" "al"); break; } if (ends(z, "\07" "iveness")) { r(z, "\03" "ive"); break; } if (ends(z, "\07" "fulness")) { r(z, "\03" "ful"); break; } if (ends(z, "\07" "ousness")) { r(z, "\03" "ous"); break; } break; case 't': if (ends(z, "\05" "aliti")) { r(z, "\02" "al"); break; } if (ends(z, "\05" "iviti")) { r(z, "\03" "ive"); break; } if (ends(z, "\06" "biliti")) { r(z, "\03" "ble"); break; } break; case 'g': if (ends(z, "\04" "logi")) { r(z, "\03" "log"); break; } /*-DEPARTURE-*/ /* To match the published algorithm, delete this line */ } }
int poor_rubber_font_rep::search_font (string s, string& r) { if (starts (s, "<big-") && (ends (s, "-1>") || ends (s, "-2>"))) { r= s; return 2*MAGNIFIED_NUMBER + 4; } if (starts (s, "<mid-")) s= "<left-" * s (5, N(s)); if (starts (s, "<right-")) s= "<left-" * s (7, N(s)); if (starts (s, "<large-")) s= "<left-" * s (7, N(s)); if (starts (s, "<left-")) { int pos= search_backwards ("-", N(s), s), num; if (pos > 6) { r= s (6, pos); num= as_int (s (pos+1, N(s)-1)); } else { r= s (6, N(s)-1); num= 0; } //cout << "Search " << base->res_name << ", " << s // << ", " << r << ", " << num << LF; int nr= max (num - 5, 0); int thin= (is_thin (r)? 1: 0); int code; if (num <= MAGNIFIED_NUMBER || r == "/" || r == "\\" || r == "langle" || r == "rangle") { num= min (num, MAGNIFIED_NUMBER); if (N(r) > 1) r= "<" * r * ">"; if (N(r)>1 && !base->supports (r)) { if (r == "<||>") r= "<emu-dbar>"; else if (r == "<interleave>") r= "<emu-tbar>"; else if (r == "<llbracket>") r= "<emu-dlbracket>"; else if (r == "<rrbracket>") r= "<emu-drbracket>"; else r= "<emu-" * r (1, N(r)-1) * ">"; } else if (r == "\\" && base->supports ("/")) { metric ex1, ex2; base -> get_extents ("/", ex1); base -> get_extents ("\\", ex2); double h1= ex1->y2 - ex1->y1; double h2= ex2->y2 - ex2->y1; if (fabs ((h2/h1) - 1.0) > 0.05) r= "<emu-backslash>"; } return 2*num + thin; } else if (r == "(") code= virt->dict ["<rubber-lparenthesis-#>"]; else if (r == ")") code= virt->dict ["<rubber-rparenthesis-#>"]; else if (r == "[") code= virt->dict ["<rubber-lbracket-#>"]; else if (r == "]") code= virt->dict ["<rubber-rbracket-#>"]; else if (r == "{") code= virt->dict ["<rubber-lcurly-#>"]; else if (r == "}") code= virt->dict ["<rubber-rcurly-#>"]; else if (r == "|") code= virt->dict ["<rubber-bar-#>"]; else if (r == "||") { if (base->supports ("<||>")) code= virt->dict ["<rubber-parallel-#>"]; else code= virt->dict ["<rubber-parallel*-#>"]; } else if (r == "interleave") { if (base->supports ("<interleave>")) code= virt->dict ["<rubber-interleave-#>"]; else code= virt->dict ["<rubber-interleave*-#>"]; } else if (r == "lfloor" || r == "rfloor" || r == "lceil" || r == "rceil" || r == "llbracket" || r == "rrbracket") { if (base->supports ("<" * r * ">")) code= virt->dict ["<rubber-" * r * "-#>"]; else code= virt->dict ["<rubber-" * r * "*-#>"]; } else if (r == "dlfloor" || r == "drfloor" || r == "dlceil" || r == "drceil" || r == "tlbracket" || r == "trbracket" || r == "tlfloor" || r == "trfloor" || r == "tlceil" || r == "trceil") code= virt->dict ["<rubber-" * r * "-#>"]; else code= virt->dict ["<rubber-lparenthesis-#>"]; r= string ((char) code) * as_string (nr + HUGE_ADJUST) * ">"; return 2*MAGNIFIED_NUMBER + 2 + thin; } r= s; return 0; }
static void step4() { switch (b[k-1]) { case 'a': if (ends("\02" "al")) break; return; case 'c': if (ends("\04" "ance")) break; if (ends("\04" "ence")) break; return; case 'e': if (ends("\02" "er")) break; return; case 'i': if (ends("\02" "ic")) break; return; case 'l': if (ends("\04" "able")) break; if (ends("\04" "ible")) break; return; case 'n': if (ends("\03" "ant")) break; if (ends("\05" "ement")) break; if (ends("\04" "ment")) break; if (ends("\03" "ent")) break; return; case 'o': if (ends("\03" "ion") && j >= k0 && (b[j] == 's' || b[j] == 't')) break; if (ends("\02" "ou")) // Takes care of -ous break; return; case 's': if (ends("\03" "ism")) break; return; case 't': if (ends("\03" "ate")) break; if (ends("\03" "iti")) break; return; case 'u': if (ends("\03" "ous")) break; return; case 'v': if (ends("\03" "ive")) break; return; case 'z': if (ends("\03" "ize")) break; return; default: return; } if (m() > 1) k = j; }
void CStemmer::step1c() { if (ends("\01" "y") && vowelinstem()) b[k] = 'i'; }
int main(int argc, const char* argv[]){ IloEnv env; try { const char* filename = "../../../examples/data/learningeffect_default.data"; IloInt failLimit = IloIntMax; if (argc > 1) filename = argv[1]; if (argc > 2) failLimit = atoi(argv[2]); std::ifstream file(filename); if (!file){ env.out() << "usage: " << argv[0] << " <file> <failLimit>" << std::endl; throw FileError(); } IloModel model(env); IloInt nbJobs, nbMachines; file >> nbJobs; file >> nbMachines; IloIntervalVarArray2 machines(env, nbMachines); IloIntArray2 sizes(env, nbMachines); for (IloInt j = 0; j < nbMachines; j++) { machines[j] = IloIntervalVarArray(env); sizes[j] = IloIntArray(env); } IloIntExprArray ends(env); for (IloInt i = 0; i < nbJobs; i++) { IloIntervalVar prec; for (IloInt j = 0; j < nbMachines; j++) { IloInt m, d; file >> m; file >> d; IloIntervalVar ti(env); machines[m].add(ti); sizes[m].add(d); if (0 != prec.getImpl()) model.add(IloEndBeforeStart(env, prec, ti)); prec = ti; } ends.add(IloEndOf(prec)); } for (IloInt j = 0; j < nbMachines; j++) { IloInt lef; file >> lef; IloNum alpha = lef/100.0; IloIntervalVarArray chain(env); IloIntVarArray indices(env); IloIntervalVar prec; for(IloInt i = 0; i < nbJobs; ++i) { IloIntervalVar ti = machines[j][i]; IloInt d = sizes[j][i]; ti.setSizeMax(d); // Building of the chain of intervals for the machine. IloIntervalVar syncti(env); if (prec.getImpl()) model.add(IloEndBeforeStart(env, prec, syncti)); prec = syncti; IloIntVar index(env, 0, nbJobs - 1); // Learning effect captured by the decreasing function // of the position (0 <= alpha <= 1). // At first position in the sequence index = 0; there is no // learning effect and duration of the task is its nominal duration model.add(IloSizeOf(ti) == IloFloor(IloNum(d)*IloPower(alpha, index))); chain.add(syncti); indices.add(index); } model.add(IloIsomorphism(env, chain, machines[j], indices, nbJobs)); // The no-overlap is a redundant constraint in this quite simple // model - it is used only to provide stronger inference. model.add(IloNoOverlap(env, machines[j])); } IloObjective objective = IloMinimize(env,IloMax(ends)); model.add(objective); IloCP cp(model); cp.setParameter(IloCP::FailLimit, failLimit); cp.setParameter(IloCP::LogPeriod, 10000); cp.out() << "Instance \t: " << filename << std::endl; if (cp.solve()) { cp.out() << "Makespan \t: " << cp.getObjValue() << std::endl; } else { cp.out() << "No solution found." << std::endl; } } catch(IloException& e){ env.out() << " ERROR: " << e << std::endl; } env.end(); return 0; }
void SkTileGrid::search(const SkRect& originalQuery, SkTDArray<unsigned>* results) const { // The inset counteracts the outset that applied in 'insert', which optimizes // for lookups of size 'tileInterval + 2 * margin' (aligned with the tile grid). SkRect query = originalQuery; query.inset(fMarginWidth, fMarginHeight); this->commonAdjust(&query); // The inset may have inverted the rectangle, so sort(). // TODO(mtklein): It looks like we only end up with inverted bounds in unit tests // that make explicitly inverted queries, not from insetting. If we can drop support for // unsorted bounds (i.e. we don't see them outside unit tests), I think we can drop this. query.sort(); // No intersection check. We optimize for queries that are in bounds. // We're safe anyway: userToGrid() will clamp out-of-bounds queries to nearest tile. SkIRect grid; this->userToGrid(query, &grid); const int tilesHit = (grid.fRight - grid.fLeft + 1) * (grid.fBottom - grid.fTop + 1); SkASSERT(tilesHit > 0); if (tilesHit == 1) { // A performance shortcut. The merging code below would work fine here too. *results = fTiles[grid.fTop * fXTiles + grid.fLeft]; return; } // We've got to merge the data in many tiles into a single sorted and deduplicated stream. // We do a simple k-way merge based on the value of opIndex. // Gather pointers to the starts and ends of the tiles to merge. SkAutoSTArray<kStackAllocationTileCount, const unsigned*> starts(tilesHit), ends(tilesHit); int i = 0; for (int y = grid.fTop; y <= grid.fBottom; y++) { for (int x = grid.fLeft; x <= grid.fRight; x++) { starts[i] = fTiles[y * fXTiles + x].begin(); ends[i] = fTiles[y * fXTiles + x].end(); i++; } } // Merge tiles into results until they're fully consumed. results->reset(); while (true) { // The tiles themselves are already ordered, so the earliest op is at the front of some // tile. It may be at the front of several, even all, tiles. unsigned earliest = SK_MaxU32; for (int i = 0; i < starts.count(); i++) { if (starts[i] < ends[i]) { earliest = SkTMin(earliest, *starts[i]); } } // If we didn't find an earliest op, there isn't anything left to merge. if (SK_MaxU32 == earliest) { return; } // We did find an earliest op. Output it, and step forward every tile that contains it. results->push(earliest); for (int i = 0; i < starts.count(); i++) { if (starts[i] < ends[i] && *starts[i] == earliest) { starts[i]++; } } } }
static int equals(struct stemmer * z, char * s) { if (s[0] != z->k + 1) return FALSE; return ends(z, s); }
/* step2() maps double suffices to single ones. so -ization ( = -ize plus -ation) maps to -ize etc. note that the string before the suffix must give m() > 0. */ static void step2(void) { switch (b[k-1]) { case 'a': if (ends("\07" "ational")) { r("\03" "ate"); break; } if (ends("\06" "tional")) { r("\04" "tion"); break; } break; case 'c': if (ends("\04" "enci")) { r("\04" "ence"); break; } if (ends("\04" "anci")) { r("\04" "ance"); break; } break; case 'e': if (ends("\04" "izer")) { r("\03" "ize"); break; } break; case 'l': if (ends("\03" "bli")) { r("\03" "ble"); break; } /*-DEPARTURE-*/ if (ends("\04" "alli")) { r("\02" "al"); break; } if (ends("\05" "entli")) { r("\03" "ent"); break; } if (ends("\03" "eli")) { r("\01" "e"); break; } if (ends("\05" "ousli")) { r("\03" "ous"); break; } break; case 'o': if (ends("\07" "ization")) { r("\03" "ize"); break; } if (ends("\05" "ation")) { r("\03" "ate"); break; } if (ends("\04" "ator")) { r("\03" "ate"); break; } break; case 's': if (ends("\05" "alism")) { r("\02" "al"); break; } if (ends("\07" "iveness")) { r("\03" "ive"); break; } if (ends("\07" "fulness")) { r("\03" "ful"); break; } if (ends("\07" "ousness")) { r("\03" "ous"); break; } break; case 't': if (ends("\05" "aliti")) { r("\02" "al"); break; } if (ends("\05" "iviti")) { r("\03" "ive"); break; } if (ends("\06" "biliti")) { r("\03" "ble"); break; } break; case 'g': if (ends("\04" "logi")) { r("\03" "log"); break; } /*-DEPARTURE-*/ default: break; } return; }
void SkTileGrid::search(const SkRect& query, SkTDArray<void*>* results) const { SkIRect adjusted; query.roundOut(&adjusted); // The inset is to counteract the outset that was applied in 'insert' // The outset/inset is to optimize for lookups of size // 'tileInterval + 2 * margin' that are aligned with the tile grid. adjusted.inset(fInfo.fMargin.width(), fInfo.fMargin.height()); adjusted.offset(fInfo.fOffset); adjusted.sort(); // in case the inset inverted the rectangle // Convert the query rectangle from device coordinates to tile coordinates // by rounding outwards to the nearest tile boundary so that the resulting tile // region includes the query rectangle. int startX = adjusted.left() / fInfo.fTileInterval.width(), startY = adjusted.top() / fInfo.fTileInterval.height(); int endX = divide_ceil(adjusted.right(), fInfo.fTileInterval.width()), endY = divide_ceil(adjusted.bottom(), fInfo.fTileInterval.height()); // Logically, we could pin endX to [startX, fXTiles], but we force it // up to (startX, fXTiles] to make sure we hit at least one tile. // This snaps just-out-of-bounds queries to the neighboring border tile. // I don't know if this is an important feature outside of unit tests. startX = SkPin32(startX, 0, fXTiles - 1); startY = SkPin32(startY, 0, fYTiles - 1); endX = SkPin32(endX, startX + 1, fXTiles); endY = SkPin32(endY, startY + 1, fYTiles); const int tilesHit = (endX - startX) * (endY - startY); SkASSERT(tilesHit > 0); if (tilesHit == 1) { // A performance shortcut. The merging code below would work fine here too. const SkTDArray<Entry>& tile = fTiles[startY * fXTiles + startX]; results->setCount(tile.count()); for (int i = 0; i < tile.count(); i++) { (*results)[i] = tile[i].data; } return; } // We've got to merge the data in many tiles into a single sorted and deduplicated stream. // We do a simple k-way merge based on the order the data was inserted. // Gather pointers to the starts and ends of the tiles to merge. SkAutoSTArray<kStackAllocationTileCount, const Entry*> starts(tilesHit), ends(tilesHit); int i = 0; for (int x = startX; x < endX; x++) { for (int y = startY; y < endY; y++) { starts[i] = fTiles[y * fXTiles + x].begin(); ends[i] = fTiles[y * fXTiles + x].end(); i++; } } // Merge tiles into results until they're fully consumed. results->reset(); while (true) { // The tiles themselves are already ordered, so the earliest is at the front of some tile. // It may be at the front of several, even all, tiles. const Entry* earliest = NULL; for (int i = 0; i < starts.count(); i++) { if (starts[i] < ends[i]) { if (NULL == earliest || starts[i]->order < earliest->order) { earliest = starts[i]; } } } // If we didn't find an earliest entry, there isn't anything left to merge. if (NULL == earliest) { return; } // We did find an earliest entry. Output it, and step forward every tile that contains it. results->push(earliest->data); for (int i = 0; i < starts.count(); i++) { if (starts[i] < ends[i] && starts[i]->order == earliest->order) { starts[i]++; } } } }
int rubber_stix_font_rep::search_font_sub (string s, string& rew, string& ltype) { ltype= ""; if (starts (s, "<big-") && ends (s, "-1>")) { string r= s (5, N(s) - 3); if (ends (r, "lim")) r= r (0, N(r) - 3); if (starts (r, "up") && ends (r, "int")) { rew= "<big-" * r (2, N(r)) * ">"; return 4; } if (ends (r, "int") || r == "sum" || r == "prod" || r == "pluscup") { rew= s; return 0; } if (r == "box") s= "<big-square-1>"; rew= s; return 1; } if (starts (s, "<big-") && ends (s, "-2>")) { string r= s (5, N(s) - 3); if (ends (r, "lim")) r= r (0, N(r) - 3); if (starts (r, "up") && ends (r, "int")) { rew= "<big-" * r (2, N(r)) * ">"; return 5; } if (ends (r, "int")) { rew= "<big-" * r * ">"; return 3; } if (r == "sum" || r == "prod" || r == "amalg" || r == "cap" || r == "cup" || r == "vee" || r == "wedge") { rew= "<big-" * r * ">"; return 6; } if (r == "pluscup") { rew= "<big-" * r * ">"; return 1; } if (r == "box") s= "<big-square-2>"; rew= s; return 2; } if (starts (s, "<mid-")) s= "<left-" * s (5, N(s)); if (starts (s, "<right-")) s= "<left-" * s (7, N(s)); if (starts (s, "<large-")) s= "<left-" * s (7, N(s)); if (starts (s, "<left-")) { int pos= search_backwards ("-", N(s), s); if (pos > 6) ltype= s (6, pos); } if (starts (s, "<left-.")) { rew= ""; return 0; } if (starts (s, "<left-|") || starts (s, "<left-interleave-")) { int nr= large_size (s); if (nr <= 0) { string r= large_type (s); r= r (5, N(r)); if (N(r) > 1) r= "<" * r * ">"; rew= r; return 0; } else { rew= "<" * large_type (s) * "-" * as_string (nr + 9) * ">"; return 16; } } if (starts (s, "<left-") && ends (s, "-0>")) { rew= s; return 0; } if (starts (s, "<left-") && ends (s, "-1>")) { string r= s (6, N(s) - 3); if (N(r) > 1) r= "<" * r * ">"; rew= r; return 7; } if (starts (s, "<left-") && ends (s, "-2>")) { string r= s (6, N(s) - 3); if (N(r) > 1) r= "<" * r * ">"; rew= r; return 8; } if (starts (s, "<left-") && ends (s, "-3>")) { string r= s (6, N(s) - 3); if (N(r) > 1) r= "<" * r * ">"; rew= r; return 9; } if (starts (s, "<left-") && ends (s, "-4>")) { string r= s (6, N(s) - 3); if (N(r) > 1) r= "<" * r * ">"; rew= r; return 10; } if (starts (s, "<left-")) { int pos= search_backwards ("-", N(s), s); if (pos > 6) { string r= s (6, pos); int nr= as_int (s (pos+1, N(s)-1)); if (r == "(" || r == ")" || r == "[" || r == "]") { rew= "<left-" * r * "-" * as_string (nr + 5) * ">"; return 17; } if (r == "{" || r == "}") { rew= "<left-" * r * "-" * as_string (nr + 2) * ">"; return 17; } if (r == "lfloor" || r == "rfloor" || r == "lceil" || r == "rceil") { rew= "<left-" * r * "-" * as_string (nr + 9) * ">"; return 17; } if (r == "/" || r == "\\" || r == "langle" || r == "rangle") { if (N(r) == 1) rew= r; else rew= "<" * r * ">"; return 10; } } } if (starts (s, "<rubber-") && ends (s, ">")) { int pos= search_backwards ("-", N(s), s); if (pos > 8) { string r= s (8, pos); int nr= as_int (s (pos+1, N(s)-1)); if (nr < 0) nr= 0; if (nr > 5) nr= 5; if (r == "hat") rew= "<#2C6>"; else if (r == "tilde") rew= "<#2DC>"; else if (r == "check") rew= "<#2C7>"; else if (r == "bar") rew= "<#203E>"; else if (r == "vect") rew= "<#20D7>"; else if (r == "breve") rew= "<#2D8>"; else if (r == "invbreve") rew= "<#311>"; else if (r == "punderbrace") rew= "<#23DD>"; else if (r == "punderbrace*") rew= "<#23DD>"; else if (r == "underbrace") rew= "<#23DF>"; else if (r == "underbrace*") rew= "<#23DF>"; else if (r == "squnderbrace") rew= "<#23B5>"; else if (r == "squnderbrace*") rew= "<#23B5>"; else if (r == "poverbrace") rew= "<#23DC>"; else if (r == "poverbrace*") rew= "<#23DC>"; else if (r == "overbrace") rew= "<#23DE>"; else if (r == "overbrace*") rew= "<#23DE>"; else if (r == "sqoverbrace") rew= "<#23B4>"; else if (r == "sqoverbrace*") rew= "<#23B4>"; else { rew= s; return 0; } if (nr == 0) return 0; else return 10 + nr; } } rew= s; return 0; }
void PorterStemmer::step5() { if (k == k0) return; /* for Bug 1 */ switch (b[k-1]) { case 'a': if (ends(_T("al"))) break; return; case 'c': if (ends(_T("ance"))) break; if (ends(_T("ence"))) break; return; case 'e': if (ends(_T("er"))) break; return; case 'i': if (ends(_T("ic"))) break; return; case 'l': if (ends(_T("able"))) break; if (ends(_T("ible"))) break; return; case 'n': if (ends(_T("ant"))) break; if (ends(_T("ement"))) break; if (ends(_T("ment"))) break; /* element etc. not stripped before the m */ if (ends(_T("ent"))) break; return; case 'o': if (ends(_T("ion")) && j >= 0 && (b[j] == 's' || b[j] == 't')) break; /* j >= 0 fixes Bug 2 */ if (ends(_T("ou"))) break; return; /* takes care of -ous */ case 's': if (ends(_T("ism"))) break; return; case 't': if (ends(_T("ate"))) break; if (ends(_T("iti"))) break; return; case 'u': if (ends(_T("ous"))) break; return; case 'v': if (ends(_T("ive"))) break; return; case 'z': if (ends(_T("ize"))) break; return; default: return; } if (m() > 1) k = j; }
static void step2() { switch (b[k - 1]) { case 'a': if (ends("\07" "ational")) { r("\03" "ate"); break; } if (ends("\06" "tional")) { r("\04" "tion"); break; } break; case 'c': if (ends("\04" "enci")) { r("\04" "ence"); break; } if (ends("\04" "anci")) { r("\04" "ance"); break; } break; case 'e': if (ends("\04" "izer")) { r("\03" "ize"); break; } break; case 'l': if (ends("\03" "bli")) { r("\03" "ble"); break; } // DEPARTURE: To match the published algorithm, replace the above if clause with // if (ends("\04" "abli")) { // r("\04" "able"); // break; // } if (ends("\04" "alli")) { r("\02" "al"); break; } if (ends("\05" "entli")) { r("\03" "ent"); break; } if (ends("\03" "eli")) { r("\01" "e"); break; } if (ends("\05" "ousli")) { r("\03" "ous"); break; } break; case 'o': if (ends("\07" "ization")) { r("\03" "ize"); break; } if (ends("\05" "ation")) { r("\03" "ate"); break; } if (ends("\04" "ator")) { r("\03" "ate"); break; } break; case 's': if (ends("\05" "alism")) { r("\02" "al"); break; } if (ends("\07" "iveness")) { r("\03" "ive"); break; } if (ends("\07" "fulness")) { r("\03" "ful"); break; } if (ends("\07" "ousness")) { r("\03" "ous"); break; } break; case 't': if (ends("\05" "aliti")) { r("\02" "al"); break; } if (ends("\05" "iviti")) { r("\03" "ive"); break; } if (ends("\06" "biliti")) { r("\03" "ble"); break; } break; // DEPARTURE: To match the published algorithm, delete this next case statement case 'g': if (ends("\04" "logi")) { r("\03" "log"); break; } } }
void step1c() { if (ends("\01" "y") && vowelinstem()) b[k] = 'i'; }
IloModel ReadModel(IloEnv env, const char* filename, IloConstraintArray& capacityCts, IloConstraintArray& precedenceCts) { std::ifstream file(filename); if (!file){ env.out() << "usage: sched_conflict <file> <failLimit>" << std::endl; throw FileError(); } IloModel model(env); IloInt nbTasks, nbResources, i, j; file >> nbTasks; file >> nbResources; IloCumulFunctionExprArray resources(env, nbResources); IloIntArray capacities(env, nbResources); for (j=0; j<nbResources; j++) { IloInt c; file >> c; capacities[j] = c; resources[j] = IloCumulFunctionExpr(env); } IloIntervalVarArray tasks(env, nbTasks); char name[32]; for (i=0; i<nbTasks; i++) { sprintf(name, "ACT%ld", i); tasks[i] = IloIntervalVar(env, name); ILOSETLOCATION(tasks[i]); } IloIntExprArray ends(env); for (i=0; i<nbTasks; i++) { IloIntervalVar task = tasks[i]; IloInt d, smin, emax, nbSucc; file >> d >> smin >> emax; task.setSizeMin(d); task.setSizeMax(d); task.setStartMin(smin); task.setEndMax(emax); ends.add(IloEndOf(task)); for (j = 0; j < nbResources; j++) { IloInt q; file >> q; if (q > 0) { resources[j] += IloPulse(task, q); } } file >> nbSucc; for (IloInt s=0; s<nbSucc; ++s) { IloInt succ; file >> succ; IloConstraint pct = IloEndBeforeStart(env, task, tasks[succ]); ILOADD(model, pct); precedenceCts.add(pct); } } for (j=0; j<nbResources; j++) { sprintf(name, "RES%ld", j); resources[j].setName(name); IloConstraint cct = (resources[j] <= capacities[j]); ILOADD(model, cct); capacityCts.add(cct); } model.add(IloMinimize(env, IloMax(ends))); return model; }