---
name: "rulexdb_search"
section: "3"
platform: "linux"
package: "librulexdb-dev"
version: "3.8.6-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rulexdb_search"
---

# rulexdb\_search(3)

search rulex database for specified word

## 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

The **rulexdb\_search**() function searches the database referenced by *rulexdb* argument and tries to guess pronunciation for the word specified by string pointed by *key* argument according to the acquired info. The resulting string is\
  placed into the buffer pointed by *value* argument. This buffer must have enough space for it. When no useful\
  info is found, the original word is copied to the *value* buffer and **RULEXDB\_SPECIAL** code is returned.

At first search is performed in the **Explicit** dictionary. If it\
  succeeds, the result is returned and procedure exits\
  successfully. Otherwise the word is treated as an implicit form and\
  program tries to guess its base and find it in the **Implicit**\
  dictionary. If this process succeeds, the pronunciation string is\
  constructed according to the acquired data and procedure exits\
  successfully. At last, the word is matched against general rules. If\
  no match succeeds, then program exits with **RULEXDB\_SPECIAL** code, returning the original word as a result.

If this process appears to be not fully unsuccessful and some information was found in the database, then the resulting string is matched against correction rules and the first matched one is applied if any.

The last argument specifies which steps of the described process are to be performed. It consists of the following flags which may be bitwise-*or*'d to form wanted search mode:

- **RULEXDB\_EXCEPTIONS**

  Search the word in the exceptions dictionary.

- **RULEXDB\_FORMS**

  Try to treat specified word as an implicit form.

- **RULEXDB\_RULES**

  Try to apply general rules.

- Zero value (no flags) means that full search (all stages) should be

  performed.

## RETURN VALUE

The **rulexdb\_search**() function returns **RULEXDB\_SUCCESS** which is zero upon success, positive value **RULEXDB\_SPECIAL** when specified word was not found, or negative error code if something is wrong.

## ERRORS

- **RULEXDB\_FAILURE**

  Referenced database has not been opened, internal data structures are corrupted or some other general failure has occurred.

- **RULEXDB\_EMALLOC**

  Internal memory allocation error.

- **RULEXDB\_EINVKEY**

  Invalid key specified.

- **RULEXDB\_EPARM**

  Invalid parameters are specified.

## SEE ALSO

[**rulexdb\_classify**(3)](/rulexdb_classify/3.md), [**rulexdb\_close**(3)](/rulexdb_close/3.md), [**rulexdb\_dataset\_name**(3)](/rulexdb_dataset_name/3.md), [**rulexdb\_discard\_dictionary**(3)](/rulexdb_discard_dictionary/3.md), [**rulexdb\_discard\_ruleset**(3)](/rulexdb_discard_ruleset/3.md), [**rulexdb\_fetch\_rule**(3)](/rulexdb_fetch_rule/3.md), [**rulexdb\_lexbase**(3)](/rulexdb_lexbase/3.md), [**rulexdb\_load\_ruleset**(3)](/rulexdb_load_ruleset/3.md), [**rulexdb\_open**(3)](/rulexdb_open/3.md), [**rulexdb\_remove\_item**(3)](/rulexdb_remove_item/3.md), [**rulexdb\_remove\_rule**(3)](/rulexdb_remove_rule/3.md), [**rulexdb\_remove\_this\_item**(3)](/rulexdb_remove_this_item/3.md), [**rulexdb\_retrieve\_item**(3)](/rulexdb_retrieve_item/3.md), [**rulexdb\_seq**(3)](/rulexdb_seq/3.md), [**rulexdb\_subscribe\_item**(3)](/rulexdb_subscribe_item/3.md), [**rulexdb\_subscribe\_rule**(3)](/rulexdb_subscribe_rule/3.md)

## AUTHOR

Igor B. Poretsky \<poretsky@mlbox.ru\>.
