Ejemplo n.º 1
0
    def run(self):
        import FilesManager
        import test, gmm
        from sklearn.model_selection import KFold

        files, digits, types = FilesManager.importFiles("train")

        train, test = test.split(types["M"])

        mfcc = []
        for i in test:
            mfcc.append(FilesManager.joinMfcc(files, excluded=i))

        for k in range(len(train)):
            one = gmm.myGmm(mfcc[k])

            good = 0
            bad = 0
            for i in files:
                if files[i]['lektor'] in test[k]:
                    if gmm.compare(one, files[i]) == files[i]["znak"]:
                        good += 1
                    else:
                        bad += 1
            file = open("recognition_ratio", 'a')
            file.write("recognition ratio of: " + str(k) + " ")
            file.write(str(int(good / (good + bad) * 100)) + "%\n")
            file.close
Ejemplo n.º 2
0
def emp_ip(a, i=0):
    if i == 1:
        ip = 0
        query = "select ip_address from employee where emp_id=" + a
        result = db_point(query)
        for x in result:
            ip = x[0]
        return ip
    elif i == 2:
        query = "select status from employee where emp_id=" + a
        result = db_point(query)
        status = ""
        for x in result:
            status = x[0]
        return status
    else:
        e = 0
        u = ""
        # query to get employee name based on ip address
        query = "select Emp_id,Full_name from employee where ip_address=" + a
        result = db_point(query)
        if result:
            for x in result:
                u = x[1]
                e = x[0]
        u = split(u, 1)
        return u, e
Ejemplo n.º 3
0
 def getPath(cls, line) -> Iterable[Point]:
     point = Point(0, 0)
     steps = split(line, str)
     for step in steps:
         distance = int(step[1:])
         if distance != 0:
             direction = step[0].upper()
             for _ in range(distance):
                 point = cls._movementsByDirection[direction](point)
                 yield point
Ejemplo n.º 4
0
    def process(self, line: str):
        lower, upper = split(line, int)
        lower = max(lower, 111111)
        upper = min(upper, 999999)

        matchCount = 0
        for x in range(lower, upper + 1):
            if self.isMatch(x):
                matchCount += 1

        return matchCount
Ejemplo n.º 5
0
def Connections():
    while True:
        client, addr = server.accept()
        addr1 = format(addr)
        addr1 = split(addr1, 2)
        print(addr1)
        global uname
        uname, eid[addr1] = emp_ip(addr1)
        uname = uname.capitalize()
        print(uname)
        addresses[client] = addr1
        clients[client] = uname
        Thread(target=ClientConnection, args=(client, )).start()
Ejemplo n.º 6
0
    def process(self, line: str):
        result = None
        program = split(line, int)
        nics = [Nic(i, program) for i in range(50)]

        def send(address: int, x: int, y: int):
            if address == 255:
                nonlocal result
                result = y
            else:
                q = nics[address].inputQueue
                q.append(x)
                q.append(y)

        while result is None:
            next(cycle(nics)).execute(send)
        return result
Ejemplo n.º 7
0
def list(request):
    # Handle file upload
    if request.method == 'POST':
        form = DocumentForm(request.POST, request.FILES)
        if form.is_valid():
            newdoc = Document(docfile = request.FILES['docfile'])
	    print type(newdoc)
            newdoc.save()
	    b = test.split()
	    print "Value of b is", b
            documents = Document.objects.all()
	    print type(documents)
	    from  mimetypes import MimeTypes
            import urllib 
            mime = MimeTypes()
	    url = urllib.pathname2url('/home/priyanshu/git/roger/media/upload.csv')
	    mime_type = mime.guess_type(url)
	    print "Mime type is", mime_type
	    import datetime
	    global h
	    h = datetime.datetime.now()
	    print h
#	    c = p4j.sentiment()
#	    print "Value of c is", c
	    # Redirect to the document list after POST
            return HttpResponseRedirect('')
    
    else:
        form = DocumentForm() # A empty, unbound form

    # Load documents for the list page
    documents = Document.objects.all()
