RULEXDB_SEARCH(3)

okay so bestie, you found it β€” RULEXDB_SEARCH(3), straight out of the Library Functions Manual shelf πŸ’…. This is the little function that looks at a word and is like "mmm I think I know how you're pronounced, let me check the vibes." Let's get into it πŸ¦‹


🌸 NAME 🌸

rulexdb_search β€” search rulex database for specified word ✨


πŸŽ€ SYNOPSIS πŸŽ€

#include <rulexdb.h>

int rulexdb_search(RULEXDB *rulexdb, const char *key, char *value, int flags);

πŸ’– DESCRIPTION πŸ’–

Okay so here's the tea πŸ“. rulexdb_search() goes digging in the database that the rulexdb argument points at, and it tries to guess the pronunciation of the word you handed it through the string that key points to β€” based on whatever info it managed to acquire. The resulting string gets placed into the buffer that value points to. Heads up though: that buffer must already have enough space for it, because nobody here is checking for you πŸ’€.

And when it finds absolutely no useful info? It just copies your original word into the value buffer and returns RULEXDB_SPECIAL. Like, "no thoughts, here's your word back" πŸ™ˆ.

Here's the whole journey, step by step, because the way this thing works is lowkey iconic πŸ‘‘:

  1. First up, the search happens in the Explicit dictionary. If that succeeds, the result is returned and the procedure exits successfully. Slay.
  2. If not, the word gets treated as an implicit form, and the program tries to guess its base and find it in the Implicit dictionary. If that works, the pronunciation string is constructed from the acquired data and the procedure exits successfully. Ate. πŸ’…
  3. Last resort: the word gets matched against general rules. If no match succeeds, the program exits with RULEXDB_SPECIAL, returning your original word as the result.

And if this whole process turns out to be not fully unsuccessful β€” meaning some info was found in the database β€” then the resulting string gets matched against correction rules, and the first matched one is applied, if there is any. Little finishing touch, you know? ✨

Now, that last argument? It decides which steps of the whole saga actually get performed. It's made of these flags, which you can bitwise-or together to build the search mode you want 🧚:

  • RULEXDB_EXCEPTIONS β€” search the word in the exceptions dictionary.
  • RULEXDB_FORMS β€” try to treat the specified word as an implicit form.
  • RULEXDB_RULES β€” try to apply general rules.
And a zero value (no flags at all) means the full search (all stages) should be performed. So like, no flags = main character energy, do everything 🌈.

⭐ RETURN VALUE ⭐

rulexdb_search() returns RULEXDB_SUCCESS, which is zero, upon success. If the specified word was not found, you get a positive value: RULEXDB_SPECIAL. And if something is wrong, you get a negative error code 😭.


πŸ’€ ERRORS πŸ’€

  • RULEXDB_FAILURE β€” the referenced database has not been opened, internal data structures are corrupted, or some other general failure has occurred. It's giving "everything is on fire" πŸ”₯.
  • RULEXDB_EMALLOC β€” internal memory allocation error. The malloc said no 🫢.
  • RULEXDB_EINVKEY β€” invalid key specified. That key is not it, bestie.
  • RULEXDB_EPARM β€” invalid parameters are specified.

🌈 SEE ALSO 🌈

rulexdb_classify(3), rulexdb_close(3), rulexdb_dataset_name(3), rulexdb_discard_dictionary(3), rulexdb_discard_ruleset(3), rulexdb_fetch_rule(3), rulexdb_lexbase(3), rulexdb_load_ruleset(3), rulexdb_open(3), rulexdb_remove_item(3), rulexdb_remove_rule(3), rulexdb_remove_this_item(3), rulexdb_retrieve_item(3), rulexdb_seq(3), rulexdb_subscribe_item(3), rulexdb_subscribe_rule(3)

Go read the whole friend group, they're all connected, iykyk πŸ’œ


🫢 AUTHOR 🫢

Igor B. Poretsky <poretsky@mlbox.ru> β€” thank you for your service, king πŸ‘‘


and that's the whole page, bestie ✨ this one's from February 20, 2012, and it lives under RULEXDB_SEARCH(3) β€” now go forth and search those words, no cap πŸ’–

πŸ“¦ where this page comes from