// 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/util/counter/WordCounter.java
// public class WordCounter {
// 
// 	public WordCounter(){
// 	}
// 
// 	/**
// 	 * Count number of words in a corpus, delimited by a space character
// 	 * @param c
// 	 * @return
// 	 */
// 	public int countWords(final Corpus c){
// 		int total=0;
// 		for(Document doc:c){
// 			StringTokenizer tokenizer = new StringTokenizer(doc.getContent().replaceAll("\\s+"," ")
// 					.replaceAll("\\s+"," ")," ");
// 			total+=tokenizer.countTokens();
// 		}
// 		return total;
// 	}
// 
// 	/**
// 	 * Count number of words in a document, delimited by a space character
// 	 * @param d
// 	 * @return
// 	 */
// 	public int countWords(final Document d){
// 		
// 		
// 		/*StringTokenizer tokenizer = new StringTokenizer(d.getContent().replaceAll("\\s+"," ")
// 					.replaceAll("\\s+"," ")," ");
// 		*/
// 		//modified part
// 		
// 		StringTokenizer tokenizer = new StringTokenizer(d.getContent(), "\r\n|\n");
// 		
// 		return tokenizer.countTokens();			
// 	}
// 
// 	/**
// 	 * Main testing method.
// 	 * @param args args[0] is the path to directory containing files
// 	 */
// 	public static void main(String[] args) {
// 		File targetFolder = new File(args[0]);
//       	File[] files = targetFolder.listFiles();
// 		if ( files == null ) {
// 			System.err.println( "Unable to find files in " + args[0] );
// 			return;
// 		}
// 		Corpus c = new CorpusImpl();
//       	for (File f : files) {
// 	      try {
// 		      c.add(new DocumentImpl(f.toURI().toURL()));
// 	      } catch (MalformedURLException e) {
// 		      e.printStackTrace();
// 	      }
//       	}//for
// 
// 		System.out.println(new WordCounter().countWords(c));
// 	}
// }


import uk.ac.shef.dcs.oak.jate.JATEException;
import uk.ac.shef.dcs.oak.jate.core.feature.indexer.GlobalIndex;
import uk.ac.shef.dcs.oak.jate.util.control.Normalizer;
import uk.ac.shef.dcs.oak.jate.util.counter.TermFreqCounter;
import uk.ac.shef.dcs.oak.jate.util.counter.WordCounter;

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


/**
 * Feature builder that builds a feature from a GlobalIndex
 *
 * @author <a href="mailto:z.zhang@dcs.shef.ac.uk">Ziqi Zhang</a>
 */



public abstract class AbstractFeatureBuilder {

	protected final TermFreqCounter _termFreqCounter;
	protected final Normalizer _normaliser;
	protected final WordCounter _wordCounter;

	/**
	 * Creates an instance
	 *
	 * @param counter1   an instance of term frequency counter
	 * @param counter2   an instance of word counter
	 * @param normaliser an instance of Normalizer, which returns a candidate term to its canonical form
	 */
	public AbstractFeatureBuilder(TermFreqCounter counter1, WordCounter counter2, Normalizer normaliser) {
		_termFreqCounter = counter1;
		_wordCounter = counter2;
		_normaliser = normaliser;
	}


// 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/util/counter/WordCounter.java
// public class WordCounter {
// 
// 	public WordCounter(){
// 	}
// 
// 	/**
// 	 * Count number of words in a corpus, delimited by a space character
// 	 * @param c
// 	 * @return
// 	 */
// 	public int countWords(final Corpus c){
// 		int total=0;
// 		for(Document doc:c){
// 			StringTokenizer tokenizer = new StringTokenizer(doc.getContent().replaceAll("\\s+"," ")
// 					.replaceAll("\\s+"," ")," ");
// 			total+=tokenizer.countTokens();
// 		}
// 		return total;
// 	}
// 
// 	/**
// 	 * Count number of words in a document, delimited by a space character
// 	 * @param d
// 	 * @return
// 	 */
// 	public int countWords(final Document d){
// 		
// 		
// 		/*StringTokenizer tokenizer = new StringTokenizer(d.getContent().replaceAll("\\s+"," ")
// 					.replaceAll("\\s+"," ")," ");
// 		*/
// 		//modified part
// 		
// 		StringTokenizer tokenizer = new StringTokenizer(d.getContent(), "\r\n|\n");
// 		
// 		return tokenizer.countTokens();			
// 	}
// 
// 	/**
// 	 * Main testing method.
// 	 * @param args args[0] is the path to directory containing files
// 	 */
// 	public static void main(String[] args) {
// 		File targetFolder = new File(args[0]);
//       	File[] files = targetFolder.listFiles();
// 		if ( files == null ) {
// 			System.err.println( "Unable to find files in " + args[0] );
// 			return;
// 		}
// 		Corpus c = new CorpusImpl();
//       	for (File f : files) {
// 	      try {
// 		      c.add(new DocumentImpl(f.toURI().toURL()));
// 	      } catch (MalformedURLException e) {
// 		      e.printStackTrace();
// 	      }
//       	}//for
// 
// 		System.out.println(new WordCounter().countWords(c));
// 	}
// }


// Path: src/main/java/uk/ac/shef/dcs/oak/jate/core/feature/AbstractFeatureBuilder.java
import uk.ac.shef.dcs.oak.jate.JATEException;
import uk.ac.shef.dcs.oak.jate.core.feature.indexer.GlobalIndex;
import uk.ac.shef.dcs.oak.jate.util.control.Normalizer;
import uk.ac.shef.dcs.oak.jate.util.counter.TermFreqCounter;
import uk.ac.shef.dcs.oak.jate.util.counter.WordCounter;

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


/**
 * Feature builder that builds a feature from a GlobalIndex
 *
 * @author <a href="mailto:z.zhang@dcs.shef.ac.uk">Ziqi Zhang</a>
 */



public abstract class AbstractFeatureBuilder {

	protected final TermFreqCounter _termFreqCounter;
	protected final Normalizer _normaliser;
	protected final WordCounter _wordCounter;

	/**
	 * Creates an instance
	 *
	 * @param counter1   an instance of term frequency counter
	 * @param counter2   an instance of word counter
	 * @param normaliser an instance of Normalizer, which returns a candidate term to its canonical form
	 */
	public AbstractFeatureBuilder(TermFreqCounter counter1, WordCounter counter2, Normalizer normaliser) {
		_termFreqCounter = counter1;
		_wordCounter = counter2;
		_normaliser = normaliser;
	}


	public abstract AbstractFeature build(GlobalIndex index) throws JATEException;
