示例#1
0
  // public String getSentimentScore(String mainText,String textType)
  public String getSentimentScore(String mainText) {
    try {
      SentiRequestObject obj = new SentiRequestObject();
      obj.setMainText(mainText);
      // obj.setTextType(textType);

      int senti = client.getSentimentScore(obj);
      return ("" + senti);
    } catch (TTransportException e) {
      e.printStackTrace();
      transport.close();
    } catch (TException e) {
      e.printStackTrace();
      transport.close();
    }
    transport.close();
    return "Connection to " + this.ip + ":" + this.port + " failed!";
  }
示例#2
0
  public String getSentimentScore(
      String mainText, String title, String middleParas, String lastPara, int diffBlog) {
    // "diffBlog" parameter can be set with any integer (added as a dummy parameter to support
    // method overloading)
    try {

      SentiRequestObject obj = new SentiRequestObject();
      obj.setMainText(mainText);
      obj.setTextType("blogs_news");
      obj.setTitle(title);
      obj.setMiddleParas(middleParas);
      obj.setLastPara(lastPara);

      int senti = client.getSentimentScore(obj);

      return ("" + senti);

    } catch (TTransportException e) {
      e.printStackTrace();
      transport.close();
    } catch (TException e) {
      e.printStackTrace();
      transport.close();
    }
    transport.close();
    return "Connection to " + this.ip + ":" + this.port + " failed!";
  }
示例#3
0
 public String getSentimentScore(
     String mainText, String title, String topDomain, String subDomain) {
   try {
     SentiRequestObject obj = new SentiRequestObject();
     obj.setMainText(mainText);
     obj.setTextType("reviews");
     obj.setTitle(title);
     obj.setTopDomain(topDomain);
     obj.setSubDomain(subDomain);
     int senti = client.getSentimentScore(obj);
     return ("" + senti);
   } catch (TTransportException e) {
     e.printStackTrace();
     transport.close();
   } catch (TException e) {
     e.printStackTrace();
     transport.close();
   }
   transport.close();
   return "Connection to " + this.ip + ":" + this.port + " failed!";
 }