- Start a new project in IntelliJ or in an IDE of your choice. Make sure the necessary JAR files are included.
- The package statement for the recipe is as follows:
package spark.ml.cookbook.chapter12
- Import the necessary packages for Scala and Spark:
import org.apache.log4j.{Level, Logger}import org.apache.spark.ml.feature.{RegexTokenizer, StopWordsRemover, Word2Vec}import org.apache.spark.sql.{SQLContext, SparkSession}import org.apache.spark.{SparkConf, SparkContext}
- Let us define the location of our book file:
val input = "../data/sparkml2/chapter12/pg62.txt"
- Create a Spark session with configurations using the factory builder pattern:
val spark = SparkSession .builder.master("local[*]") .appName("Word2Vec App")