예제 #1
0
def dataset_places_sentiment():
    utility = Utility()
    worst = utility.get_worst_places()
    best = utility.get_best_places()
    return render_template('dataset_places_sentiment.html',
                           worst=worst,
                           best=best)
예제 #2
0
    def __init__(self):
        self.util = Utility()
        self.device = self.util.device
        self.package = 'com.lv0.dotrangers'
        self.activity = 'com.unity3d.player.UnityPlayerActivity'

        self.util.positions = {
            'ad close': {
                'x': 742,
                'y': 62
            },
            'ad yes': {
                'x': 500,
                'y': 530
            },
            'ad': {
                'x': 687,
                'y': 685
            },
            'close': {
                'x': 460,
                'y': 665
            },
        }
        self.util.colors = {
            'ad': (-1, 33, 33, 33),
        }
예제 #3
0
def place_sentiment():
    wd_id = urllib.unquote(str(request.args.get('wd_id')))
    type = urllib.unquote(request.args.get('type')).encode('utf8')

    utility = Utility()
    sentiment = Sentiment()

    place = utility.get_place(wd_id=wd_id, type=type)
    place['label'] = place['uri'].split("/")[-1].replace("_", " ")
    if (place['wikidata_id'] != "None"):
        place['surfaceForm'] = utility.get_surfaceForm(place['wikidata_id'])
    elements = sentiment.get_place_word_frequency(wd_id=wd_id,
                                                  type=type,
                                                  pos_tag="a")

    words = elements['words']
    most = words.most_common()
    array = []
    for i in range(0, min(15, most.__len__())):
        new_dict = {}
        elem = most[i]
        new_dict['word'] = elem[0].decode('utf-8')
        new_dict['num'] = elem[1]
        array.append(new_dict)

    words['words'] = array
    pos_neg_words = sentiment.get_best_worst_words(wd_id, type, "a")

    return render_template('place_sentiment.html',
                           place=place,
                           words=words,
                           pos_words=pos_neg_words['pos'],
                           neg_words=pos_neg_words['neg'])
예제 #4
0
def main():

    #istantiate all the useful classes
    linker=EntityLinker()
    cleaner=Cleaner()
    sentiment=Sentiment()
    utility= Utility()
예제 #5
0
 def create_assets(self, planets):
     # self.log('Creating Board')
     self.board = Board(self.board_size, self, planets)
     self.utility = Utility(True, self)
     self.economic_engine = EconomicEngine(self.board, self)
     self.movement_engine = MovementEngine(self.board, self)
     self.combat_engine = CombatEngine(self.board, self)
예제 #6
0
 def test_calc_dates(self):
     print('test calc_dates')
     gc = GoogleCalendar()
     gcdb = GoogleCloudDb()
     utility = Utility(gcdb, None)
     bcs = BorrowConsoleState(utility, gc)
     bcs.calc_dates()
예제 #7
0
    def set_places_sentiment(self):
        utility = Utility()
        places = utility.get_places(1, 0, 100000)

        places_sentiment = self.calc_places_sentiment(places, 1)
        for place in places_sentiment:
            #print(str(round(place['total_sentiment']*1000,2))+" - "+place['uri'])
            cursor = self.db.cursor()
            query = "UPDATE places set sentiment_norm='" + str(
                round(place['total_sentiment'] * 1000, 2)
            ) + "' where uri='" + place['uri'].replace('\"', '\\\"').replace(
                '\'', '\\\'') + "' and type='" + place['type'].replace(
                    '\"', '\\\"').replace('\'', '\\\'') + "\';"
            cursor.execute(query)

        self.db.commit()

        places_sentiment = self.calc_places_sentiment(places, 0)
        for place in places_sentiment:
            #print(str(round(place['total_sentiment'],3))+" - "+place['uri'])
            cursor = self.db.cursor()
            query = "UPDATE places set sentiment='" + str(
                round(place['total_sentiment'], 2)
            ) + "' where uri='" + place['uri'].replace('\"', '\\\"').replace(
                '\'', '\\\'') + "' and type='" + place['type'].replace(
                    '\"', '\\\"').replace('\'', '\\\'') + "\';"
            cursor.execute(query)
        self.db.commit()
