Example #1
0
def Symptoms():
    Symptom_1 = request.form['Symptom1']
    Symptom_2 = request.form['Symptom2']
    Symptom_3 = request.form['Symptom3']
    Symptom_4 = request.form['Symptom4']
    Symptom_5 = request.form['Symptom5']

    result = doMyTask([Symptom_1, Symptom_2, Symptom_3, Symptom_4, Symptom_5])
    result = alter(result)

    result2 = doMyTask2(
        [Symptom_1, Symptom_2, Symptom_3, Symptom_4, Symptom_5])
    result2 = alter(result2)

    return render_template(
        'prediction.php',
        data=l1,
        requestData=[Symptom_1, Symptom_2, Symptom_3, Symptom_4, Symptom_5],
        sometext="You gave the following symptoms:",
        randomText="Prediction using Random Forest Algorithm is " + result,
        randomText2="Prediction using Decision Tree Algorithm is " + result2,
        randomText9=
        "Prediction using Decision Tree and Random Forest Algorithms is " +
        result,
        randomText3=
        "**Considering the above symptoms both the diseases predicted by the two algorithms are possible**",
        randomText5='https://en.wikipedia.org/wiki/' + result,
        randomText6='https://en.wikipedia.org/wiki/' + result2,
        disease1=result,
        disease2=result2)
def main():

    choice, alter_pos = greeting_message()

    if (choice == "2"):
        file_address = input("type the address of your file!\n")
        data_str, gen_str = getDataFromFile(file_address)
    elif (choice == "1"):
        data_str = input("enter the data message!\n")
        gen_str = input("enter the generator key!\n")
    else:
        print("wrong choice please try again!")
        choice, alter_pos = greeting_message()

    transmitted_data = ""
    verified_data = ""

    if (alter_pos == -1):
        transmitted_data = generator.generate(data_str, gen_str)
        addDataToFile(transmitted_data)
        verified_data = verifier.verifier(transmitted_data, gen_str)
        print(verified_data, end="\n")
        #print (int("5"))

    elif (alter_pos != -1):
        transmitted_data = generator.generate(data_str, gen_str)
        addDataToFile(transmitted_data)
        altered_transmitted_data = alter.alter(transmitted_data, alter_pos)
        verified_data = verifier.verifier(altered_transmitted_data, gen_str)
        print(verified_data, end="\n")
Example #3
0
def generateOutPut(sentence):
    global flatteryGenerate

    newSentence = sentence[0].lower() + sentence[1:]
    sentence = newSentence

    wordsToBeReplaced = rawWords.extractEligibleWords(sentence)

    synonims = generateSynonims.generateSynonims(wordsToBeReplaced)

    newSentence = replaceWordsWithSyn.replaceWordsWithSyn(synonims,wordsToBeReplaced,sentence)

    if flatteryGenerate<3:
        flatteryGenerate = flatteryGenerate +1
        randIncurajare = 0
    else:
        randIncurajare = random.randint(0,1)


    if randIncurajare == 1:
        newSentence = incurajatori.creeazaSintagmaMagulire(newSentence)

    '''
    Momentan se altereaza o data la 45-55 caracatere.
    Daca vi se pare prea des, puteti schimba apeland
    alter.alter(newSentence, altaFrecventa), cu altaFrecventa de tip int
    '''
    oldSentence = alter.alter(newSentence)
    newSentence = oldSentence

    #print newSentence
    newSentence = informal.useContractions(newSentence)

    return newSentence
Example #4
0
def verifyAlter():
    print ("ChatBot adauga onomatopee: ")
    time.sleep(2)
    for i in range(len(text)):
        print("Original text: ", text[i])
        modifyedText = Alter.alter(text[i])
        print("Modifyed text: ", modifyedText)
        time.sleep(2)
        print ("\n")
def main():

    args = len(sys.argv)
    file_name = sys.argv[1]
    message, key = read_lines(file_name)
    remainder, trans_message = generator(message, key)
    out_file = open('generator_Output.txt', "w")
    out_file.write(trans_message)
    out_file.write('\n')
    out_file.write(key)
    out_file.close()
    message_new, key = read_lines('generator_output.txt')

    if (args > 4):
        message_new = alter(message_new, int(sys.argv[3]))

    out_file = open('message_output.txt', "w")
    out_file.write(verifier(message_new, key))
    out_file.close()
Example #6
0
        output_message = concatenation(message, generator)
        print("the result of generator is {} \n".format(output_message))
        verify = verifier(message=output_message, plynomial=generator)
        if verify:
            print(
                "result of verify is correct and the message is {} \n".format(
                    verify))
            output.write(output_message)
            output.write("\n message is correct \n \n")
        else:
            print("wrong message")
        alt = input(
            "please enter the alter bit index as a number or the default alter is 3 eg. $ 5 \n"
        )
        if alt:
            new_message = alter(output_message, int(alt))
        else:
            new_message = alter(output_message, 3)

        verify = verifier(message=new_message, plynomial=generator)
        print("the recived message after alter is {} \n".format(new_message))

        if verify:
            print("result of verify is not correct")
        else:
            print("wrong message \n")

            output.write(new_message)
            output.write("\n message is not correct \n \n")
        print('-------------------------------------------------------------')
