|
| 1 | +--- |
| 2 | +layout: model |
| 3 | +title: Sentiment Analysis pipeline for English |
| 4 | +author: John Snow Labs |
| 5 | +name: analyze_sentiment |
| 6 | +date: 2023-05-25 |
| 7 | +tags: [open_source, english, analyze_sentiment, pipeline, en] |
| 8 | +task: Named Entity Recognition |
| 9 | +language: en |
| 10 | +edition: Spark NLP 4.4.2 |
| 11 | +spark_version: 3.4 |
| 12 | +supported: true |
| 13 | +annotator: PipelineModel |
| 14 | +article_header: |
| 15 | + type: cover |
| 16 | +use_language_switcher: "Python-Scala-Java" |
| 17 | +--- |
| 18 | + |
| 19 | +## Description |
| 20 | + |
| 21 | +The analyze_sentiment is a pretrained pipeline that we can use to process text with a simple pipeline that performs basic processing steps |
| 22 | +and recognizes entities . |
| 23 | +It performs most of the common text processing tasks on your dataframe |
| 24 | + |
| 25 | +## Predicted Entities |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +{:.btn-box} |
| 30 | +<button class="button button-orange" disabled>Live Demo</button> |
| 31 | +<button class="button button-orange" disabled>Open in Colab</button> |
| 32 | +[Download](https://s3.amazonaws.com/auxdata.johnsnowlabs.com/public/models/analyze_sentiment_en_4.4.2_3.4_1685040876208.zip){:.button.button-orange.button-orange-trans.arr.button-icon} |
| 33 | +[Copy S3 URI](s3://auxdata.johnsnowlabs.com/public/models/analyze_sentiment_en_4.4.2_3.4_1685040876208.zip){:.button.button-orange.button-orange-trans.button-icon.button-copy-s3} |
| 34 | + |
| 35 | +## How to use |
| 36 | + |
| 37 | +<div class="tabs-box" markdown="1"> |
| 38 | +{% include programmingLanguageSelectScalaPythonNLU.html %} |
| 39 | + |
| 40 | +```python |
| 41 | + |
| 42 | +from sparknlp.pretrained import PretrainedPipeline |
| 43 | + |
| 44 | +pipeline = PretrainedPipeline('analyze_sentiment', lang = 'en') |
| 45 | + |
| 46 | +result = pipeline.fullAnnotate("""Demonicus is a movie turned into a video game! I just love the story and the things that goes on in the film.It is a B-film ofcourse but that doesn`t bother one bit because its made just right and the music was rad! Horror and sword fight freaks,buy this movie now!""") |
| 47 | + |
| 48 | + |
| 49 | +``` |
| 50 | +```scala |
| 51 | + |
| 52 | +import com.johnsnowlabs.nlp.pretrained.PretrainedPipeline |
| 53 | + |
| 54 | +val pipeline = new PretrainedPipeline("analyze_sentiment", lang = "en") |
| 55 | + |
| 56 | +val result = pipeline.fullAnnotate("""Demonicus is a movie turned into a video game! I just love the story and the things that goes on in the film.It is a B-film ofcourse but that doesn`t bother one bit because its made just right and the music was rad! Horror and sword fight freaks,buy this movie now!""") |
| 57 | + |
| 58 | +``` |
| 59 | + |
| 60 | +{:.nlu-block} |
| 61 | +```python |
| 62 | + |
| 63 | +import nlu |
| 64 | +text = ["""Demonicus is a movie turned into a video game! I just love the story and the things that goes on in the film.It is a B-film ofcourse but that doesn`t bother one bit because its made just right and the music was rad! Horror and sword fight freaks,buy this movie now!"""] |
| 65 | +result_df = nlu.load('en.classify').predict(text) |
| 66 | +result_df |
| 67 | + |
| 68 | +``` |
| 69 | +</div> |
| 70 | + |
| 71 | +<div class="tabs-box" markdown="1"> |
| 72 | +{% include programmingLanguageSelectScalaPythonNLU.html %} |
| 73 | +```python |
| 74 | +from sparknlp.pretrained import PretrainedPipeline |
| 75 | + |
| 76 | +pipeline = PretrainedPipeline('analyze_sentiment', lang = 'en') |
| 77 | + |
| 78 | +result = pipeline.fullAnnotate("""Demonicus is a movie turned into a video game! I just love the story and the things that goes on in the film.It is a B-film ofcourse but that doesn`t bother one bit because its made just right and the music was rad! Horror and sword fight freaks,buy this movie now!""") |
| 79 | +``` |
| 80 | +```scala |
| 81 | +import com.johnsnowlabs.nlp.pretrained.PretrainedPipeline |
| 82 | + |
| 83 | +val pipeline = new PretrainedPipeline("analyze_sentiment", lang = "en") |
| 84 | + |
| 85 | +val result = pipeline.fullAnnotate("""Demonicus is a movie turned into a video game! I just love the story and the things that goes on in the film.It is a B-film ofcourse but that doesn`t bother one bit because its made just right and the music was rad! Horror and sword fight freaks,buy this movie now!""") |
| 86 | +``` |
| 87 | + |
| 88 | +{:.nlu-block} |
| 89 | +```python |
| 90 | +import nlu |
| 91 | +text = ["""Demonicus is a movie turned into a video game! I just love the story and the things that goes on in the film.It is a B-film ofcourse but that doesn`t bother one bit because its made just right and the music was rad! Horror and sword fight freaks,buy this movie now!"""] |
| 92 | +result_df = nlu.load('en.classify').predict(text) |
| 93 | +result_df |
| 94 | +``` |
| 95 | +</div> |
| 96 | + |
| 97 | +## Results |
| 98 | + |
| 99 | +```bash |
| 100 | +Results |
| 101 | + |
| 102 | + |
| 103 | +| | text | sentiment | |
| 104 | +|---:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------| |
| 105 | +| 0 | Demonicus is a movie turned into a video game! I just love the story and the things that goes on in the film.It is a B-film ofcourse but that doesn`t bother one bit because its made just right and the music was rad! Horror and sword fight freaks,buy this movie now! | positive | |
| 106 | +
|
| 107 | +
|
| 108 | +{:.model-param} |
| 109 | +``` |
| 110 | + |
| 111 | +{:.model-param} |
| 112 | +## Model Information |
| 113 | + |
| 114 | +{:.table-model} |
| 115 | +|---|---| |
| 116 | +|Model Name:|analyze_sentiment| |
| 117 | +|Type:|pipeline| |
| 118 | +|Compatibility:|Spark NLP 4.4.2+| |
| 119 | +|License:|Open Source| |
| 120 | +|Edition:|Official| |
| 121 | +|Language:|en| |
| 122 | +|Size:|5.1 MB| |
| 123 | + |
| 124 | +## Included Models |
| 125 | + |
| 126 | +- DocumentAssembler |
| 127 | +- SentenceDetector |
| 128 | +- TokenizerModel |
| 129 | +- NorvigSweetingModel |
| 130 | +- ViveknSentimentModel |
0 commit comments