Wednesday, December 9, 2009

Full Text Expressions

Many applications need to efficiently search a RDF graph for any statements that contain a set of terms in a literal value. Semantics.SDK and Semantics.Server both provide support for full text expressions to meet this need. In the case of Semantics.Server these full text expressions are evaluated using full text capabilities of Microsoft SQL Server.

Full text expressions are based on the following constructs:

pattern Any simple word match that contains no spaces or punctuation. The matched text must contain the exact word as specified in the pattern.

ex: bluebird
prefix pattern Any valid pattern followed by an asterisk (‘*’). The matched text must contain a word that starts with the specified pattern.

ex: blue*
simple expression A simple expression contains one or more patterns. The matched text must match all the patterns specified.

ex: song bluebird
set expression A set expression contains one or more sets. The matched text must match all the sets in the expression.

ex: {blue red}{large medium}!{dog}
set A set contains one or more patterns delimited by curly braces (‘{}’). The text must match at least one of the patterns in the set.

ex: {blue* red*}
negated set A negated set is a set that is prefixed with an exclamation mark (‘!’). The text must not match any of the patterns in the set.

ex: !{dog cat}

Examples:

The following examples are based on the familiar input string:

“The quick fox jumps over the lazy brown dog.”

Expression Match?
dog laz* yes
{dog laz*}{quick} yes
{dog laz*}!{quick} no
umps no

SPARQL:

The contains function allows you to use a full text expression in a SPARQL query. The example below shows the use of a full text expression in a SPARQL query.

select 1 where {filter(contains("The quick fox jumps over the lazy brown dog.", "dog laz*"))}

0 comments:

Post a Comment