void FrenchStemmer::step2b() { static Collection<String> suffix; if (!suffix) { static const wchar_t* _suffix[] = { L"eraIent", L"erais", L"erait", L"erai", L"eras", L"erions", L"eriez", L"erons", L"eront", L"erez", L"\x00e8rent", L"era", L"\x00e9es", L"iez", L"\x00e9e", L"\x00e9s", L"er", L"ez", L"\x00e9" }; suffix = Collection<String>::newInstance(_suffix, _suffix + SIZEOF_ARRAY(_suffix)); } deleteFrom(RV, suffix); static Collection<String> search; if (!search) { static const wchar_t* _search[] = { L"assions", L"assiez", L"assent", L"asses", L"asse", L"aIent", L"antes", L"aIent", L"Aient", L"ante", L"\x00e2mes", L"\x00e2tes", L"ants", L"ant", L"ait", L"a\x00eet", L"ais", L"Ait", L"A\x00eet", L"Ais", L"\x00e2t", L"as", L"ai", L"Ai", L"a" }; search = Collection<String>::newInstance(_search, _search + SIZEOF_ARRAY(_search)); } deleteButSuffixFrom(RV, search, L"e", true); deleteFrom(R2, newCollection<String>(L"ions")); }
void FrenchStemmer::step1() { Collection<String> suffix = newCollection<String>(L"ances", L"iqUes", L"ismes", L"ables", L"istes", L"ance", L"iqUe", L"isme", L"able", L"iste"); deleteFrom(R2, suffix); replaceFrom(R2, newCollection<String>(L"logies", L"logie"), L"log"); replaceFrom(R2, newCollection<String>(L"usions", L"utions", L"usion", L"ution"), L"u"); replaceFrom(R2, newCollection<String>(L"ences", L"ence"), L"ent"); Collection<String> search = newCollection<String>(L"atrices", L"ateurs", L"ations", L"atrice", L"ateur", L"ation"); deleteButSuffixFromElseReplace(R2, search, L"ic", true, R0, L"iqU"); deleteButSuffixFromElseReplace(R2, newCollection<String>(L"ements", L"ement"), L"eus", false, R0, L"eux"); deleteButSuffixFrom(R2, newCollection<String>(L"ements", L"ement"), L"ativ", false); deleteButSuffixFrom(R2, newCollection<String>(L"ements", L"ement"), L"iv", false); deleteButSuffixFrom(R2, newCollection<String>(L"ements", L"ement"), L"abl", false); deleteButSuffixFrom(R2, newCollection<String>(L"ements", L"ement"), L"iqU", false); deleteFromIfTestVowelBeforeIn(R1, newCollection<String>(L"issements", L"issement"), false, R0); deleteFrom(RV, newCollection<String>(L"ements", L"ement")); deleteButSuffixFromElseReplace(R2, newCollection<String>(L"it\x00e9s", L"it\x00e9"), L"abil", false, R0, L"abl"); deleteButSuffixFromElseReplace(R2, newCollection<String>(L"it\x00e9s", L"it\x00e9"), L"ic", false, R0, L"iqU"); deleteButSuffixFrom(R2, newCollection<String>(L"it\x00e9s", L"it\x00e9"), L"iv", true); Collection<String> autre = newCollection<String>(L"ifs", L"ives", L"if", L"ive"); deleteButSuffixFromElseReplace(R2, autre, L"icat", false, R0, L"iqU"); deleteButSuffixFromElseReplace(R2, autre, L"at", true, R2, L"iqU"); replaceFrom(R0, newCollection<String>(L"eaux"), L"eau"); replaceFrom(R1, newCollection<String>(L"aux"), L"al"); deleteButSuffixFromElseReplace(R2, newCollection<String>(L"euses", L"euse"), L"", true, R1, L"eux"); deleteFrom(R2, newCollection<String>(L"eux")); // if one of the next steps is performed, we will need to perform step2a if (replaceFrom(RV, newCollection<String>(L"amment"), L"ant")) suite = true; if (replaceFrom(RV, newCollection<String>(L"emment"), L"ent")) suite = true; if (deleteFromIfTestVowelBeforeIn(RV, newCollection<String>(L"ments", L"ment"), true, RV)) suite = true; }
/** * Deletes element from a subtree. * * @param [in,out] tree The AVL tree. * @param [in,out] node The root of the given subtree. * @param [in] key The key of the node. */ static void deleteFrom(AVL_Tree *tree, AVL_Node *node, const void *key) { int result; // Find the key recursively. if (!node) return; result = tree->keyComparer(key, node->key); if (result < 0) { return deleteFrom(tree, node->left, key); // void functions can return void, obviously. } else if (result > 0) { return deleteFrom(tree, node->right, key); } // Found the node, so remove it. removeNode(tree, node); free(node); }
unsigned int process_event_list(DataSet *terrain, GridPoint start, SweepEvent *event_list, size_t len, DataSet *vshed) { SweepEvent *eptr, *eend; RBTree *tree; TreeNode *node; TreeValue value; unsigned int count; double h0, h1; // retrieve height of start point gpHeight(terrain, start, h0); // initialiaze tree value.key = 0; value.gradient = SMALLEST_GRADIENT; tree = createTree(value); // process list count = 0; eptr = event_list; eend = event_list + len; while (eptr < eend) { if (eptr->event == ENTER_EVENT) { // set key to node distance value.key = eptr->dist; // calculate slope in z gpHeight(terrain, eptr->p, h1); value.gradient = (h1 - h0) / eptr->dist; // insert the node into the active list insertInto(tree, value); }else if (eptr->event == SIGHT_EVENT) { // check the active list if the current node is visible // query for the current node node = searchForNodeWithKey(tree, eptr->dist); assert(notNIL(node)); h1 = findMaxGradientWithinKey(tree, eptr->dist); if (vshed != NULL) dSet(vshed, eptr->p.r, eptr->p.c, (node->value.gradient >= h1)); count += (node->value.gradient >= h1); }else { // LEAVE_EVENT // remove the current node deleteFrom(tree, eptr->dist); } eptr++; } // garbage collect deleteTree(tree); return count; }
void FrenchStemmer::step4() { if (stringBuffer.length() > 1) { wchar_t ch = stringBuffer[stringBuffer.length() - 1]; if (ch == L's') { wchar_t b = stringBuffer[stringBuffer.length() - 2]; if (b != L'a' && b != L'i' && b != L'o' && b != L'u' && b != L'\x00e8' && b != L's') { stringBuffer.resize(stringBuffer.length() - 1); setStrings(); } } } if (!deleteFromIfPrecededIn(R2, newCollection<String>(L"ion"), RV, L"s")) deleteFromIfPrecededIn(R2, newCollection<String>(L"ion"), RV, L"t"); replaceFrom(RV, newCollection<String>(L"I\x00e8re", L"i\x00e8re", L"Ier", L"ier"), L"i"); deleteFrom(RV, newCollection<String>(L"e")); deleteFromIfPrecededIn(RV, newCollection<String>(L"\x00eb"), R0, L"gu"); }
void AVL_delete(AVL_Tree *tree, const void *key) { deleteFrom(tree, tree->rootNode, key); }