package com.grayben.riskExtractor.htmlScorer.partScorers;


import java.util.function.Function;

/**
 * Element scorer interface. Provide an implementing class to
 * {@link com.grayben.riskExtractor.htmlScorer.ScoringAndFlatteningNodeVisitor}.
 * <p>
 * This interface contains a single method that takes an {@link org.jsoup.nodes.Element} and returns a score.
 * @author beng
 *
 */
public abstract class Scorer<T> implements Function<T, Integer>{

    private String scoreLabel;

    public final static int DEFAULT_SCORE = 0;

    protected Scorer(String scoreLabel){
        this.scoreLabel = scoreLabel;
    }
	
	/**
	 * 
	 * @param input the Element to score
	 * @return the score of element
	 */
	public int score(T input){
        return this.apply(input);
    }

    public String getScoreLabel(){
        return this.scoreLabel;
    }
}

@@ -336,16 +336,19 @@
 ent%7D and
+%0A *
  returns
@@ -364,23 +364,40 @@
 %0A * 
-@author beng%0A *
+%3Cp%3E%0A * Created by Ben Gray, 2015
 %0A */
@@ -471,83 +471,488 @@
     
-private String scoreLabel;%0A%0A    public final static int DEFAULT_SCORE = 0;%0A
+/**%0A     * The string (uniquely) labelling this class.%0A     * %3Cp%3E%0A     * Used to identify this class in a collection of %7B@link Scorer%7Ds.%0A     */%0A    private String scoreLabel;%0A%0A    /**%0A     * The score to be returned when the scorer cannot explicitly determine%0A     * a score for the argument.%0A     */%0A    public final static int DEFAULT_SCORE = 0;%0A%0A    /**%0A     * Construct a scorer with the specified name.%0A     * @param scoreLabel the class-unique label for this scorer%0A     */
 %0A   
@@ -1044,16 +1044,57 @@
 /**%0A%09 * 
+Determine a score for the argument object
 %0A%09 * @pa
@@ -1107,22 +1107,21 @@
 put the 
-Elemen
+objec
 t to sco
@@ -1152,14 +1152,17 @@
  of 
-elemen
+the objec
 t%0A%09 
@@ -1233,16 +1233,103 @@
 %0A    %7D%0A%0A
+    /**%0A     * @return the class-unique score label passed in at construction.%0A     */%0A
     publ

Document Scorer