示例#1
0
 def post(self):
     #  print self.get_argument('paras')
     paras = self.get_argument('paras').encode('utf-8')
     # print paras
     entity = Entity(paras)
     str = entity.save(paras)
     self.write(str)
示例#2
0
    def __get_semantic_relations_for_organization(self, cleaned_entity,
                                                  raw_entity):
        print('Searching {}'.format(cleaned_entity))
        relation_list = []
        query_results = self.__get_dbpedia_results(
            ceo_query.format(cleaned_entity))

        if query_results['results']['bindings']:
            ceoUri = query_results['results']['bindings'][0]['ceoUri']
            if ceoUri['type'] == "typed-literal":
                cleaned_dbpedia_text = self.__clean_dbpedia_text(
                    ceoUri['value'])
                relation_list.append(
                    Relation(Entity('ORGANIZATION', raw_entity, -1),
                             Entity('PERSON', cleaned_dbpedia_text, -1),
                             'dirigida por', 1, []))
            elif ceoUri['type'] == "uri":
                name_query_results = self.__get_dbpedia_results(
                    ceo_name_query.format(ceoUri['value']))
                if name_query_results['results']['bindings']:
                    relation_list.append(
                        Relation(
                            Entity('ORGANIZATION', raw_entity, -1),
                            Entity(
                                'PERSON', name_query_results['results']
                                ['bindings'][0]['ceoName']['value'], -1),
                            'dirigida por', 1, []))

        return relation_list
示例#3
0
文件: state.py 项目: minya/omnifocus
	def merge(self, tree):
		for element in tree:
			same = self.search_same(element)
			if same is None:
				self._tree.append(element)
			else:
				e = Entity()
				e.fromXmlNode(same)
				e.merge(element)
示例#4
0
 def __relation_list_builder(self, query_results, entity_text,
                             relation_text, first_entity_type,
                             second_entity_type):
     relation_list = []
     for result in query_results['results']['bindings']:
         relation_list.append(
             Relation(
                 Entity(first_entity_type, entity_text, -1),
                 Entity(second_entity_type, result['info']['value'], -1),
                 relation_text, 1, []))
     return relation_list
    def handle_action(self, action):
        if action.type == ActionTag.ProgramMemoryAdd:
            position = action.data['position']
            parent_id = action.data['parent_id']

            world_data_for_position = self.manager.get_world_data_for_position(
                position)
            if not entities_occupy_position(parent_id,
                                            world_data_for_position):
                #todo - consider making this an explicit action instead of just chucking it into the manager? for now, this is fine
                memory_segment = Entity([
                    Attribute(AttributeTag.ProgramMemory,
                              {'parent_id': parent_id}),
                    Attribute(AttributeTag.Visible),
                    Attribute(AttributeTag.WorldPosition, {'value': position}),
                    Attribute(
                        AttributeTag.DrawInfo, {
                            'draw_type': WorldRenderType.Memory,
                            'draw_type': WorldRenderType.Memory,
                            'z_level': 2
                        })
                ])
                self.manager.add_entity(memory_segment)

                parent = self.manager.get_entity_by_id(parent_id)
                parent.get_attribute(
                    AttributeTag.OwnedMemory).data['segments'].append(
                        memory_segment)

        return []
示例#6
0
 def post(self):
     paras = self.get_argument('paras')
     if (paras[0] == ","):
         paras = paras[1:]
     paras = paras.replace('/', '-')
     paras = paras.replace('|', '/')
     file = paras.split(',')
     entity = Entity(file)
     entity.edit(file)
     str = ""
     res = open("data/read.tmp")
     for line in res.readlines():
         str = str + "*" + line
     res.close()
     commands.getstatusoutput("rm -rf data/read.tmp")
     self.write(str[1:])
