Esempio n. 1
0
 def __init__(self, choose):
     self.stream = tweetFilter('SentimentTest', 'passwd')
     self.tweet = None
     self.bayes = BayesSentiment()
     if choose == "raw":
         self.classifier = self.bayes.getRawClassifier()
     else:
         self.classifier = self.bayes.getClassifer()
Esempio n. 2
0
 def __init__(self, choose):
     self.stream = tweetFilter("SentimentTest", "passwd")
     self.tweet = None
     self.bayes = BayesSentiment()
     if choose == "raw":
         self.classifier = self.bayes.getRawClassifier()
     else:
         self.classifier = self.bayes.getClassifer()
Esempio n. 3
0
class BayesFace(Face):
    def __init__(self, choose):
        self.stream = tweetFilter("SentimentTest", "passwd")
        self.tweet = None
        self.bayes = BayesSentiment()
        if choose == "raw":
            self.classifier = self.bayes.getRawClassifier()
        else:
            self.classifier = self.bayes.getClassifer()

    def idleFunc(self):
        try:
            newTweet = self.stream.next()
            self.tweet = self.bayes.rawClassify(newTweet)
            if self.tweet != None:
                glutPostRedisplay()
        except Exception as e:
            print(e)
            return

    def drawScene(self):
        glMatrixMode(GL_MODELVIEW)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        glPushMatrix()

        # glScalef(.2, .2, .2)
        # glRotatef(90, 0, 0, 1)
        glRasterPos2f(-0.5, 1)
        glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, ord(":"))
        glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, ord("-"))
        if self.tweet[0] == "positive":
            glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, ord(")"))
        else:
            glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, ord("("))
        glPopMatrix()

        if self.tweet != None:
            self.printText(self.tweet[1])

        glFlush()
        glutSwapBuffers()
Esempio n. 4
0
class BayesFace(Face):
    def __init__(self, choose):
        self.stream = tweetFilter('SentimentTest', 'passwd')
        self.tweet = None
        self.bayes = BayesSentiment()
        if choose == "raw":
            self.classifier = self.bayes.getRawClassifier()
        else:
            self.classifier = self.bayes.getClassifer()

    def idleFunc(self):
        try:
            newTweet = self.stream.next()
            self.tweet = self.bayes.rawClassify(newTweet)
            if self.tweet != None:
                glutPostRedisplay()
        except Exception as e:
            print(e)
            return

    def drawScene(self):
        glMatrixMode(GL_MODELVIEW)
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        glPushMatrix()

        #glScalef(.2, .2, .2)
        #glRotatef(90, 0, 0, 1)
        glRasterPos2f(-0.5, 1)
        glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, ord(':'))
        glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, ord('-'))
        if self.tweet[0] == "positive":
            glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, ord(')'))
        else:
            glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, ord('('))
        glPopMatrix()

        if self.tweet != None:
            self.printText(self.tweet[1])

        glFlush()
        glutSwapBuffers()
Esempio n. 5
0
	def __init__(self):
		self.stream = tweetFilter('SentimentTest', 'passwd')
		self.tweet = None
		self.bayes = BayesSentiment()
		self.classifier = self.bayes.getRawClassifier()