// Path: src/main/java/com/davidehrmann/classifier4J/IClassifier.java
// public interface IClassifier<I> {
//     /**
//      * Default value to use if the implementation cannot work out how
//      * well a string matches.
//      */
//     public static double NEUTRAL_PROBABILITY = 0.5d;
// 
//     /**
//      * The minimum likelihood that a string matches
//      */
//     public static double LOWER_BOUND = 0.01d;
// 
//     /**
//      * The maximum likelihood that a string matches
//      */
//     public static double UPPER_BOUND = 0.99d;
// 
//     /**
//      * Default cutoff value used by default implementation of 
//      * isMatch. Any match probability greater than or equal to this
//      * value will be classified as a match. 
//      * 
//      * The value is 0.9d
//      * 
//      */
//     public static double DEFAULT_CUTOFF = 0.9d;
// 
//     /**
//      * 
//      * Sets the cutoff below which the input is not considered a match
//      * 
//      * @param cutoff the level below which isMatch will return false. Should be between 0 and 1.
//      */
//     public void setMatchCutoff(double cutoff);
// 
//     /**
//      *
//      * Function to determine the probability string matches a criteria.
//      *   
//      * @param input the string to classify
//      * @return the likelihood that this string is a match for this net.sf.classifier4j. 1 means 100% likely.
//          *
//          * @throws ClassifierException If a non-recoverable problem occurs
//      */
//     public double classify(I input) throws ClassifierException;
// 
//     /**
//      * 
//      * Function to determine if a string matches a criteria.
//      * 
//      * @param input the string to classify
//      * @return true if the input string has a probability >= the cutoff probability of 
//      * matching
//          *
//          * @throws ClassifierException If a non-recoverable problem occurs
//      */
//     public boolean isMatch(I input) throws ClassifierException;
// 
//     /**
//      * Convenience method which takes a match probability
//      * (calculated by {@link IClassifier#classify(java.lang.String)})
//      * and checks if it would be classified as a match or not
//      * 
//      * @param matchProbability 
//      * @return true if match, false otherwise
//      */
//     public boolean isMatch(double matchProbability);
// }


import junit.textui.TestRunner;
import com.davidehrmann.classifier4j.IClassifier;
import junit.framework.TestCase;


	public void testCalculateProbability() {

		WordProbability wp = null;

		wp = new WordProbability("", 10, 10);
		assertEquals(IClassifier.NEUTRAL_PROBABILITY, wp.getProbability(), 0);

		wp = new WordProbability("", 20, 10);
		assertEquals(0.66, wp.getProbability(), 0.01);

		wp = new WordProbability("", 30, 10);
		assertEquals(0.75, wp.getProbability(), 0);

		wp = new WordProbability("", 10, 20);
		assertEquals(0.33, wp.getProbability(), 0.01);

		wp = new WordProbability("", 10, 30);
		assertEquals(0.25, wp.getProbability(), 0);

		wp = new WordProbability("", 10, 0);
		assertEquals(IClassifier.UPPER_BOUND, wp.getProbability(), 0);

		wp = new WordProbability("", 100, 1);
		assertEquals(IClassifier.UPPER_BOUND, wp.getProbability(), 0);

		wp = new WordProbability("", 1000, 1);
		assertEquals(IClassifier.UPPER_BOUND, wp.getProbability(), 0);

		wp = new WordProbability("", 0, 10);

// Path: src/main/java/com/davidehrmann/classifier4J/IClassifier.java
// public interface IClassifier<I> {
//     /**
//      * Default value to use if the implementation cannot work out how
//      * well a string matches.
//      */
//     public static double NEUTRAL_PROBABILITY = 0.5d;
// 
//     /**
//      * The minimum likelihood that a string matches
//      */
//     public static double LOWER_BOUND = 0.01d;
// 
//     /**
//      * The maximum likelihood that a string matches
//      */
//     public static double UPPER_BOUND = 0.99d;
// 
//     /**
//      * Default cutoff value used by default implementation of 
//      * isMatch. Any match probability greater than or equal to this
//      * value will be classified as a match. 
//      * 
//      * The value is 0.9d
//      * 
//      */
//     public static double DEFAULT_CUTOFF = 0.9d;
// 
//     /**
//      * 
//      * Sets the cutoff below which the input is not considered a match
//      * 
//      * @param cutoff the level below which isMatch will return false. Should be between 0 and 1.
//      */
//     public void setMatchCutoff(double cutoff);
// 
//     /**
//      *
//      * Function to determine the probability string matches a criteria.
//      *   
//      * @param input the string to classify
//      * @return the likelihood that this string is a match for this net.sf.classifier4j. 1 means 100% likely.
//          *
//          * @throws ClassifierException If a non-recoverable problem occurs
//      */
//     public double classify(I input) throws ClassifierException;
// 
//     /**
//      * 
//      * Function to determine if a string matches a criteria.
//      * 
//      * @param input the string to classify
//      * @return true if the input string has a probability >= the cutoff probability of 
//      * matching
//          *
//          * @throws ClassifierException If a non-recoverable problem occurs
//      */
//     public boolean isMatch(I input) throws ClassifierException;
// 
//     /**
//      * Convenience method which takes a match probability
//      * (calculated by {@link IClassifier#classify(java.lang.String)})
//      * and checks if it would be classified as a match or not
//      * 
//      * @param matchProbability 
//      * @return true if match, false otherwise
//      */
//     public boolean isMatch(double matchProbability);
// }


// Path: src/test/java/com/davidehrmann/classifier4J/bayesian/WordProbabilityTest.java
import junit.textui.TestRunner;
import com.davidehrmann.classifier4j.IClassifier;
import junit.framework.TestCase;


	public void testCalculateProbability() {

		WordProbability wp = null;

		wp = new WordProbability("", 10, 10);
		assertEquals(IClassifier.NEUTRAL_PROBABILITY, wp.getProbability(), 0);

		wp = new WordProbability("", 20, 10);
		assertEquals(0.66, wp.getProbability(), 0.01);

		wp = new WordProbability("", 30, 10);
		assertEquals(0.75, wp.getProbability(), 0);

		wp = new WordProbability("", 10, 20);
		assertEquals(0.33, wp.getProbability(), 0.01);

		wp = new WordProbability("", 10, 30);
		assertEquals(0.25, wp.getProbability(), 0);

		wp = new WordProbability("", 10, 0);
		assertEquals(IClassifier.UPPER_BOUND, wp.getProbability(), 0);

		wp = new WordProbability("", 100, 1);
		assertEquals(IClassifier.UPPER_BOUND, wp.getProbability(), 0);

		wp = new WordProbability("", 1000, 1);
		assertEquals(IClassifier.UPPER_BOUND, wp.getProbability(), 0);

		wp = new WordProbability("", 0, 10);

		assertEquals(IClassifier.LOWER_BOUND, wp.getProbability(), 0);