示例#7
0
 def __extract_entities_with_vision(self, text):
     result = self.vision_model.get_entities(text)
     entities = []
     for key in result:
         for entity in result[key]:
             if (self.__is_valid_entity(entity)):
                 e = Entity(self.__unify_types(key), entity, 0)
                 entities.append(e)
     return entities
    def test_is_input_row_in_capital_group_should_be_false4(self):
        entity = Entity("1111111111", "other", "Test sp. zoo",
                        "audit restricted client - PL SLP assigned")
        engagement = Engagement(entity, "XXXXX1", "bez znaczenia",
                                "Jan Kowalski", "21-02-2015", "Active")

        self.assertFalse(
            self.__strategy.is_input_row_in_capital_group(engagement),
            msg="Should not be in capital group")
示例#9
0
 def __extract_entities_with_standford(self, text):
     r = requests.post(self.standfor_model_url,
                       params=self.stanford_params_map,
                       data=text.encode('utf-8'))
     result = r.json()['sentences'][0]['entitymentions']
     return [
         Entity(self.__unify_types(entity['ner']), entity['text'], 0)
         for entity in result if self.__is_valid_entity(entity['text'])
     ]
示例#10
0
    def _parse_object_from_csv_line(self, line):

        try:
            line = line.strip('\n').split(sep=';')
            input_entity = Entity(line[0])

            return input_entity

        except IndexError as e:
            print(e)
示例#11
0
 def post(self):
     flag = 0
     paras = self.get_argument('paras')
     host = self.get_argument('host', default="127.0.0.1")
     if (paras[0] == ","):
         paras = paras[1:]
     paras = paras.replace('/', '-')
     paras = paras.replace('|', '/')
     file = paras.split(',')
     if (host.count("\n") > 0):
         host = host.split('\n')
         flag = 1
     entity = Entity(file, host, flag)
     entity.get(file, host, flag)
     str = ""
     str1 = ""
     value = []
     key = []
     res = open("data/result.tmp")
     for line in res.readlines():
         line = line.split(':')
         key.append(line[0])
         dic = {line[0]: line[1]}
         value.append(dic.copy())
     key = list(set(key))
     for k in key:
         str = k + ":"
         for v in value:
             for (k1, v1) in v.items():
                 if (k1 == k):
                     str = str + v1.strip() + ","
                 # str=str[:-1]+";"
         str = str + ";"
         str1 = str1 + str
     # print str1
     res.close()
     commands.getstatusoutput("rm -rf data/result.tmp")
     print str1
     self.write(str1)
示例#12
0
 def __order_entities(self, unified_entities, text):
     # remove duplicated entities
     unique_entities = set(unified_entities)
     for entity in unique_entities:
         entity.index = [m.start() for m in re.finditer(entity.text, text)]
     entities_with_index_normalized = []
     for entity_indexed in unique_entities:
         if len(entity_indexed.index) > 0:
             for index in entity_indexed.index:
                 entities_with_index_normalized.append(
                     Entity(entity_indexed.entity_type, entity_indexed.text,
                            index))
     entities_with_index_normalized.sort(key=lambda x: x.position)
     return entities_with_index_normalized
示例#13
0
文件: task.py 项目: minya/omnifocus
	def fromXmlNode(self, elem):
		Entity.fromXmlNode(self, elem)

		project_el_list = elem.findall('.//' + self._ns + 'project')
		project = None
		if len(project_el_list) > 0:
			project = Project.FromXmlElement(project_el_list[0])

		folder_el_list = elem.findall('.//' + self._ns + 'folder')
		folderRef = None
		if len(folder_el_list) > 0:
			folderRef = folder_el_list[0].attrib['idref']

		completed = Task.get_string_field(elem, self._ns, "completed")
		due = Task.get_string_field(elem, self._ns, "due")
		start = Task.get_string_field(elem, self._ns, "start")
		order = Task.get_string_field(elem, self._ns, "order")

		self.project = project
		self.folderRef = folderRef
		self.completed = completed
		self.due = due
		self.start = start
		self.order = order or "parallel"
