Skip to content

Commit

Permalink
Fix SparkNLP notebook example (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lothiraldan committed Jun 18, 2024
1 parent 8ab9e78 commit 5dbd01c
Showing 1 changed file with 37 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,8 @@
"metadata": {
"colab": {
"provenance": [],
"collapsed_sections": [
"Kl0UxLzAstRr",
"XkgWO1nEsrIX",
"And0LEcJsnw1",
"izYqvCWvswV9",
"gFoyiY8fs1pH",
"6ShrQ4NKrlU5",
"psAACN7KO8fu",
"8eaOQeZQ_0gj",
"sJZo_mwU-U6e",
"hDJs1HJ03Iff"
],
"toc_visible": true
"toc_visible": true,
"machine_shape": "hm"
},
"kernelspec": {
"name": "python3",
Expand Down Expand Up @@ -66,14 +55,32 @@
},
"source": [
"# This is only to setup PySpark and Spark NLP on Colab\n",
"!wget http://setup.johnsnowlabs.com/colab.sh -O - | bash\n",
"\n",
"!wget http://setup.johnsnowlabs.com/colab.sh -O - | bash"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# Install Spark NLP Display for visualization\n",
"!pip install --ignore-installed spark-nlp-display\n",
"\n",
"%pip install spark-nlp-display"
],
"metadata": {
"id": "XKbZHYav_Ond"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# Installing Comet\n",
"!pip install comet_ml --quiet"
"%pip install comet_ml"
],
"metadata": {
"id": "sXCTHd9N_QWx"
},
"execution_count": null,
"outputs": []
},
Expand Down Expand Up @@ -135,7 +142,7 @@
"id": "W6uDqwwTzTNY"
},
"source": [
"comet_ml.init(project_name=\"sparknlp-demo\")"
"comet_ml.init(project_name=\"comet-example-sparknlp\")"
],
"execution_count": null,
"outputs": []
Expand Down Expand Up @@ -397,8 +404,11 @@
"id": "-oDkX9RtMo1f"
},
"source": [
"import glob\n",
"\n",
"logger = CometLogger()\n",
"logger.log_completed_run(\"./run/MultiClassifierDLApproach_736adb7a5ea5.log\")"
"log_file = glob.glob(\"./run/MultiClassifierDLApproach_*.log\")\n",
"logger.log_completed_run(log_file[0])"
],
"execution_count": null,
"outputs": []
Expand Down Expand Up @@ -797,14 +807,16 @@
"id": "0jEqnP6JBlPK"
},
"source": [
"import pandas as pd\n",
"\n",
"text_list = [\n",
" \"\"\"William Henry Gates III (born October 28, 1955) is an American business magnate, software developer, investor, and philanthropist. He is best known as the co-founder of Microsoft Corporation. During his career at Microsoft, Gates held the positions of chairman, chief executive officer (CEO), president and chief software architect, while also being the largest individual shareholder until May 2014. He is one of the best-known entrepreneurs and pioneers of the microcomputer revolution of the 1970s and 1980s. Born and raised in Seattle, Washington, Gates co-founded Microsoft with childhood friend Paul Allen in 1975, in Albuquerque, New Mexico; it went on to become the world's largest personal computer software company. Gates led the company as chairman and CEO until stepping down as CEO in January 2000, but he remained chairman and became chief software architect. During the late 1990s, Gates had been criticized for his business tactics, which have been considered anti-competitive. This opinion has been upheld by numerous court rulings. In June 2006, Gates announced that he would be transitioning to a part-time role at Microsoft and full-time work at the Bill & Melinda Gates Foundation, the private charitable foundation that he and his wife, Melinda Gates, established in 2000.[9] He gradually transferred his duties to Ray Ozzie and Craig Mundie. He stepped down as chairman of Microsoft in February 2014 and assumed a new post as technology adviser to support the newly appointed CEO Satya Nadella.\"\"\",\n",
" \"\"\"The Mona Lisa is a 16th century oil painting created by Leonardo. It's held at the Louvre in Paris.\"\"\",\n",
" {\n",
" \"text\": \"William Henry Gates III (born October 28, 1955) is an American business magnate, software developer, investor, and philanthropist. He is best known as the co-founder of Microsoft Corporation. During his career at Microsoft, Gates held the positions of chairman, chief executive officer (CEO), president and chief software architect, while also being the largest individual shareholder until May 2014. He is one of the best-known entrepreneurs and pioneers of the microcomputer revolution of the 1970s and 1980s. Born and raised in Seattle, Washington, Gates co-founded Microsoft with childhood friend Paul Allen in 1975, in Albuquerque, New Mexico; it went on to become the world's largest personal computer software company. Gates led the company as chairman and CEO until stepping down as CEO in January 2000, but he remained chairman and became chief software architect. During the late 1990s, Gates had been criticized for his business tactics, which have been considered anti-competitive. This opinion has been upheld by numerous court rulings. In June 2006, Gates announced that he would be transitioning to a part-time role at Microsoft and full-time work at the Bill & Melinda Gates Foundation, the private charitable foundation that he and his wife, Melinda Gates, established in 2000.[9] He gradually transferred his duties to Ray Ozzie and Craig Mundie. He stepped down as chairman of Microsoft in February 2014 and assumed a new post as technology adviser to support the newly appointed CEO Satya Nadella.\"\n",
" },\n",
" {\n",
" \"text\": \"The Mona Lisa is a 16th century oil painting created by Leonardo. It's held at the Louvre in Paris.\"\n",
" },\n",
"]\n",
"\n",
"df = spark.createDataFrame(pd.DataFrame({\"text\": text_list}))\n",
"df = spark.createDataFrame(text_list)\n",
"results = pipeline_model.transform(df)"
],
"execution_count": null,
Expand Down

0 comments on commit 5dbd01c

Please sign in to comment.