コード例 #1
0
ファイル: location_recognizer.py プロジェクト: gmmo526/JioNLP
    def _prepare(self):
        self.pkuseg = pkuseg.pkuseg(postag=True)

        china_loc = china_location_loader()
        world_loc = world_location_loader()
        self._mapping_china_location(china_loc)
        self._mapping_world_location(world_loc)
コード例 #2
0
ファイル: location_recognizer.py プロジェクト: ddxx01/JioNLP
 def _prepare(self):
     self.location_parser_obj = LocationParser()
     self.split_sentence_obj = SplitSentence()
     self.thuseg = thulac.thulac()
     #self.municipalities_cities = ['北京', '上海', '天津', '重庆', '香港', '澳门']
     china_loc = china_location_loader()
     self._mapping(china_loc)
コード例 #3
0
ファイル: location_parser.py プロジェクト: Hello-Toufu/jionlp
 def _prepare(self):
     # 添加中国区划词典
     china_loc = china_location_loader()
     self._mapping(china_loc)
     
     self.loc_level_key_list = ['省', '市', '县']
     self.loc_level_key_dict = dict(
         [(loc_level, None) for loc_level in self.loc_level_key_list])
     self.municipalities_cities = ['北京', '上海', '天津', '重庆', '香港', '澳门']
コード例 #4
0
    def _prepare(self):
        # 添加中国区划词典
        china_loc = china_location_loader(detail=self.town_village)
        china_change_loc = china_location_change_loader()
        self._mapping(china_loc, china_change_loc)

        self.loc_level_key_list = ['省', '市', '县']
        if self.town_village:
            self.loc_level_key_list.extend(['乡', '村'])
        self.loc_level_key_dict = dict([
            (loc_level, None) for loc_level in self.loc_level_key_list
        ])
        self.municipalities_cities = ['北京', '上海', '天津', '重庆', '香港', '澳门']
コード例 #5
0
 def _prepare(self):
     china_loc = china_location_loader()
     china_locations = dict()
     for prov in china_loc:
         if not prov.startswith('_'):
             china_locations.update(
                 {china_loc[prov]['_admin_code']: 
                  [prov, None, None]})
             for city in china_loc[prov]:
                 if not city.startswith('_'):
                     china_locations.update(
                         {china_loc[prov][city]['_admin_code']: 
                          [prov, city, None]})
                     for county in china_loc[prov][city]:
                         if not county.startswith('_'):
                             china_locations.update(
                                 {china_loc[prov][city][county]['_admin_code']: 
                                  [prov, city, county]})
     self.china_locations = china_locations
コード例 #6
0
    def _prepare_china_locations(self):
        china_location = china_location_loader()
        china_list = list()
        china_list.extend(list(china_location.keys()))
        for prov, cities in china_location.items():
            china_list.append(prov)
            china_list.append(cities['_full_name'])
            china_list.append(cities['_alias'])
            for city, counties in cities.items():
                if city.startswith('_'):
                    continue
                china_list.append(city)
                china_list.append(counties['_full_name'])
                china_list.append(counties['_alias'])
                for county, info in counties.items():
                    if county.startswith('_'):
                        continue
                    china_list.append(county)
                    china_list.append(info['_full_name'])
                    china_list.append(info['_alias'])

        return china_list