@Override
    public TargetRelevance classify(Page page) throws TargetClassifierException {
        boolean matchesAll = true;
        boolean matchesOne = false;
        if(titlePatterns != null && titlePatterns.length > 0) {
            boolean matches = regexMatchesField(page.getParsedData().getTitle(), params.title.boolean_operator, titlePatterns);
            matchesAll = (matchesAll && matches);
            matchesOne = (matchesOne || matches);
            if( matchesOne && OR)   return TargetRelevance.RELEVANT;
            if(!matchesAll && AND)  return TargetRelevance.IRRELEVANT;
        }
        if(urlPatterns != null && urlPatterns.length > 0) {
            boolean matches = regexMatchesField(page.getURL().toString(), params.url.boolean_operator, urlPatterns);
            matchesAll = (matchesAll && matches);
            matchesOne = (matchesOne || matches);
            if( matchesOne && OR)   return TargetRelevance.RELEVANT;
            if(!matchesAll && AND)  return TargetRelevance.IRRELEVANT;
        }
        if(contentPatterns != null && contentPatterns.length > 0) {
            boolean matches = regexMatchesField(page.getContentAsString(), params.content.boolean_operator, contentPatterns);
            matchesAll = (matchesAll && matches);
            matchesOne = (matchesOne || matches);
            if( matchesOne && OR)   return TargetRelevance.RELEVANT;
            if(!matchesAll && AND)  return TargetRelevance.IRRELEVANT;
        }
        if(contentTypePatterns != null && contentTypePatterns.length > 0) {
            boolean matches = regexMatchesField(page.getContentType(), params.content.boolean_operator, contentTypePatterns);
            matchesAll = (matchesAll && matches);
            matchesOne = (matchesOne || matches);
            if( matchesOne && OR)   return TargetRelevance.RELEVANT;
            if(!matchesAll && AND)  return TargetRelevance.IRRELEVANT;
        }

        if(AND)
            return matchesAll ? TargetRelevance.RELEVANT : TargetRelevance.IRRELEVANT;
        else
            return matchesOne ? TargetRelevance.RELEVANT : TargetRelevance.IRRELEVANT;
    }
Classify whether a page is relevant by matching lists of regular expressions against multiples
fields of the web page.
ache/src/main/java/achecrawler/target/classifier/RegexTargetClassifier.java