package com.grayben.riskExtractor.htmlScorer.partScorers.elementScorers;

import com.grayben.riskExtractor.htmlScorer.partScorers.Scorer;
import com.grayben.riskExtractor.htmlScorer.partScorers.tagScorers.TagSegmentationScorer;
import org.jsoup.nodes.Element;
import org.jsoup.parser.Tag;

/**
 * Score the segmentation of an {@link org.jsoup.nodes.Element} based upon the {@link org.jsoup.parser.Tag} it contains.
 */
public class SegmentationElementScorer extends Scorer<Element> {

	public final static String SCORE_LABEL = "element-segmentation";

	Scorer<Tag> tagScorer;

    public Scorer<Tag> getTagScorer() {
        return tagScorer;
    }

    public SegmentationElementScorer(TagSegmentationScorer tagScorer){
		super(SCORE_LABEL);
		this.tagScorer = tagScorer;
	}

	private void validateScoreInput(Element input){
		if (input == null){
			throw new NullPointerException(
					"The input cannot be null"
			);
		}
		if(input.attributes() == null){
			throw new NullPointerException(
					"the input.attributes cannot be null"
			);
		}
	}

	@Override
	public Integer apply(Element input) {
		validateScoreInput(input);
		int score = tagScorer.score(input.tag());
		return score;
	}
}

@@ -408,16 +408,53 @@
 ntains.%0A
+ * %3Cp%3E%0A * Created by Ben Gray, 2015.%0A
  */%0Apubl
@@ -519,172 +519,611 @@
  %7B%0A%0A
-%09public final static String SCORE_LABEL = %22element-segmentation%22;%0A%0A%09Scorer%3CTag%3E tagScorer;%0A%0A    public Scorer%3CTag%3E getTagScorer() %7B%0A        return tagScorer;%0A    %7D%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%09public final static String SCORE_LABEL = %22element-segmentation%22;%0A%0A    /**%0A     * The delegate tag scorer for this object to use in scoring elements.%0A     */%0A%09Scorer%3CTag%3E tagScorer;%0A%0A    /**%0A     * @return the delegate %7B@link Scorer%7D used by this object.%0A     */%0A    public Scorer%3CTag%3E getTagScorer() %7B%0A        return tagScorer;%0A    %7D%0A%0A    /**%0A     * Constructor accepting a delegate scorer.%0A     * @param tagScorer the delegate tag scorer to use%0A     */
 %0A   
@@ -1246,16 +1246,74 @@
 er;%0A%09%7D%0A%0A
+    /**%0A     * @param input the input to validate%0A     */%0A
 %09private
@@ -1578,16 +1578,264 @@
 %09%09%7D%0A%09%7D%0A%0A
+    /**%0A     * Score the specified element.%0A     * @param input the element to score%0A     * @return the score of the specified element; this is the highest score given by the delegate scorers%0A     * specified at construction of this object%0A     */%0A
 %09@Overri

Document SegmentationElementScorer