Ejemplo n.º 1
0
class PythonServiceServer:
    def __init__(self):
        self.Review = Review(reviewModel)
        self.Sentiment = Sentiment(reviewModel)

    #return positive(1), negative(-1) or neutral(0) sentiment
    def getSentiment(self, content):
        func = "getSentiment"
        try:
            res = self.Sentiment.predict(self.Review, str(content.strip()))
            print res
        except Exception as e:
            logging.error("Error: host: %s \t func: %s \t content: %s \t ",
                          self.host, func, content)
            res = 0
        #logging.info("host: %s \t func: %s \t content: %s \t result: %s ",self.host, func, content, res)
        return res

    #return the degree various from 0 to 1 about bad review to good review
    def getReview(self, content):
        func = "getReview"
        try:
            content = "".join(content.split("\n"))
            res = self.Review.predictPraise(str(content.strip()))
        except Exception as e:
            logging.error("Error: host: %s \t func: %s \t content: %s \t ",
                          self.host, func, content)
            res = 0
        #logging.info("host: %s \t func: %s \t content: %s \t result: %s ",self.host, func, content, res)
        return res
Ejemplo n.º 2
0
class PythonServiceServer:
     def __init__(self):
         self.Review = Review(reviewModel)
         self.Sentiment = Sentiment(reviewModel)

     #return positive(1), negative(-1) or neutral(0) sentiment
     def getSentiment(self, content):
        func = "getSentiment"
        try:
            res = self.Sentiment.predict(self.Review, str(content.strip()))
            print res
        except Exception as e:
            logging.error("Error: host: %s \t func: %s \t content: %s \t ",self.host, func, content)
            res = 0
        #logging.info("host: %s \t func: %s \t content: %s \t result: %s ",self.host, func, content, res)
        return res

     #return the degree various from 0 to 1 about bad review to good review
     def getReview(self, content):
        func = "getReview"
        try:
            content = "".join(content.split("\n"))
            res = self.Review.predictPraise(str(content.strip()))
        except Exception as e:
            logging.error("Error: host: %s \t func: %s \t content: %s \t ",self.host, func, content)
            res = 0
        #logging.info("host: %s \t func: %s \t content: %s \t result: %s ",self.host, func, content, res)
        return res
Ejemplo n.º 3
0
 def __init__(self):
     self.Review = Review(reviewModel)
     self.Sentiment = Sentiment(reviewModel)
Ejemplo n.º 4
0
 def __init__(self):
     self.Review = Review(reviewModel)
     self.Sentiment = Sentiment(reviewModel)