예제 #8
0
    def simulate(self):
        # Starts the simulation
        if self.simType == 1:
            while (self.gameState):
                self.updateInformation()
                # self.defender.debugKnowledge()
                if self.askAtt:
                    self.askAttacker()
                if self.askDef:
                    self.askDefender()
                self.executeAction()
                # debugging.printAgentKS(self.attacker, self.defender)
                # debugging.printTruth(self.stateManager.activeResources,
                #                       self.stateManager.inactiveResources)

        #  Use the recorded history to get the utility
        self.updateInformation()

        #  Set up the utility function
        u = Utility(self.utilParams)
        utilFunc = u.getUtility(self.utilType)
        payoff = utilFunc(self.stateManager.stateHistory)
        #  if self.debug:
        # pprint.pprint(self.stateManager.stateHistory)

        return payoff
예제 #9
0
    def __init__(self):
        self.utility = Utility()
        self.file_setup = FileSetup()
        self.cv_operations = CvOperations()
        self.image_processing = ImageProcessing()

        self.file_setup.setup_file_structure()
        self.date_id = self.utility.get_date_id()
예제 #10
0
def dataset_places():
    utility = Utility()
    places_brescia = utility.get_places(1, 0, 15)
    places_provincia = utility.get_places(0, 1, 15)
    places_mondo = utility.get_places(0, 1, 15)
    return render_template('dataset_places.html',
                           places_brescia=places_brescia,
                           places_provincia=places_provincia,
                           places_mondo=places_mondo)
 def createSchema(self, dbConnection, schemaName):
     utility = Utility()
     self.createDataTablesSQLScript(schemaName)
     sqlRead = FileUtil(ResourceLocation.DatabaseScript.value, "r")
     utility.writeLogs(ResourceLocation.LogFileLocation.value, "",
                       LogMessage.DBDatabaseCreation.value, "a", False)
     self.executeAndCommitToDatabase(dbConnection, sqlRead)
     utility.writeLogs(ResourceLocation.LogFileLocation.value, "",
                       LogMessage.Completed.value, "a", True)
예제 #12
0
def run_game():
    game = Game(Config())
    utility = Utility(
        [FringeSmoothness(),
         HoleCount(),
         EmptyRowsCount(),
         AverageHeight()], [3.2375932, 14.10950807, 22.32253916, 30.96122022])
    # game.run_agent(ProbabilisticPlanningHierarchicalAgent(utility))
    game.run_agent(LimitedProbabilisticPlanningHierarchicalAgent(utility))
예제 #13
0
def mappa_brescia_filtered():
    utility = Utility()
    query = ""
    count = 0
    if (urllib.unquote(str(request.args.get('elemento_stradale'))) == "1"):
        query = query + " or aggregated_type = \'elemento stradale\'"

    if (urllib.unquote(str(request.args.get('sede_scolastica'))) == "1"):
        query = query + " or aggregated_type = \'sede scolastica/culturale\'"

    if (urllib.unquote(str(request.args.get('luogo_turistico'))) == "1"):
        query = query + " or aggregated_type = \'luogo turistico/monumento\'"

    if (urllib.unquote(str(request.args.get('edificio_religioso'))) == "1"):
        query = query + " or aggregated_type = \'edificio religioso\'"

    if (urllib.unquote(str(
            request.args.get('suddivisione_cittadina'))) == "1"):
        query = query + " or aggregated_type = \'suddivisione cittadina'"

    if (urllib.unquote(str(request.args.get('edifici_civili'))) == "1"):
        query = query + " or aggregated_type = \'edificio civile\'"

    if (urllib.unquote(str(request.args.get('fermata_tpl'))) == "1"):
        query = query + " or aggregated_type = \'fermata tpl\'"

    if (urllib.unquote(str(request.args.get('edificio_sanitario'))) == "1"):
        query = query + " or aggregated_type = \'edificio sanitario\'"

    if (urllib.unquote(str(request.args.get('edificio_sportivo'))) == "1"):
        query = query + " or aggregated_type = \'edificio sportivo\'"

    n_citations = urllib.unquote(str(request.args.get('citations')))
    places = utility.get_places_filtered(1, 0, n_citations, query)

    circle_size = urllib.unquote(str(request.args.get('circle_size')))
    show_counters = urllib.unquote(str(request.args.get('show_counters')))

    elemento_stradale = 1
    sede_scolastica = 1
    luogo_turistico = 1
    edificio_religioso = 1
    suddivisione_cittadina = 1
    edifici_civili = 1
    fermata_tpl = 1
    edificio_sanitario = 1
    edificio_sportivo = 1

    params = dict()
    params['zoom'] = 13
    params['circle_size'] = circle_size
    if (show_counters == "1"):
        params['counters'] = "map.addLayer(circlesLayer);"
    else:
        params['counters'] = "0"

    return render_template('mappa.html', places=places, params=params)
