def Test(inp): print("Entered Test") wordcount = 0 #inp = raw_input("Enter the name of the test file : ") # test #inp = raw_input("Enter the name of the test file (filename.txt) : ") #path = ('./dataset/Test/input/raghuram.txt') import os script_dir = os.path.dirname(__file__) #<-- absolute dir the script is in rel_path = "/dataset/Test/input/" + str(inp) #abs_file_path = os.path.join(script_dir, rel_path) #abs_file_path = os.path.abspath(os.path.dirname(__file__)) path = os.getcwd() print path abs_file_path = str(path) + str(rel_path) #parentdir = os.path.dirname(path) #os.chdir(parentdir) #path = os.getcwd() print "\n\n\npath=" print abs_file_path print "\n\n\n\n" #paths = os.path.abspath('dataset/Test/input/'+str(inp)) paths = abs_file_path #path = ('./dataset/Test/input/'+inp) #f = open(paths,'r') arra = [] with open(paths, 'r+') as f: tweets = [x.strip() for x in f] preprocessed = preproc.tweet_mains(tweets) wordcount = w.generatetestset(preprocessed, str(inp)) svm.create_trainfile(2, str(inp)) arra = svm.testSVM(str(inp)) print("Leaving Test") return arra
def Test(): print("Entered Test") wordcount = 0 path = ('./dataset/Test/input/bse.txt') with open(path) as f: tweets = [x.strip() for x in f] preprocessed = preproc.tweet_mains(tweets) wordcount = w.generatetestset(preprocessed) print("Leaving Test")
def Test(): print("Entered Test") wordcount = 0 #inp = raw_input("Enter the name of the test file : ") # test inp = raw_input("Enter the name of the test file (filename.txt) : ") #path = ('./dataset/Test/input/raghuram.txt') path = ('./dataset/Test/input/' + str(inp)) #path = ('./dataset/Test/input/raghuram.txt') with open(path) as f: tweets = [x.strip() for x in f] preprocessed = preproc.tweet_mains(tweets) wordcount = w.generatetestset(preprocessed) print("Leaving Test")
def Train(): print("EnteredTrain") preprocessed = [] wordcount = 0 categoryId = 0 path = ('./dataset/input/') #string =[ "Hello this is it;","Hi How are you","This is Congratulations:"] for filename in glob.glob(os.path.join(path, '*.txt')): categoryId += 1 with open(filename) as f: tweets = [x.strip() for x in f] preprocessed = preproc.tweet_mains(tweets) wordcount = w.generatewordset(preprocessed, categoryId) #svm.create_trainfile() "not complete" '''for pre in preprocessed: print pre''' print("Leaving Train")
def Train(): print("EnteredTrain") preprocessed = [] wordcount = 0 categoryId =0 #string =[ "Hello this is it;","Hi How are you","This is Congratulations:"] path = ('./dataset/input/') #string =[ "Hello this is it;","Hi How are you","This is Congratulations:"] for filename in glob.glob(os.path.join(path, '*.txt')): with open('./dataset/test.txt','r+') as f: tweets = [x.strip() for x in f] preprocessed = preproc.tweet_mains(tweets) m = Word2Vec(preprocessed) print m.vocab m.most_similar('SunRisers', topn=5) '''for tweet in preprocessed:
def Train(): print("EnteredTrain") preprocessed = [] wordcount = 0 categoryId = 0 #string =[ "Hello this is it;","Hi How are you","This is Congratulations:"] path = ('./dataset/input/') #string =[ "Hello this is it;","Hi How are you","This is Congratulations:"] for filename in glob.glob(os.path.join(path, '*.txt')): print categoryId categoryId += 1 with open(filename, 'r+') as f: tweets = [x.strip() for x in f] preprocessed.append(preproc.tweet_mains(tweets)) for tweet in preprocessed: for word in tweet: print word print '\n' '''m = Word2Vec(preprocessed)
def Train(): print("EnteredTrain") preprocessed = [] wordcount = 0 categoryId = 0 files = [ './dataset/input/sports.txt', './dataset/input/finance.txt', './dataset/input/politics.txt', './dataset/input/technology.txt', './dataset/input/entertainment.txt' ] #string =[ "Hello this is it;","Hi How are you","This is Congratulations:"] for filename in files: categoryId += 1 with open(filename) as f: tweets = [x.strip() for x in f] preprocessed = preproc.tweet_mains(tweets) wordcount = w.generatewordset(preprocessed, categoryId) #svm.create_trainfile() "not complete" '''for pre in preprocessed: print pre''' print("Leaving Train")