Ejemplo n.º 1
0
 def __init__(self,
              csv_file=None,
              classifier="twss_classifier.pkl",
              **kwargs):
     if csv_file:
         self.c = csv.writer(open(csv_file, 'wb'))
     else:
         self.c = None
     classifier = os.path.abspath(classifier)
     self.classifier = LoadClassifier(filename=classifier)
     super(TWSSListner, self).__init__(**kwargs)
Ejemplo n.º 2
0
 def __init__(self, csv_file=None, classifier="twss_classifier.pkl", **kwargs):
     if csv_file:
         self.c = csv.writer(open(csv_file, 'wb'))
     else:
         self.c = None
     classifier = os.path.abspath(classifier)
     self.classifier = LoadClassifier(filename=classifier)
     super(TWSSListner, self).__init__(**kwargs)
Ejemplo n.º 3
0
    def __init__(self,
                 csv_files=("general.csv", "twss.csv"),
                 classifier="twss_classifier.pkl",
                 **kwargs):
        classifier = os.path.abspath(classifier)
        self.classifier = LoadClassifier(filename=classifier)

        self.gen_writer = csv.writer(open(csv_files[0], "wb"))
        self.twss_writer = csv.writer(open(csv_files[1], "wb"))

        super(TWSSBuildClassifierListner, self).__init__(**kwargs)
Ejemplo n.º 4
0
class TWSSListner(tweepy.StreamListener):
    def __init__(self, csv_file=None, classifier="twss_classifier.pkl", **kwargs):
        if csv_file:
            self.c = csv.writer(open(csv_file, 'wb'))
        else:
            self.c = None
        classifier = os.path.abspath(classifier)
        self.classifier = LoadClassifier(filename=classifier)
        super(TWSSListner, self).__init__(**kwargs)
    
    def on_status(self, status):
        try:
            print status.text
            cls = self.classifier.classify(word_features(process_string(status.text)))
            if self.c:
                self.c.writerow([cls, status.text, status.text])
        except Exception as e:
            print e
Ejemplo n.º 5
0
class TWSSListner(tweepy.StreamListener):
    def __init__(self,
                 csv_file=None,
                 classifier="twss_classifier.pkl",
                 **kwargs):
        if csv_file:
            self.c = csv.writer(open(csv_file, 'wb'))
        else:
            self.c = None
        classifier = os.path.abspath(classifier)
        self.classifier = LoadClassifier(filename=classifier)
        super(TWSSListner, self).__init__(**kwargs)

    def on_status(self, status):
        try:
            print status.text
            cls = self.classifier.classify(
                word_features(process_string(status.text)))
            if self.c:
                self.c.writerow([cls, status.text, status.text])
        except Exception as e:
            print e