예제 #14
0
def mappa_brescia():
    utility = Utility()
    places = utility.get_places(1, 0, 10000)

    params = dict()
    params['zoom'] = 13
    params['circle_size'] = 2
    params['counters'] = "map.addLayer(circlesLayer);"
    return render_template('mappa.html', places=places, params=params)
예제 #15
0
    def __init__(self):
        self.util = Utility()
        self.device = self.util.device
        self.package = 'com.gamehivecorp.taptitans'
        self.activity = 'com.gamehivecorp.ghplugin.ImmersivePlayerNativeActivity'

        self.util.positions = {
            'fairy': {
                'x': 0.5,
                'y': 0.25
            },
            'ad watch': {
                'x': 0.6,
                'y': 0.625
            },
            'close': {
                'x': 0.8825,
                'y': 0.2
            },
            'skill1': {
                'x': 0.1,
                'y': 0.9
            },
            'skill2': {
                'x': 0.25,
                'y': 0.9
            },
            'skill3': {
                'x': 0.4375,
                'y': 0.9
            },
            'skill4': {
                'x': 0.5625,
                'y': 0.9
            },
            'skill5': {
                'x': 0.75,
                'y': 0.9
            },
            'skill6': {
                'x': 0.9,
                'y': 0.9
            },
            'ad close': {
                'x': 0.85625,
                'y': 0.1015625
            },
            'dead': {
                'x': 0.5,
                'y': 0.5
            },
        }
        self.util.colors = {
            'ad': (-1, 33, 33, 33),
            'dead': (-1, 0, 0, 0),
        }
예제 #16
0
	def initial_setup(self, dns='', path='base'):
		self.make = path + '_' + dns
		
		'''CREATE DIRECTORY FOR IMAGES.'''
		FileOperations().mk_dir(self.make)
		
		'''CREATE TABLE TO STORE LINKS.'''
		DatabaseOperations().mk_table(self.make)
		
		'''Insert ROOT link.'''
		if path == 'base':
			href = self.base_url1
			child = Utility().hash(self.base_url1)
		elif path == 'relative':
			href = self.url
			child = Utility().hash(self.url)
			
		parent, scraped_status = 1, False
		DatabaseOperations().insert_into(table_name=self.make, to_insert=[(child, href, parent, scraped_status)])
예제 #17
0
 def test_borrow_again(self):
     print('test borrow_again')
     gc = GoogleCalendar()
     gcdb = GoogleCloudDb()
     utility = Utility(gcdb, None)
     bcs = BorrowConsoleState(utility, gc)
     print('Assert if TRUE')
     self.assertTrue(bcs.borrow_again())
     print('Assert if FALSE')
     self.assertFalse(bcs.borrow_again())
예제 #18
0
    def test_find_least_common_ancestor_should_return_none_when_root_given_none(
            self):
        utility = Utility()
        mock_root = None

        actual_result = utility.find_least_common_ancestor(root=mock_root,
                                                           node1=2,
                                                           node2=3)

        assert actual_result is None
