{"id":21723574,"url":"https://github.com/chrismuir/address-parse-china","last_synced_at":"2025-09-10T21:16:30.442Z","repository":{"id":229336731,"uuid":"774158042","full_name":"ChrisMuir/address-parse-china","owner":"ChrisMuir","description":"Geolocation of Chinese Addresses in golang (no API keys required)","archived":false,"fork":false,"pushed_at":"2024-03-25T03:09:31.000Z","size":52,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-25T19:09:45.843Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChrisMuir.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-19T03:28:54.000Z","updated_at":"2024-04-11T01:53:52.000Z","dependencies_parsed_at":"2024-03-23T17:21:29.572Z","dependency_job_id":"c59b6b67-c0a1-46c8-9deb-da2fcc6ec84f","html_url":"https://github.com/ChrisMuir/address-parse-china","commit_stats":null,"previous_names":["chrismuir/address-parse-china"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisMuir%2Faddress-parse-china","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisMuir%2Faddress-parse-china/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisMuir%2Faddress-parse-china/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisMuir%2Faddress-parse-china/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChrisMuir","download_url":"https://codeload.github.com/ChrisMuir/address-parse-china/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244700644,"owners_count":20495578,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-26T02:40:23.490Z","updated_at":"2025-03-20T22:20:29.235Z","avatar_url":"https://github.com/ChrisMuir.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# address-parse-china\n\nGolang port of [this](https://github.com/ChrisMuir/geolocChina/) R package\n\nGolang package that takes Chinese location/address stings as input and returns geolocation data for each input string. \nThis package does not rely on an external API service to perform geocoding. It is dependency-free.\n\nThe functions are designed to work with business name strings and address strings. For each input string, the following \nvalues are returned: `Province`, `City`, `County`, `Provincial geocode`, `City geocode`, and `County geocode`.\n\nThe package is using geo substrings and associated geocodes from [Administrative-divisions-of-China](https://github.com/modood/Administrative-divisions-of-China) \non GitHub, put together by user [modood](https://github.com/modood).\n\nFor more info on geolocating Chinese strings, see [this](https://pdfs.semanticscholar.org/ca9d/2d09d0a2420a7ce398e14ed43f8cd7464705.pdf) \n2016 paper on the subject. The geolocation function works by using both substring matching and geocodes to validate child \nregions and infer parent regions.\n\n## Installation\n\n```\ngo get github.com/ChrisMuir/address-parse-china\n```\n\n## Example Usage\n\nFunction `GeoLocate()`\n\n```go\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\tapc \"github.com/ChrisMuir/address-parse-china\"\n)\n\nfunc main() {\n\tlocs := []string{\n\t\t\"大连市甘井子区南关岭街道姚工街101号\",\n\t\t\"浙江省杭州市余杭区径山镇小古城村\",\n\t\t\"大连御洋食品有限公司\",\n\t\t\"徐州雅莲连锁超市有限公司\",\n\t\t\"四川省南充市阆中市公园路63号\",\n\t\t\"同德县鲜肉蔬菜配送行\",\n\t}\n\tgeoLocs := apc.GeoLocate(locs)\n\tgeoLocsJson, _ := json.Marshal(geoLocs)\n\tfmt.Println(fmt.Sprintf(\"%+v\", string(geoLocsJson)))\n}\n```\n\n```json\n[\n  {\n    \"Address\": \"大连市甘井子区南关岭街道姚工街101号\",\n    \"Province\": \"辽宁\",\n    \"ProvinceCode\": 21,\n    \"City\": \"大连\",\n    \"CityCode\": 2102,\n    \"County\": \"甘井子\",\n    \"CountyCode\": 210211\n  },\n  {\n    \"Address\": \"浙江省杭州市余杭区径山镇小古城村\",\n    \"Province\": \"浙江\",\n    \"ProvinceCode\": 33,\n    \"City\": \"杭州\",\n    \"CityCode\": 3301,\n    \"County\": \"余杭\",\n    \"CountyCode\": 330110\n  },\n  {\n    \"Address\": \"大连御洋食品有限公司\",\n    \"Province\": \"辽宁\",\n    \"ProvinceCode\": 21,\n    \"City\": \"大连\",\n    \"CityCode\": 2102,\n    \"County\": \"\",\n    \"CountyCode\": 0\n  },\n  {\n    \"Address\": \"徐州雅莲连锁超市有限公司\",\n    \"Province\": \"江苏\",\n    \"ProvinceCode\": 32,\n    \"City\": \"徐州\",\n    \"CityCode\": 3203,\n    \"County\": \"\",\n    \"CountyCode\": 0\n  },\n  {\n    \"Address\": \"四川省南充市阆中市公园路63号\",\n    \"Province\": \"四川\",\n    \"ProvinceCode\": 51,\n    \"City\": \"南充\",\n    \"CityCode\": 5113,\n    \"County\": \"阆中\",\n    \"CountyCode\": 511381\n  },\n  {\n    \"Address\": \"同德县鲜肉蔬菜配送行\",\n    \"Province\": \"青海\",\n    \"ProvinceCode\": 63,\n    \"City\": \"海南藏族\",\n    \"CityCode\": 6325,\n    \"County\": \"同德\",\n    \"CountyCode\": 632522\n  }\n]\n```\n\nThere are also functions that expose the pkg data used for geolocation, `GetProvinceData()`, `GetCityData()`, and `GetCountyData()`\n\n```go\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\tapc \"github.com/ChrisMuir/address-parse-china\"\n)\n\nfunc main() {\n\tprovs := apc.GetProvinceData()\n\tprovsJson, _ := json.Marshal(provs)\n\tfmt.Println(fmt.Sprintf(\"%+v\", string(provsJson)))\n}\n\n```\n\n```json\n[\n  {\n    \"ProvinceName\": \"北京\",\n    \"ProvinceCode\": 11\n  },\n  {\n    \"ProvinceName\": \"天津\",\n    \"ProvinceCode\": 12\n  },\n  {\n    \"ProvinceName\": \"河北\",\n    \"ProvinceCode\": 13\n  },\n  {\n    \"ProvinceName\": \"山西\",\n    \"ProvinceCode\": 14\n  },\n  {\n    \"ProvinceName\": \"内蒙古\",\n    \"ProvinceCode\": 15\n  },\n  {\n    \"ProvinceName\": \"辽宁\",\n    \"ProvinceCode\": 21\n  },\n  {\n    \"ProvinceName\": \"吉林\",\n    \"ProvinceCode\": 22\n  },\n  {\n    \"ProvinceName\": \"黑龙江\",\n    \"ProvinceCode\": 23\n  },\n  {\n    \"ProvinceName\": \"上海\",\n    \"ProvinceCode\": 31\n  },\n  {\n    \"ProvinceName\": \"江苏\",\n    \"ProvinceCode\": 32\n  },\n  {\n    \"ProvinceName\": \"浙江\",\n    \"ProvinceCode\": 33\n  },\n  {\n    \"ProvinceName\": \"安徽\",\n    \"ProvinceCode\": 34\n  },\n  {\n    \"ProvinceName\": \"福建\",\n    \"ProvinceCode\": 35\n  },\n  {\n    \"ProvinceName\": \"江西\",\n    \"ProvinceCode\": 36\n  },\n  {\n    \"ProvinceName\": \"山东\",\n    \"ProvinceCode\": 37\n  },\n  {\n    \"ProvinceName\": \"河南\",\n    \"ProvinceCode\": 41\n  },\n  {\n    \"ProvinceName\": \"湖北\",\n    \"ProvinceCode\": 42\n  },\n  {\n    \"ProvinceName\": \"湖南\",\n    \"ProvinceCode\": 43\n  },\n  {\n    \"ProvinceName\": \"广东\",\n    \"ProvinceCode\": 44\n  },\n  {\n    \"ProvinceName\": \"广西壮族\",\n    \"ProvinceCode\": 45\n  },\n  {\n    \"ProvinceName\": \"海南\",\n    \"ProvinceCode\": 46\n  },\n  {\n    \"ProvinceName\": \"重庆\",\n    \"ProvinceCode\": 50\n  },\n  {\n    \"ProvinceName\": \"四川\",\n    \"ProvinceCode\": 51\n  },\n  {\n    \"ProvinceName\": \"贵州\",\n    \"ProvinceCode\": 52\n  },\n  {\n    \"ProvinceName\": \"云南\",\n    \"ProvinceCode\": 53\n  },\n  {\n    \"ProvinceName\": \"西藏\",\n    \"ProvinceCode\": 54\n  },\n  {\n    \"ProvinceName\": \"陕西\",\n    \"ProvinceCode\": 61\n  },\n  {\n    \"ProvinceName\": \"甘肃\",\n    \"ProvinceCode\": 62\n  },\n  {\n    \"ProvinceName\": \"青海\",\n    \"ProvinceCode\": 63\n  },\n  {\n    \"ProvinceName\": \"宁夏回族\",\n    \"ProvinceCode\": 64\n  },\n  {\n    \"ProvinceName\": \"新疆维吾尔\",\n    \"ProvinceCode\": 65\n  }\n]\n```\n\n## Benchmark\n\n```go\npackage address_parse_china\n\nimport \"testing\"\n\nfunc BenchmarkGeoLocate(b *testing.B) {\n\tlocs := []string{\n\t\t\"大连市甘井子区南关岭街道姚工街101号\",\n\t}\n\tfor i := 0; i \u003c b.N; i++ {\n\t\tGeoLocate(locs)\n\t}\n}\n```\n```bash\n~/address-parse-china % go test -bench=.\ngoos: darwin\ngoarch: arm64\npkg: github.com/ChrisMuir/address-parse-china\nBenchmarkGeoLocate-8       40614             26821 ns/op\nPASS\nok      github.com/ChrisMuir/address-parse-china        1.614s\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrismuir%2Faddress-parse-china","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrismuir%2Faddress-parse-china","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrismuir%2Faddress-parse-china/lists"}