#    command = nagios_summary.pretty_print_status()
    a = nagios_summary.pretty_print_status()
    host = a[0]
    state = a[1]
    command  = zip(host, state)
    print documents
    # Render list page with the documents and the form
    return render_to_response(
        'fileupload/picture_basic_form.html',
        {'documents': documents, 'form': form, 'command' : command},
        context_instance=RequestContext(request)
	    )
Ejemplo n.º 8
0
def ClientConnection(client):
    name = clients[client]
    a = addresses[client]
    addr2 = split(a, 2)
    global rec_Id
    rec_Id = client.recv(BufferSize).decode("utf-8")
    #print("receiver id is " + rec_Id)

    while True:
        ms = client.recv(BufferSize).decode("utf-8")
        msg = ms.split(", ", 1)

        rec_Id = msg[0]
        if msg[1] != "quit":
            Broadcast(addr2, msg[1].encode("utf-8"), name+":")
            print(name+":"+msg[1])
        else:
            client.send(("Will see you soon..").encode("utf-8"))
            del clients[client]
            break
Ejemplo n.º 9
0
    def process(self, line: str):
        codes = split(line, int)
        for i in range(0, len(codes), 4):
            operationCode = codes[i]
            if operationCode == 1:
                operation = lambda x, y: x + y
            elif operationCode == 2:
                operation = lambda x, y: x * y
            elif operationCode == 99:
                break
            else:
                raise Exception(
                    'Invalid operationCode {0} in position {1}'.format(
                        operationCode, i))

            # check operationCode before reading on, because after 99 there are no more codes
            paramPos1 = codes[i + 1]
            paramPos2 = codes[i + 2]
            resultPos = codes[i + 3]
            result = operation(codes[paramPos1], codes[paramPos2])
            codes[resultPos] = result
        return join(codes)
Ejemplo n.º 10
0
def db_insert(val, a):
    if a == 1:  # query to insert a group message into db
        sql = "insert into message (message_body,sender_id,receiver_id,Receiver_group_id,message_type,time) values (%s,%s,%s,%s,%s,%s)"
        cursor.execute(sql, val)
        mydb.commit()
    elif a == 2:  # query to add new employee into db
        query = "INSERT INTO employee(Full_name, Designation, Email_id, Dob,ip_address) VALUES(%s, %s, %s, %s, %s)"
        cursor.execute(query, val)
        mydb.commit()
        eid = cursor.lastrowid
        uname = split(val[0])  # function call to get username
        pass1 = encrypt_code("password")  # function call to encrypt password
        print(uname + "\t" + pass1)
        # create user in user table
        query = "INSERT INTO `users`(`Emp_id`, `username`, `password`, `user_type`)  VALUES(%s, %s ,%s, %s) "
        eval = (eid, uname, pass1, "standard")
        cursor.execute(query, eval)
        mydb.commit()
    elif a == 3:  # query to insert notices into db
        sql = "INSERT INTO notices(leader_id, notice_body, date_created) VALUES(%s, %s, %s)"
        cursor.execute(sql, val)
        mydb.commit()
Ejemplo n.º 11
0
 def process(self, lines: List[str]):
     lunarSystem = JupiterLunarSystem((split(line, int) for line in lines))
     lunarSystem.progress(1000)
     return lunarSystem.totalEnergy
Ejemplo n.º 12
0
 def process(self, line: str):
     paintedPanels = HullPaintingRobot(split(line, int)).panelColorByXy
     return len(paintedPanels)
Ejemplo n.º 13
0
    my_msg.set("")  # Clears input field.
    if msg == "quit":
        client_socket.send(msg.encode("utf8"))
        client_socket.close()
        # top.quit()
    else:
        client_socket.send(msg.encode("utf8"))


query = "select Full_name from employee where Emp_id='" + eid + "'"
result = db_point(query)
if result:
    for x in result:
        uname1 = x[0]

uname = split(uname1)
uname = uname.capitalize()


def notices():
    os.system('python notices_ui.py')


NoticeButton = Button(window, text="Notices", command=notices, bg="red")
NoticeButton.place(relx=0.677, rely=0.0, height=35, width=84)

# left side frame
TFrame1 = ttk.Frame(window)
TFrame1.place(relx=0.0, rely=0.056, relheight=0.955, width=213)
TFrame1.configure(relief='groove')
TFrame1.configure(borderwidth="2")