예제 #19
0
def run_simulation(config):
    world = World.from_config(config)
    utility = Utility(
        [FringeSmoothness(), HoleCount(), EmptyRowsCount(), AverageHeight()],
        [3.2375932, 14.10950807, 22.32253916, 30.96122022]
    )
    # agent = LimitedProbabilisticPlanningHierarchicalAgent(utility)
    # agent = ProbabilisticPlanningHierarchicalAgent(utility)
    agent = PlanningTwoMovesHierarchicalAgent(utility)
    # agent = ReflexiveHierarchicalAgent(utility)
    return simulate_game(world, agent)
예제 #20
0
 def test_input(self):
     print('test input')
     list = []
     gc = GoogleCalendar()
     gcdb = GoogleCloudDb()
     utility = Utility(gcdb, None)
     book = Book(1, 'title', 'author', '12/09/99')
     list.append(book)
     utility.add_cur_results(list)
     bcs = BorrowConsoleState(utility, gc)
     self.assertEqual(bcs.input().book_id, 1)
예제 #21
0
파일: trainer.py 프로젝트: KNakane/GPR
 def __init__(self, model):
     self.regression_model = eval(model)()
     self.util = Utility(model)
     self.util.initialize()
     self.train_x, self.train_y = self.load(low=0, high=1, n=1000, std=0.1)
     self.test_x, self.test_y = self.load(low=-2,
                                          high=3,
                                          n=1000,
                                          std=0.1,
                                          test=True)
     self.message = OrderedDict({'model': model})
예제 #22
0
 def __init__(self, mount_point, fallback):
     self.utility = Utility(mount_point)
     self.mount_point = mount_point
     self.conv_handler = ConversationHandler(
         entry_points=[CommandHandler('unregister', self.unregister)],
         allow_reentry=True,
         states={
             REMOVER: [CallbackQueryHandler(self.remover, pattern=r'\w*rem2\b')]
         },
         fallbacks=[fallback]
     )
예제 #23
0
    def __init__(self):
        reload(sys)
        self.records_count = 0
        self.utility = Utility()
        self.error_log = self.setup_logger("error_log", "error_logs.log")
        self.parsing_log = self.setup_logger("parsing_log", "parsing_logs.log")

        if not os.path.exists("digest"):
            os.makedirs("digest")

        return
예제 #24
0
 def __init__(self, key_id, secret_key, args=None):
     self.utility = Utility(args)
     self.args = args or self.utility.updated_hash()
     self.event_id_exist = True
     self.key_id = key_id
     self.secret_key = secret_key
     self.data_dir = os.path.join(os.path.dirname(__file__), os.pardir,
                                  'data')
     self.has_configdir = False
     self.first_batch = True
     self.config = ConfigHelper()
예제 #25
0
def run_simulation(index, weights):
    config = Config()
    np.random.seed(seed + index)
    world = World.from_config(config)
    utility = Utility(
        [FringeSmoothness(),
         HoleCount(),
         EmptyRowsCount(),
         AverageHeight()], weights)
    agent = ReflexiveHierarchicalAgent(utility)
    return simulate_game(world, agent)
예제 #26
0
    def __init__(self):
        self.modules = list()  #Command Modules
        self.cmds = {}  #Commands
        self.cmdescs = {}  #command Descriptions
        self.bot = Bot(None)
        self.pref = "//"
        self.link = "https://discordapp.com/oauth2/authorize?client_id=354353934074380298&scope=bot&permissions=271674432"
        self.owner = None  #Owner Info
        self.servers = {}

        #Adding Commands
        if Owner(self).open():
            self.modules.append(Owner(self))
            self.cmdescs.update(Owner(self).settings().descs)
            for a in Owner(self).lis:
                self.cmds[a] = Command(a, self.modules[0].lis[a])
        if Roles(self).open():
            self.modules.append(Roles(self))
            self.cmdescs.update(Roles(self).settings().descs)
            for a in Roles(self).lis:
                self.cmds[a] = Command(a, self.modules[1].lis[a])
        if Filter(self).open():
            self.modules.append(Filter(self))
            self.cmdescs.update(Filter(self).settings().descs)
            for a in Filter(self).lis:
                self.cmds[a] = Command(a, self.modules[2].lis[a])
        if Utility(self).open():
            self.modules.append(Utility(self))
            self.cmdescs.update(Utility(self).settings().descs)
            for a in Utility(self).lis:
                self.cmds[a] = Command(a, self.modules[3].lis[a])
        if Chat(self).open():
            self.modules.append(Chat(self))
            self.cmdescs.update(Chat(self).settings().descs)
            for a in Chat(self).lis:
                self.cmds[a] = Command(a, self.modules[4].lis[a])
        if Entertainment(self).open():
            self.modules.append(Entertainment(self))
            self.cmdescs.update(Entertainment(self).settings().descs)
            for a in Entertainment(self).lis:
                self.cmds[a] = Command(a, self.modules[5].lis[a])
