Beispiel #1
0
def drawGameOver():
    pygame.draw.rect(screen, (163, 196, 220),
                     (width // 4, 100, width // 2, height - 200))
    pygame.draw.rect(screen, (0, 52, 114),
                     (width // 4, 100, width // 2, height - 200), 4)
    textCenterX = width / 2
    textCenterY = 200
    createText("Game Over", textCenterX, textCenterY, 40)
    textCenterY += 60
    totalScore = score.calculateScore()
    createText(f"Total Score: {totalScore}", textCenterX, textCenterY, 30)
    textCenterY += 60
    createText("Summary:", textCenterX, textCenterY, 30)
    for key in score.pointsDict:
        textCenterY += 40
        caption = f"{key[0].upper() + key[1:]}: {score.pointsDict[key]}"
        createText(caption, textCenterX, textCenterY, 20)
Beispiel #2
0
    def interact(self,
                 username=None,
                 interviewId=None,
                 answer=None,
                 mode=0,
                 emotion={},
                 previousQuestion=""):
        '''
		mode determines where to run the chatbot on the console or the as web api
		mode=0 web
		mode=1 console
		'''
        #beginInterview(username,interviewId)
        #question=""
        #print(emotion)
        if mode == 0:
            #answer=input("user :"******""
            while notasked:
                if times < 5:
                    question = self.kernel.respond(answer)

                    notasked = checkIfQuestionAlreadyAsked(
                        interviewId, question)
                    times = times + 1
                else:
                    break
            if times == 5:
                question = self.kernel.respond("ASK QUESTION")
                print(question)

            sentiment = self.sentiment(answer)
            textAnalysis = self.textAnalysis(answer)
            #print("Bot: ",question)
            #saveInterview(interviewId,previousQuestion,answer,0.5)
            #previousQuestion=question

            q = getQuestionDetails(previousQuestion)
            if q is not None:
                evaluable = q.evaluable
                keywords = list(q.keywords)
                #print(keywords)
                #print(q.question)
                #print("Chatbot ",q.keywords,type(keywords))
            else:
                evaluable = False
                keywords = None

            score = calculateScore(emotion=emotion,
                                   sentiment=sentiment,
                                   lexical=textAnalysis["Lexical"],
                                   evaluable=evaluable,
                                   keywords=keywords,
                                   answer=answer)
            #print(score)
            #print("Bot: ",question)

            saveInterview(interviewId,
                          previousQuestion,
                          answer,
                          score=score,
                          emotion=emotion,
                          sentiment=sentiment,
                          textAnalysis=textAnalysis)

            response = {}
            response["question"] = question
            response["sentiment"] = sentiment
            response["textAnalytics"] = textAnalysis
            response["score"] = score
            response["previousQuestion"] = previousQuestion
            response["answer"] = answer
            #print(response)
            return response

        else:
            while True:
                print("==" * 10)
                answer = input("user :"******"neutral": random.randint(1, 1000),
                    "sad": random.randint(1, 100),
                    "fear": random.randint(1, 100),
                    "disgust": random.randint(1, 100),
                    "anger": random.randint(1, 100),
                    "happy": random.randint(1, 500),
                    "suprise": random.randint(1, 100)
                }
                textAnalysis = self.textAnalysis(answer)

                q = getQuestionDetails(previousQuestion)
                if q is not None:
                    evaluable = q.evaluable
                    keywords = list(q.keywords)
                    #print("Chatbot ",q.keywords,type(keywords))
                else:
                    evaluable = False
                    keywords = None

                score = calculateScore(emotion=emotion,
                                       sentiment=sentiment,
                                       lexical=textAnalysis["Lexical"],
                                       evaluable=evaluable,
                                       keywords=keywords,
                                       answer=answer)
                #print(score)
                print("Bot: ", question)

                saveInterview(interviewId,
                              previousQuestion,
                              answer,
                              score=score,
                              emotion=emotion,
                              sentiment=sentiment,
                              textAnalysis=textAnalysis)

                previousQuestion = question
Beispiel #3
0
    #while True:
    # iterate over requests and try to cache them
    with tqdm(total=len(requests_sorted)) as pbar:
        for request in requests_sorted:
            pbar.update(1)
            # add video to the closest cache to the request endpoint with enough free space
            if cacheRequest(videos, caches, endpoint_caches, request):
                continue

    # not able to cache any request => we are done
    # break

    return caches


filename = sys.argv[1]
(cache_count, cache_capacity, videos, endpoints,
 requests) = read.read(filename)

caches_state = solve(cache_count, cache_capacity, videos, endpoints, requests)

# SCORE
score = score.calculateScore(caches_state, requests, endpoints)
print("SCORE = " + str(score))

# SUBMISSION FORMAT
used_caches = [(i, cache) for i, cache in enumerate(caches_state)
               if len(cache) > 0]
# print(len(used_caches))
# for i, cache in used_caches:
#     print(str(i) + " " + " ".join(str(x) for x in cache))
Beispiel #4
0
def getBuzzyCompanies(number, a_id, date, ilvl):
    hdr = {
        'User-Agent':
        'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
        'Accept':
        'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
        'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
        'Accept-Encoding': 'none',
        'Accept-Language': 'en-US,en;q=0.8',
        'Connection': 'keep-alive'
    }

    obj = {}
    fintech_obj = {}
    all_scores = []
    for accelerator in a_id:

        url = "https://www.seed-db.com/accelerators/viewall?acceleratorid=" + str(
            accelerator)

        req = urllib2.Request(url, headers=hdr)
        try:
            page = urllib2.urlopen(req)
        except urllib2.HTTPError, e:
            print e.fp.read()
        contents = page.read()
        root = html.fromstring(contents)

        max_array = []
        min_array = []

        print("getting id " + str(accelerator))

        for i in root.xpath('//*[@id="seedcos"]/tbody/tr'):

            return_object = []

            return_object.append("")

            crunchbase = i.xpath('td[3]/div/button[2]/a/@href')
            if not crunchbase:
                return_object.append("")
            else:
                return_object.append(crunchbase[0])

            box = i.xpath('td')

            for k in box:
                info = "".join(k.itertext())
                info = "".join(info.split()).replace("\n", "")
                return_object.append(info)

            # return_object: [angellist url = "", crunchbase url, exited?, name, url, acceleration date, exit value, ?, funding]
            print(return_object)
            skip = False

            if (date != ""):
                a_date = int(return_object[5].split("/")[1])
                if (a_date < date):
                    skip = True

            if (skip == False):
                if (return_object[2] == "" and return_object[4] != "None"
                        and return_object[1] != ""):
                    pass_object = [
                        return_object[1], return_object[4], return_object[8],
                        return_object[3]
                    ]  #[cb url, url, funding, name]
                    reutrn_val = score.calculateScore(pass_object)

                    print(reutrn_val)

                    if (reutrn_val[0] != 0):
                        string = return_object[3] + ": " + str(
                            int(reutrn_val[0]))
                        all_scores.append(string)

                        obj[return_object[3]] = int(reutrn_val[0])

                        interestLvl = reutrn_val[8]
                        if (interestLvl > ilvl):
                            fintech_obj[return_object[3]] = int(reutrn_val[0])

                        file = open("./data/list.csv", "a+")
                        file.write(string + ",")
                        file.close()

                    print("all:")
                    print(all_scores)
                else:
                    print("skipping " + return_object[3])
            else:
                print("year is too early for " + return_object[3])