Exemplo n.º 1
0
def main():
    print("TUBES I IF3170 INTELIGENSI BUATAN")
    print("Masukkan nama file: ")
    namafile = input()
    states = parse(namafile)

    stop = False
    while (not stop):
        print("Tentukan Algoritma Penyelesaian:")
        print("1. Hill Climbing")
        print("2. Simulated Annealing")
        print("3. Genetic Algorithm")
        print("4. Exit")

        algo = input("Pilihan: ")

        if (algo=='1'):
            print("BOARD AWAL")
            hillClimbing(states)
            input()
        elif (algo=='2'):
            print("BOARD AWAL")
            simulated_annealing(states)
        elif (algo=='3'):
            genetic_algorithm(states)
            print("BOARD AWAL")
        elif (algo=='4'):
            print('Program selesai')
            stop = True
        else:
            print('Invalid input')
Exemplo n.º 2
0
 def generateListOfNames(self, fileNames):
     print(fileNames)
     finalList = []
     for file in fileNames:
         finalList.append(parserr.parse(file, self.homeDir))
     subDirFolder = os.path.join(self.homeDir, "Names-CSV")
     location = parserr.writeToCSV(subDirFolder, finalList)
     self.alertDialogForManualClick("Results: ", finalList, location)
Exemplo n.º 3
0
    def compareFiles(self, listBoxBotLeft, listBoxBotRight):
        if self.checkForEqualRows(listBoxBotLeft, listBoxBotRight):
            oldFiles = listBoxBotLeft.get(0, (listBoxBotLeft.size() - 1))
            recentFiles = listBoxBotRight.get(0, (listBoxBotRight.size() - 1))

            listOfOldResults = []
            listOfRecentResults = []
            for i in range(len(oldFiles)):
                oldFileParsed = parserr.parse(oldFiles[i], self.homeDir)
                recentFileParsed = parserr.parse(recentFiles[i], self.homeDir)
                if self.isComparisonOfSameSecurity(oldFileParsed,
                                                   recentFileParsed):
                    listOfOldResults.append(oldFileParsed)
                    listOfRecentResults.append(recentFileParsed)
                else:
                    self.alertDialogForManualClick(
                        "Matching Error",
                        "Security of row %s does not match.\n"
                        "This row will be removed from final analysis." % (i))

            listOfPrey = []
            for i in range(len(listOfOldResults)):
                freshPrey = parserr.compareDicts(listOfOldResults[i],
                                                 listOfRecentResults[i])
                listOfPrey.append(freshPrey)

            self.refreshFields([listBoxBotRight, listBoxBotLeft])
            subDirFolder = os.path.join(self.homeDir, "Comparisons-CSV")
            # this is horrible form but I'm tired. The method below returns file location but also does a bunch of other stuff
            location = parserr.writeToCSV(subDirFolder, listOfPrey)
            self.alertDialogForManualClick("Results: ", listOfPrey, location)

        else:
            self.alertDialogForManualClick(
                "Indexing Error",
                "ListBoxes must have equal number of entries.\n"
                "- Remember that each comparison must be of the same "
                "security type.")
Exemplo n.º 4
0
        "tezos": "XTZ",
        "xtz": "XTZ",
        "zcash": "ZEC",
        "zec": "ZEC",
        "ox": "ZRX",
        "zrx": "ZRX",
        "augur": "REP",
        "rep": "REP"
    })
    while True:
        # takes in input from command line
        query = input("> ")
        if query == "q":
            break

        parsed_query = parserr.parse(query)[0]
        cryptos = parserr.parse(query)[1]

        response = cb.respond(parsed_query)

        if parserr.unparse(response, cryptos) == "off-topic":
            print("off topic")

        question = response[0]
        crypto = parserr.unparse(response, cryptos)
        print(question)
        if cryptoDict.get(crypto) != None:
            if question == price:
                priceOf(crypto, cryptoDict.get(crypto))
            elif question == cryptointro:
                cryptoIntro()
Exemplo n.º 5
0
def process():
    query = request.form['user_input']
    cryptoDict = dict({
        "bitcoin": "BTC",
        "btc": "BTC",
        "ethereum": "ETH",
        "eth": "ETH",
        "litecoin": "LTC",
        "ltc": "LTC",
        "dai": "DAI",
        "eos": "EOS",
        "stellar": "XLM",
        "xlm": "XLM",
        "bat": "BAT",
        "ripple": "XRP",
        "xrp": "XRP",
        "chainlink": "LINK",
        "link": "LINK",
        "dash": "DASH",
        "tezos": "XTZ",
        "xtz": "XTZ",
        "zcash": "ZEC",
        "zec": "ZEC",
        "ox": "ZRX",
        "zrx": "ZRX",
        "augur": "REP",
        "rep": "REP"
    })
    # takes in input from command line

    parsed_query = parserr.parse(query)[0]
    cryptos = parserr.parse(query)[1]

    response = cb.respond(parsed_query)

    if parserr.unparse(response, cryptos) == "off-topic":
        print("off topic")
    if len(response) != 0:
        question = response[0]
        crypto = parserr.unparse(response, cryptos).strip()
        # DEBUG:
        # print(question, crypto)
        # print("~"+crypto+"~")
        if cryptoDict.get(crypto) != None:
            if question == "price":
                return priceOf(crypto, cryptoDict.get(crypto))
            elif question == "cryptointro":
                return cryptoIntro()
            elif question == "close":
                return closeCrypto(crypto, cryptoDict.get(crypto))
            elif question == "opens":
                return openCrypto(crypto, cryptoDict.get(crypto))
            elif question == "high":
                return highCrypto(crypto, cryptoDict.get(crypto))
            elif question == "low":
                return lowCrypto(crypto, cryptoDict.get(crypto))
            elif question == "percent":
                return percentCrypto(crypto, cryptoDict.get(crypto))
            elif question == "absolute":
                return absoluteCrypto(crypto, cryptoDict.get(crypto))
            elif question == "volume":
                return volumeCrypto(crypto, cryptoDict.get(crypto))
            elif question == "about":
                return aboutCrypto(cryptoDict.get(crypto))
            elif question == "marketcap":
                return marketCap(crypto, cryptoDict.get(crypto))
            else:
                return "I cannot answer that right now"
        else:
            return "I'm not trained to answer that question."
    else:
        return "Off topic"
Exemplo n.º 6
0
# COMP 340
# Amari Sisco
import lexer
import parserr
import evaluator
import decipher

while True:
    babyExp = input(">>> ")
    if babyExp == "poopoo":
        break
    srcCode = decipher.decipher(babyExp)
    tokSeq = lexer.tokenize(srcCode)
    rootNode = parserr.parse(tokSeq)
    result = evaluator.evaluate(rootNode)
    print("The Result is: ", result)

print("Now it is tim to go poo poo")