예제 #27
0
 def test_handle_input(self):
     print('test handle input')
     list = []
     gc = GoogleCalendar()
     gcdb = GoogleCloudDb()
     utility = Utility(gcdb, None)
     book = Book(1, 'title', 'author', '12/09/99')
     list.append(book)
     utility.add_cur_results(list)
     utility.user = MasterUser('username', 'firstname', 'lastname', 1)
     bcs = BorrowConsoleState(utility, gc)
     bcs.handle_input(book, utility)
예제 #28
0
def status(config, policy_id, policy):
    """
    Show status for a specific policy
    """
    base_url, session = init_config(config.edgerc, config.section)

    cloudlet_object = Cloudlet(base_url, config.account_key)
    utility_object = Utility()

    policy_name = policy
    policy_id = policy_id

    if policy_id and policy:
        root_logger.info("Please specify either policy or policy-id.")
        exit(-1)

    if not policy_id and not policy:
        root_logger.info("Please specify either policy or policy-id.")
        exit(-1)

    # get policy
    if policy:
        root_logger.info("...searching for cloudlet policy " +
                         str(policy_name))
        policy_info = utility_object.get_policy_by_name(
            session, cloudlet_object, policy_name, root_logger)
    else:
        root_logger.info("...searching for cloudlet policy-id " +
                         str(policy_id))
        policy_info = utility_object.get_policy_by_id(session, cloudlet_object,
                                                      policy_id, root_logger)

    try:
        policy_id = policy_info['policyId']
        policy_name = policy_info['name']
        root_logger.info('...found policy-id ' + str(policy_id))
    except:
        root_logger.info("ERROR: Unable to find existing policy")
        exit(-1)

    #setup a table
    table = PrettyTable(['Version', 'Network', 'PM Config', 'PM Version'])

    for every_policy in policy_info['activations']:
        table_row = []
        table_row.append(every_policy['policyInfo']['version'])
        table_row.append(every_policy['network'])
        table_row.append(every_policy['propertyInfo']['name'])
        table_row.append(str(every_policy['propertyInfo']['version']))
        table.add_row(table_row)

    table.align = "l"
    print(table)
 def getTableHeader(self, fileList):
     utility = Utility()
     filePaths = self.getFilePaths(fileList, "csv",
                                   ResourceLocation.DatabaseLocation.value)
     utility.writeLogs(ResourceLocation.LogFileLocation.value,
                       ("\n").join(filePaths), LogMessage.Files.value, "a",
                       False)
     tableHeaders = []
     for filePath in filePaths:
         fileHeader = ((FileUtil(filePath, "r")).getFileContent())[0]
         tableHeaders.append(fileHeader)
     return tableHeaders
예제 #30
0
    def test_find_least_common_ancestor_should_return_root_when_same_root_and_node2_given(
            self):
        utility = Utility()
        mock_root = Node(1)
        mock_node1 = 2
        mock_node2 = 1

        actual_result = utility.find_least_common_ancestor(root=mock_root,
                                                           node1=mock_node1,
                                                           node2=mock_node2)

        assert actual_result.key == mock_root.key == mock_node2