Symantec Access Management

 View Only
Expand all | Collapse all

How to use MlLib with Spark to perform Sentiment Analysis using the Stanford library?

  • 1.  How to use MlLib with Spark to perform Sentiment Analysis using the Stanford library?

    Posted Oct 03, 2019 05:28 AM
    Edited by Liana Melissa Oct 03, 2019 05:30 AM
    Hello all,  

    I am trying to access hive tables using SparkSQL. Then will feed to the MlLib of Spark for sentiment analysis. I have check the Stanford NLP library which performs sentiment analysis.

    I am currently stuck at the usage of MlLib of Spark and the training data with the Stanford NLP to give sentiments in Java. I am trying to give the same output as in the demo: http://nlp.stanford.edu:8080/sentiment/rntnDemo.html

    The output must be a tree structure which I can feed to Tableau tool for visualisation. I need to visualise tableau data exactly the way it is in the referenced link.

    Here is the code for accessing the Hive Table:

    import org.apache.spark.sql.SparkSession;

    public class queryhive {

    public static void main(String[] args)
    {


    SparkSession spark = SparkSession
    .builder()
    .appName("Java Spark Hive Example")
    .master("local[*]")
    .config("hive.metastore.uris", "thrift://localhost:9083")
    .enableHiveSupport()
    .getOrCreate();
    try
    {
    Dataset<Row> df = spark.sql("select * from health1 where srno=1");
    df.show();
    }
    catch (Exception AnalysisException)
    {
    System.out.print("\nTable is not found\n");
    }
    }
    }
    }

    Thanks in advance


  • 2.  RE: How to use MlLib with Spark to perform Sentiment Analysis using the Stanford library?
    Best Answer

    Broadcom Employee
    Posted Oct 03, 2019 08:43 AM
    Liana, This question seems to be unrelated to Broadcom's web access management product Layer7 SiteMinder. Others may comment, if they have any input on this.
    best rgds. -Vijay