// Path: src/main/java/uk/ac/shef/dcs/oak/jate/JATEException.java
// public class JATEException extends Exception {
// 	private static final long serialVersionUID = -4511571544868986419L;
// 
// 	public JATEException(String exception){
// 		super(exception);
// 	}
// 
// 	public JATEException(Exception e){
// 		super(e);
// 	}
// 
// 	public JATEException(String exception, Throwable cause){
// 		super(exception, cause);
// 	}
// }


import uk.ac.shef.dcs.oak.jate.JATEException;
import uk.ac.shef.dcs.oak.jate.model.Term;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

package uk.ac.shef.dcs.oak.jate.core.algorithm;



/**
 * An implementation of the GlossEx term recognition algorithm. See Kozakov, et. al 2004, <i>
 * Glossary extraction and utilization in the information search and delivery system for IBM Technical Support</i>
 *. This is the implementation of the scoring formula <b>only</b>, and does not include the filtering algorithm as mentioned
 * in the paper.
 * <p>
 * In the equation C(T) = a* TD(T) + B*TC(T), default a=0.2, B = 0.8.
 * </p>
 *
 * You might need to modify the value of B by increasing it substaintially when the reference corpus is relatively
 * much bigger than the target corpus, such as the BNC corpus. For details, please refer to the paper.
 *
 * @author <a href="mailto:z.zhang@dcs.shef.ac.uk">Ziqi Zhang</a>
 */




public class GlossExAlgorithm implements Algorithm {

	private final double _alpha;
	private final double _beta;

	public GlossExAlgorithm(){
		this(0.2,0.8);
	}

	public GlossExAlgorithm(double alpha, double beta){
		_alpha = alpha;
		_beta = beta;
	}

	public Term[] execute(AbstractFeatureWrapper store) throws JATEException {
		if (!(store instanceof GlossExFeatureWrapper)) throw new JATEException("" +
				"Required: GlossExFeatureWrapper");
		GlossExFeatureWrapper gFeatureStore = (GlossExFeatureWrapper) store;
		Set<Term> result = new HashSet<Term>();


// Path: src/main/java/uk/ac/shef/dcs/oak/jate/JATEException.java
// public class JATEException extends Exception {
// 	private static final long serialVersionUID = -4511571544868986419L;
// 
// 	public JATEException(String exception){
// 		super(exception);
// 	}
// 
// 	public JATEException(Exception e){
// 		super(e);
// 	}
// 
// 	public JATEException(String exception, Throwable cause){
// 		super(exception, cause);
// 	}
// }


// Path: src/main/java/uk/ac/shef/dcs/oak/jate/core/algorithm/GlossExAlgorithm.java
import uk.ac.shef.dcs.oak.jate.JATEException;
import uk.ac.shef.dcs.oak.jate.model.Term;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

package uk.ac.shef.dcs.oak.jate.core.algorithm;



/**
 * An implementation of the GlossEx term recognition algorithm. See Kozakov, et. al 2004, <i>
 * Glossary extraction and utilization in the information search and delivery system for IBM Technical Support</i>
 *. This is the implementation of the scoring formula <b>only</b>, and does not include the filtering algorithm as mentioned
 * in the paper.
 * <p>
 * In the equation C(T) = a* TD(T) + B*TC(T), default a=0.2, B = 0.8.
 * </p>
 *
 * You might need to modify the value of B by increasing it substaintially when the reference corpus is relatively
 * much bigger than the target corpus, such as the BNC corpus. For details, please refer to the paper.
 *
 * @author <a href="mailto:z.zhang@dcs.shef.ac.uk">Ziqi Zhang</a>
 */




public class GlossExAlgorithm implements Algorithm {

	private final double _alpha;
	private final double _beta;

	public GlossExAlgorithm(){
		this(0.2,0.8);
	}

	public GlossExAlgorithm(double alpha, double beta){
		_alpha = alpha;
		_beta = beta;
	}

	public Term[] execute(AbstractFeatureWrapper store) throws JATEException {
		if (!(store instanceof GlossExFeatureWrapper)) throw new JATEException("" +
				"Required: GlossExFeatureWrapper");
		GlossExFeatureWrapper gFeatureStore = (GlossExFeatureWrapper) store;
		Set<Term> result = new HashSet<Term>();


        double totalCorpusTermFreq = gFeatureStore.getTotalCorpusTermFreq();