示例#14
0
    def from_tree(cls, ctx: VhdlParser.Design_fileContext):
        document = cls()

        for design_unit in ctx.design_unit():

            context_clause = design_unit.context_clause()
            library_unit = design_unit.library_unit()

            for context_item in context_clause.context_item():
                library_clause = context_item.library_clause()
                use_clause = context_item.use_clause()

                if library_clause is not None:

                    # libraries
                    for name in library_clause.logical_name_list(
                    ).logical_name():
                        document.libraries.append(name.getText())

                elif use_clause is not None:

                    # 'use' imports
                    document.imports += [
                        name_ctx.getText()
                        for name_ctx in use_clause.selected_name()
                    ]

            primary_unit = library_unit.primary_unit()
            secondary_unit = library_unit.secondary_unit()

            if primary_unit is not None:

                entity_declaration = primary_unit.entity_declaration()
                configuration_declaration = primary_unit.configuration_declaration(
                )
                package_declaration = primary_unit.package_declaration()

                if entity_declaration is not None:
                    # entity
                    entity = Entity.from_tree(entity_declaration)
                    document.entities.append(entity)

            else:

                architecture_body = secondary_unit.architecture_body()
                package_body = secondary_unit.package_body()

        return document
示例#15
0
 def get(self):
     entity = Entity.get('ryan\'s blog')
     self.render('index.html', entity=entity)
示例#16
0
 def get(self):
   entity = Entity.get('The blog')
   self.render('index.html', entity = entity)
示例#17
0
    def get(self):
#         string = 'wawuee'
        exe = "insert into mytable (name,sex) values ('kevin','1')"
        db.execute(exe)
        entity = Entity.get('the5fire\'s blog')
        self.render('index.html', entity = entity)
示例#18
0
def discover_semantic_relations():
    entity = Entity('PERSON', 'iván Duque márquez', 0)
    response, relations = personal_knowledge.discover_semantic_relation(entity)
    print(relations)
示例#19
0
文件: folder.py 项目: minya/omnifocus
	def fromXmlNode(self, elem):
		Entity.fromXmlNode(self, elem)
示例#20
0
文件: index.py 项目: ttttsai/BookEx
 def get(self):
     entity = Entity('the5fire\'s blog')
     self.render('index.html', entity=entity)
示例#21
0
文件: index.py 项目: DaZhiZi/learn
 def get(self):
     entity = Entity.get('whister')
     self.render('index.html', entity=entity)
示例#22
0
 def get(self) :
   name = self.get_argument('name', '')
   entity = Entity.get(name)
   self.set_secure_cookie('name', name)
   #self.write(json_encode(entity.__dict__))
   self.render('index.html', entity = entity)
示例#23
0
 def get(self):
     entity = Entity("data")
     self.render('show.html', result='', zNodes=entity.interface("data"))
示例#24
0
for i in range(NUM_FLOORS):
    newfloor = generator.generate_floor(random.randint(15, 25),
                                        random.randint(15, 25))
    floors.append(newfloor)

for i in range(NUM_FLOORS):
    if i > 0:
        floors[i].get_entity("up_stair").get_component(
            StairComponent).set_destination_floor(floors[i - 1])
    if i < NUM_FLOORS - 1:
        floors[i].get_entity("down_stair").get_component(
            StairComponent).set_destination_floor(floors[i + 1])

current_floor = floors[0]
player = Entity("player",
                current_floor.get_entity("up_stair").x,
                current_floor.get_entity("up_stair").y, True)
player.add_component(PlayerComponent(player))
player.add_component(
    VisibleComponent(player, CanvasTile(None, tcod.Color(0, 255, 0), '@')))
current_floor.add_entity(player)


def go_up_to_floor(new_floor):
    change_floor(new_floor)
    put_player_on_downstair()


def go_down_to_floor(new_floor):
    change_floor(new_floor)
    put_player_on_upstair()
示例#25
0
 def get(self):
     entity = Entity.get('the5fire\'s blog')
     self.render('index.html', entity = entity)
