Exemplo n.º 1
0
def trainData():
    target = list()
    input = ps.parse()
    featWrds = loadFeatureFromFile('tester.txt')
    twtCounter = 0
    x = list()
    for tweet in input:
        twtCounter = twtCounter + 1
        target.append(tweet.pop(-1))
        featNum = []
        counter = 0
        for wrd in featWrds:
            if wrd in tweet:
                featNum.append(1)
            else:
                featNum.append(0)
            counter = counter + 1
        x.append(featNum)
        #print x

    model.fit(x, target)

    givenAnswer = model.predict(x)

    listToSum = abs(givenAnswer - target)
    print sum(givenAnswer)
    print twtCounter
Exemplo n.º 2
0
def onlyOnInit():
	st = LancasterStemmer()
	yes = dict()
	no = dict()
	(yes,no) = loadWordsFromFile('tester.txt')
	valText = ps.parse()
	stemmedWordList = []
	#for each tweet, manipulate dictionary (part of training)
	for row in valText:
		#pop V bit from end of row
		V = row.pop(-1)
		filtered_words = [w for w in row if not w in stopwords.words('english')]
		#print "stemmed" + str([w for w in row if w in stopwords.words('english')])
		for word in filtered_words:
			#if the key does not exist in the dictionary, add it with 1 weight
			try:
				prevWord = word
				word = st.stem(str(word))
				word = str(word)
				if yes.get(word, 'none') == 'none':
					if(V==1):
						yes[word] = 1	
						no[word] = 0
					else:
						yes[word] = 0
						no[word] = 1
				else:
					if(V==1):
						yes[word] += 1
						#print words[word]
					else:
						no[word] += 1
			except:
				print "Exception " + str(prevWord)
	storeWordsToFile(yes, no,'tester.txt')
Exemplo n.º 3
0
import motor
import threading
import subprocess
import random
import time
import os
import parseFile
import xlsxwriter
import openpyxl
from openpyxl.chart import *
import serial

define("port", default=8000, help="run on the given port", type=int)
cwd = os.getcwd()  # used by static file server
print("Current Working directory :" + cwd)
parseFile.parse()
temperature = []
light = []
voltage = []
current = []
timestamp = []


class IndexPageHandler(RequestHandler):
    """
        index page
    """
    @gen.coroutine
    def get(self, *args, **kwargs):
        self.set_header('Content-Type', 'html')
        self.set_header("Access-Control-Allow-Origin", "*")