abstract sclass WordTokRule extends Attractor implements RuleOnTok, RuleOnString { S pattern; // example sentence Set vars; // list of the variable words in the sentence bool debug; transient LS tokPat; // parsed pattern transient SS map; // not null if there is a match *() {} *(S *pattern, S... vars) { this.vars = litciset(vars); } *(S *pattern, Set *vars) {} LS tokPat() { if (tokPat == null) tokPat = wordTok(pattern); ret tokPat; } public bool matches(ExtS s) { process(s); ret matched(); } public bool matches(S s) { process(s); ret matched(); } public void process(ExtS s) { processTok(extLift(s, wordTok(s!)); } public void processTok(Ext tok) { map = nullIfContainsKeysOtherThan(gazelle_zipTwoTokenizationsToMap(tokPat(), tok), vars); if (debug) print(pattern + " + " + join(tok) + " => " + map); } bool matched() { ret map != null; } S getVar(S name) { ret getOrKeep(map, name); } }