info.ephyra.util
Class RegexConverter

java.lang.Object
  extended by info.ephyra.util.RegexConverter

public class RegexConverter
extends java.lang.Object

The RegexConverter can be used to tranform a string into a regular expression and to build a query string from a regular expression.

Version:
2006-04-12
Author:
Nico Schlaefer

Constructor Summary
RegexConverter()
           
 
Method Summary
static java.lang.String regexToQueryStr(java.lang.String regex)
          Returns a query string that is derived from the regular expression.
static java.lang.String strToRegex(java.lang.String expr)
          Transform a string into a regular expression that matches the string.
static java.lang.String strToRegex2(java.lang.String expr)
          Transforms a string into a regular expression that describes a regular expression that matches the string by applying the method strToRegex() twice.
static java.lang.String strToRegexWithBounds(java.lang.String expr)
          Transforms a string into a regular expressions and adds word boundaries if the first/last character is a word character.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegexConverter

public RegexConverter()
Method Detail

strToRegex

public static java.lang.String strToRegex(java.lang.String expr)
Transform a string into a regular expression that matches the string. This is done by replacing all metacharacters 'C' by '\\C'.

Parameters:
expr - a string
Returns:
a regular expression that matches the string

strToRegex2

public static java.lang.String strToRegex2(java.lang.String expr)
Transforms a string into a regular expression that describes a regular expression that matches the string by applying the method strToRegex() twice.

Parameters:
expr - a string
Returns:
a regular expression that describes a regular expression that matches the string

strToRegexWithBounds

public static java.lang.String strToRegexWithBounds(java.lang.String expr)
Transforms a string into a regular expressions and adds word boundaries if the first/last character is a word character.

Parameters:
expr - a string
Returns:
a regular expression with word boundaries

regexToQueryStr

public static java.lang.String regexToQueryStr(java.lang.String regex)
Returns a query string that is derived from the regular expression. When learning patterns, this string should be part of the query string to ensure that both the TARGET and the seeked PROPERTY occur in the passages that are obtained from the search engine.