Heuristics
3
REDLAND Library

# Heuristics

Utility heuristic functions.

## Synopsis

    char*               librdf_heuristic_gen_name           (const char *name);
    int                 librdf_heuristic_is_blank_node      (const char *node);
    const char*         librdf_heuristic_get_blank_node     (const char *node);
    int                 librdf_heuristic_object_is_literal  (const char *object);

## Description

Various utility functions for performing heuristics such as generating a name, guessing if a string is a URI or RDF literal.

## Details

### librdf_heuristic_gen_name ()

    char*               librdf_heuristic_gen_name           (const char *name);

Generate a new name from an existing name.

Adds an integer or increases the integer at the end of the name in order to generate a new one

`name` :

  the name

Returns :

  a new name or NULL on failure

### librdf_heuristic_is_blank_node ()

    int                 librdf_heuristic_is_blank_node      (const char *node);

Try to guess if an node string is a blank node identifier.

The guessing is done by assuming the object is a blank node if it matches ^_: like N-Triples, N3 and related.

`node` :

  string object to guess type

Returns :

  non 0 if node is probably a blank node identifier

### librdf_heuristic_get_blank_node ()

    const char*         librdf_heuristic_get_blank_node     (const char *node);

Get a blank node identifier from a node string.

Picks the blank node identifier out of a string. Looks for things like _:ABC

`node` :

  string object to guess type

Returns :

  the blank node identifer string or NULL if the node does not seem to be a blank node identifier

### librdf_heuristic_object_is_literal ()

    int                 librdf_heuristic_object_is_literal  (const char *object);

Try to guess if an object string is a literal or a resource.

The guessing is done by assuming the object is a URL if it matches ^[`isalnum()`]+:[^`isblank()`]+$

This will be fooled by literals of form 'thing:non-blank-thing' but is good enough.

`object` :

  string object to guess type

Returns :

  non 0 if object is probably a literal