// Path: src/main/java/eu/socialsensor/focused/crawler/utils/Image.java
// public class Image implements Comparable<Image> {
// 	private final String src;
// 	private final String width;
// 	private final String height;
// 	private final String alt;
// 	private final int area;
// 
// 	public Image(final String src, final String width, final String height, final String alt) {
// 		this.src = src;
// 		if(src == null) {
// 			throw new NullPointerException("src attribute must not be null");
// 		}
// 		this.width = nullTrim(width);
// 		this.height = nullTrim(height);
// 		this.alt = nullTrim(alt);
// 		
// 		if(width != null && height != null) {
// 			int a;
// 			try {
// 				a = Integer.parseInt(width) * Integer.parseInt(height);
// 			} catch(NumberFormatException e) {
// 				a = -1;
// 			}
// 			this.area = a;
// 		} else {
// 			this.area = -1;
// 		}
// 	}
// 
// 	public String getSrc() {
// 		return src;
// 	}
// 
// 	public String getWidth() {
// 		return width;
// 	}
// 
// 	public String getHeight() {
// 		return height;
// 	}
// 
// 	public String getAlt() {
// 		return alt;
// 	}
// 	
// 	private static String nullTrim(String s) {
// 		if(s == null) {
// 			return null;
// 		}
// 		s = s.trim();
// 		if(s.length() == 0) {
// 			return null;
// 		}
// 		return s;
// 	}
// 	
// 	/**
// 	 * Returns the image's area (specified by width * height), or -1 if width/height weren't both specified or could not be parsed.
// 	 * 
// 	 * @return
// 	 */
// 	public int getArea() {
// 		return area;
// 	}
// 	
// 	public String toString() {
// 		return src+"\twidth="+width+"\theight="+height+"\talt="+alt+"\tarea="+area;
// 	}
// 
// 	public int compareTo(Image o) {
// 		if(o == this) {
// 			return 0;
// 		}
// 		if(area > o.area) {
// 			return -1;
// 		} else if(area == o.area) {
// 			return src.compareTo(o.src);
// 		} else {
// 			return 1;
// 		}
// 	}
// }


import java.io.IOException;
import java.io.StringReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.xerces.parsers.AbstractSAXParser;
import org.cyberneko.html.HTMLConfiguration;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import de.l3s.boilerpipe.BoilerpipeExtractor;
import de.l3s.boilerpipe.BoilerpipeProcessingException;
import de.l3s.boilerpipe.document.TextBlock;
import de.l3s.boilerpipe.document.TextDocument;
import de.l3s.boilerpipe.sax.BoilerpipeSAXInput;
import de.l3s.boilerpipe.sax.HTMLDocument;
import de.l3s.boilerpipe.sax.HTMLFetcher;
import eu.socialsensor.focused.crawler.utils.Image;
package eu.socialsensor.focused.crawler.utils;




/**
 * Extracts the images that are enclosed by extracted content. 
 * 
 * @author Christian Kohlschütter
 */
public final class ImageExtractor {
	public static final ImageExtractor INSTANCE = new ImageExtractor();
	
	/**
	 * Returns the singleton instance of {@link ImageExtractor}.
	 * 
	 * @return
	 */
	public static ImageExtractor getInstance() {
		return INSTANCE;
	}

	private ImageExtractor() {
	}

	/**
	 * Processes the given {@link TextDocument} and the original HTML text (as a
	 * String).
	 * 
	 * @param doc
	 *            The processed {@link TextDocument}.
	 * @param origHTML
	 *            The original HTML document.
	 * @return A List of enclosed {@link Image}s
	 * @throws BoilerpipeProcessingException
	 */
// Path: src/main/java/eu/socialsensor/focused/crawler/utils/Image.java
// public class Image implements Comparable<Image> {
// 	private final String src;
// 	private final String width;
// 	private final String height;
// 	private final String alt;
// 	private final int area;
// 
// 	public Image(final String src, final String width, final String height, final String alt) {
// 		this.src = src;
// 		if(src == null) {
// 			throw new NullPointerException("src attribute must not be null");
// 		}
// 		this.width = nullTrim(width);
// 		this.height = nullTrim(height);
// 		this.alt = nullTrim(alt);
// 		
// 		if(width != null && height != null) {
// 			int a;
// 			try {
// 				a = Integer.parseInt(width) * Integer.parseInt(height);
// 			} catch(NumberFormatException e) {
// 				a = -1;
// 			}
// 			this.area = a;
// 		} else {
// 			this.area = -1;
// 		}
// 	}
// 
// 	public String getSrc() {
// 		return src;
// 	}
// 
// 	public String getWidth() {
// 		return width;
// 	}
// 
// 	public String getHeight() {
// 		return height;
// 	}
// 
// 	public String getAlt() {
// 		return alt;
// 	}
// 	
// 	private static String nullTrim(String s) {
// 		if(s == null) {
// 			return null;
// 		}
// 		s = s.trim();
// 		if(s.length() == 0) {
// 			return null;
// 		}
// 		return s;
// 	}
// 	
// 	/**
// 	 * Returns the image's area (specified by width * height), or -1 if width/height weren't both specified or could not be parsed.
// 	 * 
// 	 * @return
// 	 */
// 	public int getArea() {
// 		return area;
// 	}
// 	
// 	public String toString() {
// 		return src+"\twidth="+width+"\theight="+height+"\talt="+alt+"\tarea="+area;
// 	}
// 
// 	public int compareTo(Image o) {
// 		if(o == this) {
// 			return 0;
// 		}
// 		if(area > o.area) {
// 			return -1;
// 		} else if(area == o.area) {
// 			return src.compareTo(o.src);
// 		} else {
// 			return 1;
// 		}
// 	}
// }


// Path: src/main/java/eu/socialsensor/focused/crawler/utils/ImageExtractor.java
import java.io.IOException;
import java.io.StringReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.xerces.parsers.AbstractSAXParser;
import org.cyberneko.html.HTMLConfiguration;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import de.l3s.boilerpipe.BoilerpipeExtractor;
import de.l3s.boilerpipe.BoilerpipeProcessingException;
import de.l3s.boilerpipe.document.TextBlock;
import de.l3s.boilerpipe.document.TextDocument;
import de.l3s.boilerpipe.sax.BoilerpipeSAXInput;
import de.l3s.boilerpipe.sax.HTMLDocument;
import de.l3s.boilerpipe.sax.HTMLFetcher;
import eu.socialsensor.focused.crawler.utils.Image;

package eu.socialsensor.focused.crawler.utils;




/**
 * Extracts the images that are enclosed by extracted content. 
 * 
 * @author Christian Kohlschütter
 */
public final class ImageExtractor {
	public static final ImageExtractor INSTANCE = new ImageExtractor();
	
	/**
	 * Returns the singleton instance of {@link ImageExtractor}.
	 * 
	 * @return
	 */
	public static ImageExtractor getInstance() {
		return INSTANCE;
	}

	private ImageExtractor() {
	}

	/**
	 * Processes the given {@link TextDocument} and the original HTML text (as a
	 * String).
	 * 
	 * @param doc
	 *            The processed {@link TextDocument}.
	 * @param origHTML
	 *            The original HTML document.
	 * @return A List of enclosed {@link Image}s
	 * @throws BoilerpipeProcessingException
	 */
	public List<Image> process(final TextDocument doc,