{"id":23029668,"url":"https://github.com/antononcube/raku-data-geographics","last_synced_at":"2025-04-02T20:25:41.399Z","repository":{"id":216740060,"uuid":"741965795","full_name":"antononcube/Raku-Data-Geographics","owner":"antononcube","description":"Raku package for geographical data (like, country data, city data, etc.)","archived":false,"fork":false,"pushed_at":"2024-06-07T22:04:12.000Z","size":8747,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-08T11:13:07.638Z","etag":null,"topics":["city-data","country-data","geographic-data","geography","raku","rakulang"],"latest_commit_sha":null,"homepage":"https://raku.land/zef:antononcube/Data::Geographics","language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"artistic-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antononcube.png","metadata":{"files":{"readme":"README-work.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-01-11T13:35:41.000Z","updated_at":"2024-06-14T17:16:11.000Z","dependencies_parsed_at":"2024-01-24T01:25:22.467Z","dependency_job_id":"c4eb6ef6-d18f-4d4b-89c6-716200fef699","html_url":"https://github.com/antononcube/Raku-Data-Geographics","commit_stats":null,"previous_names":["antononcube/raku-data-geographics"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antononcube%2FRaku-Data-Geographics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antononcube%2FRaku-Data-Geographics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antononcube%2FRaku-Data-Geographics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antononcube%2FRaku-Data-Geographics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antononcube","download_url":"https://codeload.github.com/antononcube/Raku-Data-Geographics/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246886479,"owners_count":20849867,"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":["city-data","country-data","geographic-data","geography","raku","rakulang"],"created_at":"2024-12-15T14:16:39.917Z","updated_at":"2025-04-02T20:25:41.378Z","avatar_url":"https://github.com/antononcube.png","language":"Raku","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Data::Geographics\n\nRaku package for geographical data (like, country data, city data, etc.)\n\nProvides the functions `country-data` and `city-data`. \n\n-----\n\n## Installation\n\nFrom [Zef ecosystem](https://raku.land):\n\n```\nzef install Data::Geographics\n```\n\nFrom GitHub:\n\n```\nzef install https://github.com/antononcube/Raku-Data-Geographics.git\n```\n\n----\n\n## Using city-data Function\n\nThe `city-data` function is a powerful tool for retrieving and analyzing geographic data. Below is an example of how to use it.\n\nFirst, we need to import the necessary modules:\n\n```raku\nuse Data::Geographics;\nuse Data::TypeSystem;\nuse Data::Reshapers;\nuse Data::Summarizers;\n```\n\nThen, we can call the `city-data` function to get an array of city data:\n\n```raku\nmy @dsCityData = city-data();\n@dsCityData.\u0026dimensions \n```\n\nWe can then use the `records-summary` function to get a summary of the city data:\n\n```raku\nrecords-summary(@dsCityData);\n```\n\nWe can group the city data by country and print the number of cities in each country in a pretty table:\n\n```raku\ngroup-by(@dsCityData, \u003cCountry\u003e).Array.map({ $_.key =\u003e $_.value.elems }).Hash\n        ==\u003e to-pretty-table()\n        ==\u003e say();\n```\n\nWe can also get a nested hash of city data grouped by country, state, and city:\n\n```raku\nmy %countryStateCity = city-data():nested;\n%countryStateCity.elems\n```\n\nWe can then use the `deduce-type` function (from \"Data::TypeSystem\") to get the type of the nested hash:\n\n```raku\nsay deduce-type(%countryStateCity\u003cBulgaria\u003e);\n```\n\nWe can get the first defined record for the city of Stara Zagora in Bulgaria:\n\n```raku\nsay %countryStateCity{'Bulgaria';*;'Stara Zagora'}.grep(*.defined).head;\n```\n\nWe can also get the latitude and longitude of Stara Zagora:\n\n```raku\nsay %countryStateCity{'Bulgaria';*;'Stara Zagora';'Latitude'}.grep(*.defined).head;\nsay %countryStateCity{'Bulgaria';*;'Stara Zagora';'Longitude'}.grep(*.defined).head;\n```\n\n-----\n\n## NER and data retrieval\n\nIn this section we show how to use Named Entity Recognition (NER) of Geo-locations provided by \"DSL::Entity::Geographics\", [AAp1],\ntogether with the Geo-data provided by this package, (\"Data::Geographics\").\n\n\nIn this code, `$geoID` is obtained by calling the `ToGeographicEntityCode` function with a string `$s` and the *target* \"Raku-System\".\n\n```raku\nuse DSL::Entity::Geographics;\n\nmy $s = 'Fort Lauderdale, FL';\nmy $geoID = ToGeographicEntityCode($s, 'Raku-System');\n```\n\nThe `interpret-geographics-id` function is then used to interpret `$geoID` into its constituent parts, which are stored in `%geoIDParts`.\n\n```raku\nmy %geoIDParts = interpret-geographics-id($geoID):p;\n```\n\nDepending on whether the `Type` of `%geoIDParts` is \"CITYNAME\" or not, \nthe code then fetches the corresponding geographic data from `%countryStateCity` and stores it in `$res`.\n\n```raku\nmy $res = do if %geoIDParts\u003cType\u003e // 'NONE' eq 'CITYNAME' {\n    %countryStateCity{'United States';*;%geoIDParts\u003cName\u003e}.grep(*.defined);\n} else {\n    %countryStateCity{'United States';%geoIDParts\u003cState\u003e;%geoIDParts\u003cCity\u003e};\n}\n\nsay $res;\n```\n\n\n----\n\n## References\n\n[AAp1] Anton Antonov,\n[DSL::Entity::Geographics Raku package](),\n(2023-2024),\n[GitHub/antononcube](https://github.com/antononcube/Raku-DSL-Entity-Geographics).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantononcube%2Fraku-data-geographics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantononcube%2Fraku-data-geographics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantononcube%2Fraku-data-geographics/lists"}