def read(crd): print(main.read(crd.client, crd.key)+"\n\n") print(main.read("pinky", "student1")+"\n\n") print(main.read("SVCE", crd.key)+"\n\n") print(main.read(crd.client, "Executive")+"\n\n") print("\nSleeping mode...\n\n") sleep(20) # print(main.read(crd.client, crd.key)+"\n") print(main.read(crd.client, "Executive")+"\n\n")
def main(_): config = flags.FLAGS os.environ["CUDA_VISIBLE_DEVICES"] = config.gpu with tf.Graph().as_default(): data = read(config) pseudo_labeling(config, data)
def main(_): config = flags.FLAGS os.environ["CUDA_VISIBLE_DEVICES"] = config.gpu with open(config.pattern_file, "r") as fh: patterns = json.load(fh) config.patterns = patterns data = read(config) train(config, data)
def class_init(): tmp_list = [] path_label = "C:/Users/Yitian Chen.DESKTOP-TIIP443/Desktop/tmp1/training/result_csv/all_label.csv" path_result = "C:/Users/Yitian Chen.DESKTOP-TIIP443/Desktop/tmp1/training/result_csv/all_result.csv" path_speakerID = "C:/Users/Yitian Chen.DESKTOP-TIIP443/Desktop/UNSW_Thesis/ComParE2013_Autism/lab/ComParE2013_Autism.csv" tmp_label = read(path_label) tmp_result = read(path_result) tmp_speaker = read(path_speakerID) label = np.array(tmp_label) features = np.array(tmp_result) speakerID = np.array(tmp_speaker)[:, 1] N1 = np.shape(label)[0] N2 = cf.NUM_SPEAKERS for i in range(N1): tmp_list.append(Diagnosis_class(label[i], speakerID[i], features[i])) tmp1 = np.array(tmp_list[0].features) tmp2 = np.array(tmp_list[1].features) tmp_list[0].features = np.row_stack((tmp1, tmp2)) #print(tmp_list[0].features, tmp_list[0].speaker_ID) '''
def extract_instances(dir_name, class_value=None, min_occurences=1): raw_instances = main.read(dir_name, True, combine=list.append) def parse_instance(raw_inst): inst = Counter(raw_inst) inst[CLASS_VALUE] = class_value return inst #convert trom a raw sequence of strings to a dict containing counts of those strings instances = [parse_instance(raw_inst) for raw_inst in raw_instances] if min_occurences > 1: filter_data(data, min_occurences=min_occurences) return instances
import main as main_file main_file.create("Avinash", 25) main_file.create("src", 70, 3600) main_file.read("Avinash") main_file.read("src") main_file.create("Avinash", 50) main_file.modify("Avinash", 55) main_file.delete("Avinash") th1 = Thread(target=(create or read or delete), args=(key_name, value, timeout)) th1.start() th1.sleep() th2 = Thread(target=(create or read or delete), args=(key_name, value, timeout)) th2.start() th2.sleep()
def test_read_1(): assert main.read('data1.txt') == {'101': 'Teddy-Bear', '102': 'Kelereng', '201': 'Laptop', '202': 'Smartphone', '203': 'Speaker', '301': 'Avanza', '302': 'Supra-X', '401': 'Topi', '402': 'Jaket', '403': 'Scarf'}
def test_read_2(): assert main.read('data2.txt') == {'711': 'Malaysia', '712': 'Singapura', '713': 'Indonesia', '814': 'USA', '815': 'Canada'}
#This are the inputs to explain, how to perform operations on a mail file... import threading # For multi-threading purpose import main as m # importing the main file as a library that act as a data-store... m.create("execution", 25) m.create("Test", 50) m.create("Demo", 70) m.create("example", 100) # To create a key with name of the key,value given and with no time-to-live property... m.create("source", 70, 3600) #to create a key with name of the key,value given and with time-to-live property value given(in number of seconds) m.read("execution") # it returns the value of desired key in Jasonobject format 'key_name:value'm m.read("Demo") # it returns the value of desired key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR m.create("Test", 150) #it returns an ERROR since the name of the key already exists in the datastore... # If we want to create this key again with some other value then delete this key using # delete operation and then recreate it... m.delete("execution" ) #it deletes the respective key and its value from the datastore... #we can access these using multiple threads like
def test_read(self): self.assertEqual(main.read("kolkata"),"kolkata:25") self.assertEqual(main.read("Bangalore"),"error: given key does not exist in database. Please enter a valid key") self.assertEqual(main.read("Delhi"),"Delhi:100")
cutTo( bits["datatype"],maxWidth - maxWidth/2), \ cutTo( bits["prevVal"],(maxWidth/2)-2) + 2*" " +\ cutTo(bits["default"],maxWidth -maxWidth/2)] if whatType == "next": miniFieldTable = [ cutTo(bits["key"],3*(maxWidth/8)-2) + 2*" " + \ cutTo( bits["datatype"],2*(maxWidth/8)-2) + 2*" " +\ cutTo(bits["default"],maxWidth -5*(maxWidth/8)), \ cutTo( bits["helpStr"],5*(maxWidth/8)-2) + 2*" " +\ cutTo(bits["prevVal"],maxWidth -5*(maxWidth/8))] return miniFieldTable data = leaf.entries() logs = main.read("Logs.xml") leaf = logs.children()[0].children()[0] field = leaf.fields()[0] for line in miniDrawField(field, leaf,{"Gut pain": 3}, "next"): print line def drawField(field, fieldAsTable = None, maxWidth = WINDOW_WIDTH,maxHeight = 8): """ Draws a field in 8 lines (or more) 1 Key: 2 Type: 3 Type data: 4 Hidden: Optional: 5 Default: 6 Help: 7
import ga import csv import main series = main.read() model = ga.GeneticAlgorithm(series, ks=4, verbose=1) model.run() model.fitness(model.Xbest, True) B = ['*'] * len(series) B[42] = 42 B[270] = 270 B[676] = 676 B[821] = 821 i = ga.Individual(series, 4) i.B = B i._make_attr_() model.fitness(i, True)
def test_guestbook(): assert main.read('Guest_book.json') == 3
import main action = input("Read or Write?").lower() if action not in ("read", "write"): print("Error, assuming read") main.read() if action == "read": main.read() if action == "write": numbers = str(input("Numbers?")) main.writeStart(numbers)
res = app.create(key,value) if(res): print("Key Value pair has been added successfully") elif(option == 2): print("Enter the key:") key = input() print("Enter its value:") value = input() print("Enter the time-to-live") ttl = int(input()) res = app.create(key,value,ttl) if(res): print("Key Value pair has been added successfully") elif(option == 3): print("Enter the key:") key = input() app.read(key) elif(option == 4): print("Enter the key:") key = input() app.delete(key) print("Enter your option") option = int(input()) if(option == 5): datastore = app.save() with open("library.json",'w') as file: datastore = json.dumps(datastore) file.write(datastore)
import main as crd crd.create("pawan", 28) crd.create("pp", 70, 3600) crd.read("pawan") crd.read("pp") crd.create("pawan", 50) #it throws an ERROR since the key already exists in the db crd.modify("pawan", 55) crd.delete("pawan") # it can be access through thread thrd1 = Thread(target=(create or read or delete), args=(key, value, t_out)) thrd1.start() thrd1.sleep() thrd2 = Thread(target=(create or read or delete), args=(key, value, t_out)) thrd2.start() thrd2.sleep() thrd3 = Thread(target=(create or read or delete), args=(key, value, t_out)) thrd3.start() thrd3.sleep()
""" import main from sklearn.svm import SVC from sklearn import linear_model from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score, confusion_matrix, precision_score, recall_score, f1_score from sklearn.metrics import accuracy_score from sklearn.model_selection import GridSearchCV from sklearn.metrics import classification_report import numpy as np import matplotlib.pyplot as plt from prettytable import PrettyTable print("Reading data ...") x_all, y_all = main.read(LOAD_DATA=False) x_train, x_test, y_train, y_test = train_test_split(x_all, y_all, test_size=0.3, random_state=42) modelLogistic = [ linear_model.LogisticRegression(), linear_model.LogisticRegression(C=10, class_weight=None, dual=False, fit_intercept=True, intercept_scaling=1, max_iter=100, multi_class='ovr', n_jobs=1,
import main as x import time x.create('dog',8,10,1) x.create('cat',6) x.create('donkey',10) x.read('cat') x.destroy('donkey') time.sleep(10) x.read('dog')
def read(self): return main.read(self.client, self.key, filepath=self.filepath)
import main as x x.create("amrita", 25) x.create("school", 70, 3600) x.read("amrita") x.read("src") x.create("amrita", 50) x.modify("amrita", 55) x.delete("amrita") t1 = Thread(target=(create or read or delete), args=(key_name, value, timeout)) t1.start() t1.sleep() t2 = Thread(target=(create or read or delete), args=(key_name, value, timeout)) t2.start() t2.sleep()
import main from sklearn.svm import SVC from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score, confusion_matrix, precision_score, recall_score, f1_score from sklearn.model_selection import GridSearchCV from sklearn.metrics import classification_report print("Reading data ...") x_all, y_all = main.read(data=False) x_train, x_test, y_train, y_test = train_test_split(x_all, y_all, test_size=0.3, random_state=42) print(x_train.shape, y_train.shape) print(x_test.shape, y_test.shape) models = [ SVC(), SVC(C=1000, cache_size=200, class_weight=None, coef0=0.0, decision_function_shape='ovr', degree=3, gamma=0.01, kernel='rbf', max_iter=-1, probability=False, random_state=None, shrinking=True, tol=0.001,
import main as data data.create("chetan",30 data.create("shivam",75,3610) data.read("chetan") data.read("shivam") data.create("chetan",55) data.modify("chetan",50) data.delete("chetan") thread1=Thread(target=(create or read or delete),args=(key_name,value,timeout)) thread1.start() thread1.sleep() thread2=Thread(target=(create or read or delete),args=(key_name,value,timeout)) thread2.start() thread2.sleep()
#here are the commands to demonstrate how to access and perform operations on a main file #run the MODULE of MAIN FILE and import mainfile as a library import main #importing the main file("code" is the name of the file I have used) as a library main.create("sankar", 25) #to create a key with key_name,value given and with no time-to-live property main.create("src", 70, 20) #to create a key with key_name,value given and with time-to-live property value given(number of seconds) main.read("sankar") #it returns the value of the respective key in Jasonobject format 'key_name:value' main.read("src") #it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR main.read("example__key") #if we try to read an unknown key main.create("sankar", 50) #it returns an ERROR since the key_name already exists in the database #To overcome this error #either use modify operation to change the value of a key #or use delete operation and recreate it main.modify("sankar", 55) #it replaces the initial value of the respective key with new value main.read('sankar')