Showcasing notebooks and codes of how to use Spark NLP in Python and Scala.
Python Setup
$ java -version
# Java 8 or 11 for Apache Spark 3.x, Java 17 for Apache Spark 4.x
$ conda create -n sparknlp python=3.9 -y
$ conda activate sparknlp
# Apache Spark 3.x (Scala 2.12) -> spark-nlp_2.12
$ pip install spark-nlp==7.0.0 pyspark==3.5.1
# Apache Spark 4.0.0 (Scala 2.13) -> spark-nlp-spark400_2.13
$ pip install spark-nlp==7.0.0 pyspark==4.0.0
# Apache Spark 4.0.1 and later validated Spark 4 versions (Scala 2.13) -> spark-nlp_2.13
$ pip install spark-nlp==7.0.0 pyspark==4.0.1
Google Colab Notebook
Google Colab is perhaps the easiest way to get started with spark-nlp. It requires no installation or setup other than having a Google account.
Run the following code in Google Colab notebook and start using spark-nlp right away.
# This is only to setup PySpark and Spark NLP on Colab
!wget http://setup.johnsnowlabs.com/colab.sh -O - | bash
This script comes with the two options to define pyspark and spark-nlp versions via options:
# -p is for pyspark
# -s is for spark-nlp
# by default they are set to the latest
# Apache Spark 3.x (Scala 2.12) -> spark-nlp_2.12
!bash colab.sh -p 3.5.1 -s 7.0.0
# Apache Spark 4.0.0 (Scala 2.13) -> spark-nlp-spark400_2.13
!bash colab.sh -p 4.0.0 -s 7.0.0
# Apache Spark 4.0.1+ (Scala 2.13) -> spark-nlp_2.13
!bash colab.sh -p 4.0.1 -s 7.0.0
Spark NLP quick start on Google Colab is a live demo on Google Colab that performs named entity recognitions and sentiment analysis by using Spark NLP pretrained pipelines.
<div class=”h3-box” markdown=”1”
Kaggle Kernel
Run the following code in Kaggle Kernel and start using spark-nlp right away.
# Let's setup Kaggle for Spark NLP and PySpark
!wget http://setup.johnsnowlabs.com/kaggle.sh -O - | bash
</div><div class="h3-box" markdown="1">
Notebooks
</div>