示例#26
0
    def __init__(self, width, height):
        Menu.__init__(self, width, height)

        self.queued_actions_cost_so_far = 0
        self.action_history = []
        self.flagged_exit = False
        self.entity_manager = None
        self.game_state = GameState.TakingInput
        self.current_input_tree = innates_input_tree

        player_hardcoded_libraries = [
            Library('atk', 'temporary test library',
                    [config.game_functions.master_available_functions[0]])
        ]

        #try and load a save game. if that fails, initialize a baseline entity manager and try to feed in an action history. If both fail, the game simply ends up in a newgame state
        self.entity_manager = self.try_load_savegame()
        if not self.entity_manager:
            #currently hardcoded to test player movement
            self.entity_manager = EntityManager(self)
            self.entity_manager.add_entity(
                Entity([
                    Attribute(AttributeTag.Player,
                              {'max_actions_per_cycle': max_actions}),
                    Attribute(AttributeTag.Visible),
                    Attribute(AttributeTag.OwnedMemory, {'segments': []}),
                    Attribute(AttributeTag.WorldPosition,
                              {'value': Vec2d(2, 2)}),
                    Attribute(AttributeTag.MaxProgramSize, {'value': 5}),
                    Attribute(AttributeTag.ClockRate, {'value': 2}),
                    Attribute(
                        AttributeTag.DrawInfo, {
                            'character': 64,
                            'fore_color': libtcod.Color(157, 205, 255),
                            'back_color': libtcod.black,
                            'draw_type': WorldRenderType.Character,
                            'z_level': 2
                        }),
                    Attribute(AttributeTag.Libraries,
                              {'value': player_hardcoded_libraries})
                ]))
            #for x in range(10):
            self.entity_manager.add_entity(
                Entity([
                    Attribute(AttributeTag.HostileProgram),
                    Attribute(AttributeTag.Visible),
                    Attribute(AttributeTag.OwnedMemory, {'segments': []}),
                    Attribute(
                        AttributeTag.WorldPosition, {'value': Vec2d(20, 10)}
                    ),  #libtcod.random_get_int(0, 5, 45), libtcod.random_get_int(0, 5, 45))}),
                    Attribute(AttributeTag.MaxProgramSize, {'value': 5}),
                    Attribute(AttributeTag.ClockRate, {'value': 2}),
                    Attribute(
                        AttributeTag.DrawInfo, {
                            'character': 121,
                            'fore_color': libtcod.Color(255, 0, 0),
                            'back_color': libtcod.black,
                            'draw_type': WorldRenderType.Character,
                            'z_level': 2
                        })
                ]))

            self.try_load_action_history()
        else:
            self.entity_manager.parent_menu = self

        self.entity_manager.player_id = 1

        self.init_ui()
    def generate_floor(self, width, height):

        ####make tiles####

        tiles = [[DungeonTile(CanvasTile(tcod.Color(0, 0, 0), tcod.Color(255, 255, 255), '.'), False) for i in range(height)] for j in range(width)]
        for i in range(width):
            for j in range(height):
                if i == 0 or j == 0 or i == width-1 or j == height-1:
                    tiles[i][j].canvas_tile.character = '#'
                    tiles[i][j].is_obstacle = True

        floor = Floor(width, height, tiles)

        ####populate with necessary entities####

        #Stairs
        up_stair_x = random.randint(1, width-2)
        up_stair_y = random.randint(1, height-2)
        while True:
            down_stair_x = random.randint(1, width-2)
            down_stair_y = random.randint(1, height-2)
            if down_stair_x != up_stair_x or down_stair_y != up_stair_y:
                break
        up_stair = Entity("up_stair", up_stair_x, up_stair_y)
        down_stair = Entity("down_stair", down_stair_x, down_stair_y)
        up_stair.add_component(StairComponent(up_stair, True))
        up_stair.add_component(VisibleComponent(up_stair, CanvasTile(None, tcod.Color(255, 0, 0), '<')))
        down_stair.add_component(StairComponent(up_stair, False))
        down_stair.add_component(VisibleComponent(up_stair, CanvasTile(None, tcod.Color(255, 0, 0), '>')))
        floor.add_entity(up_stair)
        floor.add_entity(down_stair)

        #monsters
        for i in range(random.randint(1,20)):
            monster = Entity("monster " + str(i), random.randint(1, width-2), random.randint(1, height-2), True)
            monster.add_component(AIComponent(monster))
            monster.add_component(VisibleComponent(monster, CanvasTile(None, tcod.Color(0, 0, 255), '&')))
            monster.add_component(HealthComponent(monster, 1))
            floor.add_entity(monster)

        return floor