// Path: src/main/java/vn/vitk/util/SparkContextFactory.java
// public class SparkContextFactory {
// 	private static volatile JavaSparkContext jsc = null; 
// 	
// 	private SparkContextFactory() {}
// 	
// 	public static JavaSparkContext create(String appName, String master) {
// 		if (jsc == null) {
// 			synchronized (SparkContextFactory.class) {
// 				if (jsc == null) {
// 					SparkConf sc = new SparkConf().setAppName(appName).setMaster(master);
// 					jsc = new JavaSparkContext(sc);
// 				}
// 			}
// 		}
// 		return jsc;
// 	}
// 
// 	public static JavaSparkContext create(String master) {
// 		if (jsc == null) {
// 			synchronized (SparkContextFactory.class) {
// 				if (jsc == null) {
// 					SparkConf sc = new SparkConf()
// 						.setAppName("vn.vitk")
// 						.setMaster(master);
// 					jsc = new JavaSparkContext(sc);
// 				}
// 			}
// 		}
// 		return jsc;
// 	}
// 	
// 	public static JavaSparkContext create() {
// 		if (jsc == null) {
// 			synchronized (SparkContextFactory.class) {
// 				if (jsc == null) {
// 					SparkConf sc = new SparkConf()
// 						.setAppName("vn.vitk")
// 						.setMaster("local[*]");
// 					jsc = new JavaSparkContext(sc);
// 				}
// 			}
// 		}
// 		return jsc;
// 	}
// }


import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.regex.Pattern;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.ml.Pipeline;
import org.apache.spark.ml.PipelineModel;
import org.apache.spark.ml.PipelineStage;
import org.apache.spark.ml.classification.LogisticRegression;
import org.apache.spark.ml.classification.LogisticRegressionModel;
import org.apache.spark.ml.classification.LogisticRegressionTrainingSummary;
import org.apache.spark.ml.evaluation.MulticlassClassificationEvaluator;
import org.apache.spark.ml.feature.HashingTF;
import org.apache.spark.ml.feature.Tokenizer;
import org.apache.spark.sql.DataFrame;
import org.apache.spark.sql.SQLContext;
import vn.vitk.util.SparkContextFactory;
package vn.vitk.tok;




/**
 * @author Phuong LE-HONG, <phuonglh@gmail.com>
 * <p>
 * Apr 25, 2016, 4:51:27 PM
 * <p>
 * Whitespace classifier with logistic regression.
 */
public class WhitespaceClassifier implements Serializable {
	private static final long serialVersionUID = 3100732272743758977L;
// Path: src/main/java/vn/vitk/util/SparkContextFactory.java
// public class SparkContextFactory {
// 	private static volatile JavaSparkContext jsc = null; 
// 	
// 	private SparkContextFactory() {}
// 	
// 	public static JavaSparkContext create(String appName, String master) {
// 		if (jsc == null) {
// 			synchronized (SparkContextFactory.class) {
// 				if (jsc == null) {
// 					SparkConf sc = new SparkConf().setAppName(appName).setMaster(master);
// 					jsc = new JavaSparkContext(sc);
// 				}
// 			}
// 		}
// 		return jsc;
// 	}
// 
// 	public static JavaSparkContext create(String master) {
// 		if (jsc == null) {
// 			synchronized (SparkContextFactory.class) {
// 				if (jsc == null) {
// 					SparkConf sc = new SparkConf()
// 						.setAppName("vn.vitk")
// 						.setMaster(master);
// 					jsc = new JavaSparkContext(sc);
// 				}
// 			}
// 		}
// 		return jsc;
// 	}
// 	
// 	public static JavaSparkContext create() {
// 		if (jsc == null) {
// 			synchronized (SparkContextFactory.class) {
// 				if (jsc == null) {
// 					SparkConf sc = new SparkConf()
// 						.setAppName("vn.vitk")
// 						.setMaster("local[*]");
// 					jsc = new JavaSparkContext(sc);
// 				}
// 			}
// 		}
// 		return jsc;
// 	}
// }


// Path: src/main/java/vn/vitk/tok/WhitespaceClassifier.java
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.regex.Pattern;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.ml.Pipeline;
import org.apache.spark.ml.PipelineModel;
import org.apache.spark.ml.PipelineStage;
import org.apache.spark.ml.classification.LogisticRegression;
import org.apache.spark.ml.classification.LogisticRegressionModel;
import org.apache.spark.ml.classification.LogisticRegressionTrainingSummary;
import org.apache.spark.ml.evaluation.MulticlassClassificationEvaluator;
import org.apache.spark.ml.feature.HashingTF;
import org.apache.spark.ml.feature.Tokenizer;
import org.apache.spark.sql.DataFrame;
import org.apache.spark.sql.SQLContext;
import vn.vitk.util.SparkContextFactory;

package vn.vitk.tok;




/**
 * @author Phuong LE-HONG, <phuonglh@gmail.com>
 * <p>
 * Apr 25, 2016, 4:51:27 PM
 * <p>
 * Whitespace classifier with logistic regression.
 */
public class WhitespaceClassifier implements Serializable {
	private static final long serialVersionUID = 3100732272743758977L;
	private transient JavaSparkContext jsc = SparkContextFactory.create();