text: #File: sentiment_mod.py
  
  import nltk
  import random
  #from nltk.corpus import movie_reviews
  from nltk.classify.scikitlearn import SklearnClassifier
  import pickle
  from sklearn.naive_bayes import MultinomialNB, BernoulliNB
  from sklearn.linear_model import LogisticRegression, SGDClassifier
  from sklearn.svm import SVC, LinearSVC, NuSVC
  from nltk.classify import ClassifierI
  from statistics import mode
  from nltk.tokenize import word_tokenize
  
  
  
  class ClassifyVotes(ClassifierI):
      def __init__(self, *classifiers):
          self._classifiers = classifiers
  
      # Cycle through classifiers and append the features
      def classify(self, features):
          matches = []
          for c in self._classifiers:
              v = c.classify(features)
              matches.append(v)
          return mode(matches)
  
      def accuracy_confidence(self, features):
          matches = []
          for c in self._classifiers:
              v = c.classify(features)
              matches.append(v)
  
          choice_matches = matches.count(mode(matches))
          conf = choice_matches / len(matches)
          return conf
  
  
  documents_collection = open("pickled_algos/documents.pickle", "rb")
  documents = pickle.load(documents_collection)
  documents_collection.close()
  
  
  
  
  word_features5k_f = open("pickled_algos/word_features5k.pickle", "rb")
  word_features = pickle.load(word_features5k_f)
  word_features5k_f.close()
  
  
  def find_features(document):
      words = word_tokenize(document)
      features = {}
      for w in word_features:
          features[w] = (w in words)
  
      return features
  
  
  
  featuresets_f = open("pickled_algos/featuresets.pickle", "rb")
  featuresets = pickle.load(featuresets_f)
  featuresets_f.close()
  
  random.shuffle(featuresets)
  print(len(featuresets))
  
  testing_set = featuresets[10000:]
  training_set = featuresets[:10000]
  
  
  
  open_file = open("pickled_algos/originalnaivebayes5k.pickle", "rb")
  classifier = pickle.load(open_file)
  open_file.close()
  
  
  open_file = open("pickled_algos/MNB_classifier5k.pickle", "rb")
  MNB_classifier = pickle.load(open_file)
  open_file.close()
  
  
  
  open_file = open("pickled_algos/BernoulliNB_classifier5k.pickle", "rb")
  BernoulliNB_classifier = pickle.load(open_file)
  open_file.close()
  
  
  open_file = open("pickled_algos/LogisticRegression_classifier5k.pickle", "rb")
  LogisticRegression_classifier = pickle.load(open_file)
  open_file.close()
  
  
  open_file = open("pickled_algos/LinearSVC_classifier5k.pickle", "rb")
  LinearSVC_classifier = pickle.load(open_file)
  open_file.close()
  
  
  open_file = open("pickled_algos/SGDC_classifier5k.pickle", "rb")
  SGDC_classifier = pickle.load(open_file)
  open_file.close()
  
  
  
  
  voted_classifier = ClassifyVotes(
                                    # classifier,
                                    LinearSVC_classifier,
                                    MNB_classifier,
                                    BernoulliNB_classifier,
                                    LogisticRegression_classifier)
  
  
  
  
  def sentiment(text):
      featurefind = find_features(text)
      return voted_classifier.classify(featurefind),voted_classifier.accuracy_confidence(featurefind)