Example #7
0
                        color_alter = "nude"
                    elif(data==SMS.Message.CalibrationColor.Light_Green):
                        color_alter = "light green"
                elif(mtype==SMS.Message.CalibrationR.type):
                    print(rgb_alter)
                    rgb_alter[2] = int(data)
                    print(rgb_alter)
                elif(mtype==SMS.Message.CalibrationG.type):
                    print(rgb_alter)
                    rgb_alter[1] = int(data)
                    print(rgb_alter)
                elif(mtype==SMS.Message.CalibrationB.type):
                    print(rgb_alter)
                    rgb_alter[0] = int(data)
                    print(rgb_alter)
                    boundaries = alter(boundaries, color_alter, rgb_alter)
                    print(boundaries)
                    print("BOUNDARIES WERE ALTERED")
                #elif(mtype==SMS.Message.CalibrationConf.type):
                    
    #detect colors
    colors, rect = colorDetector(image, min_area= min_area, proportion= crop_p, boundaries = boundaries)

    #rising and falling edge
    if (len(rect) == 1 and flag == 0) and old_flag == 1 and colors != []:
        
        old_flag = flag
        flag = 1
        print("Capsule detected: ", colors)
        ##send comm
        #if start==1:
Example #8
0
class SQL:
    def __init__(self, parent, database, sql_insert):

        # Create class variable references
        self.parent = parent
        self.database = database
        self.sql_insert = sql_insert
        self.last_table = ''
        self.last_selection = []

        if DEBUG: print self.sql_insert

        # Parse the sql insert until no more characters are left
        while not self.sql_insert == '':
            if self.sql_insert.find(' ') > -1:
                case = self.sql_insert[0:self.sql_insert.find(' ')]
            else:
                case = self.sql_insert
            case = case.upper()
            if (case == 'CREATE'):
                create(self)
            elif (case == 'ALTER'):
                alter(self)
            elif (case == 'DROP'):
                drop(self)
            elif (case == 'INSERT'):
                insert(self)
            elif (case == 'SELECT'):
                s = select(self)
                join_union_case = self.sql_insert[0:self.sql_insert.
                                                  find(' ')].upper()
                if join_union_case == 'UNION':
                    self.sql_insert = self.sql_insert[len(case):].strip()
                    s1 = eval(s)
                    s = select(self)
                    s2 = eval(s)
                    if len(s1[0]) != len(s2[0]):
                        print 'SQL: each SELECT statement within the UNION must have the same number of columns.'
                        s = ''
                    else:
                        wrongTypes = 0
                        i = len(s1[0]) - 1
                        while i >= 0:  #iterate through the first tuple
                            if not isinstance(s1[0][i], type(s2[0][i])):
                                print 'SQL: each SELECT statement within the UNION must have columns of the same data types in the same order.'
                                s = ''
                                wrongTypes = 1  #flag indicates that elements of the two selects aren't of the same data types
                                break
                            i -= 1
                        if not wrongTypes:
                            ret = []
                            for trple1 in s1:
                                ret.append(
                                    trple1
                                )  #append all triples in the first set to the output set
                            for trple2 in s2:
                                found = 0
                                for addedTrple in s1:
                                    if trple2 == addedTrple:  #if found in both the first and second don't append it again to the output set
                                        found = 1
                                        break
                                if found == 0:  #if not found in the second set append it to the output set
                                    ret.append(trple2)

                            x = ", ".join(map(str, ret))
                            s = '[' + x + ']'
                elif join_union_case == 'INNER' or join_union_case == 'LEFT' or join_union_case == 'RIGHT' or join_union_case == 'FULL':
                    s = joins(self)
                parent.python += s
            elif (case == 'TRUNCATE'):
                truncate(self)
            elif (case == 'DELETE'):
                delete(self)
            elif (case == 'UPDATE'):
                update(self)
            elif (case == 'PRINT'):
                self.sql_insert = self.sql_insert[len(case):].strip()
                parent.python += self.print_select(select(self))

            # Non-standard SQL
            elif (case == 'DATABASEPRINT'):
                self.sql_insert = self.sql_insert[len(case):].strip()
                s = self.databaseprint()
                parent.python += s
            elif (case == 'CONTENTS'):
                self.sql_insert = self.sql_insert[len(case):].strip()
                s = select(self)
                s = '[' + s.replace('[', '').replace(']', '') + ']'
                parent.python += s
            elif (case == 'TRIPLES'):
                s = ", ".join(map(str, self.database['triples']))
                parent.python += s
                self.sql_insert = self.sql_insert[len(case):].strip()
            else:
                print self.sql_insert
                raise NameError(
                    'SQL: Statement incorrect or not yet supported: ' + case)
            if DEBUG: print