edu.washington.cs.knowitall.regex.RegularExpressionParsers Maven / Gradle / Ivy
package edu.washington.cs.knowitall.regex;
import edu.washington.cs.knowitall.regex.Expression.BaseExpression;
/**
* Static factories for regular expressions over some basic sequences.
*
* @author Michael Schmitz
*/
class RegularExpressionParsers {
/**
* Regular expressions over words where sequences are string
* representations of words.
*/
public final static RegularExpressionParser word =
new RegularExpressionParser() {
@Override public BaseExpression factory(final String string) {
return new BaseExpression(string) {
@Override public boolean apply(final String token) {
return string.equals(token);
}
};
}
};
/**
* Regular expression over characters, as in java.util.Regex.
*/
public final static RegularExpressionParser character =
new RegularExpressionParser() {
@Override public BaseExpression factory(final String string) {
return new BaseExpression(string) {
@Override public boolean apply(final Character token) {
return string.equals(token.toString());
}
};
}
};
}