package morphology.parser; import java.util.regex.*; /** * Encapsulation of transducer rules. * * Project: NGSLT --> NLP --> Words --> Assignment #1 * @author Normunds Grūzītis, Gunta Nešpore, Baiba Saulīte * @version February-March 2006 */ public class RegExRule { private String pIf; private String pThen; private int order; /** * Constructor. * @param r_if pattern of recognizer. * @param r_then pattern of transducer. */ public RegExRule(int order, String r_if, String r_then) { try { //Test. Pattern.compile(r_if); Pattern.compile(r_then); pIf = r_if; pThen = r_then; this.order = order; } catch (PatternSyntaxException e) { pIf = ""; pThen = ""; } } /** * Gets indication at which stage to apply the rule. * @return number of order. */ public int getOrder() { return order; } /** * Gets rule-recognizer. * @return non-compiled pattern. */ public String getIF() { return pIf; } /** * Gets compiled rule-transducer. * @return non-compiled pattern. */ public String getTHEN() { return pThen; } }