UL 2 C : Mapping User Locations to Countries on A rabic T witter (2021)

Abstract: Mapping user locations to countries can be useful for many applications such as dialect identification, author profiling, recommendation system, etc. Twitter allows users to declare their locations as free text, and these user-declared locations are often noisy and hard to decipher automatically. In this paper, we present the largest manually labeled dataset for mapping user locations on Arabic Twitter to their corresponding countries. We build effective machine learning models that can automate this mapping with significantly better efficiency compared to libraries such as geopy. We also show that our dataset is more effective than data extracted from GeoNames geographical database in this task as the latter covers only locations written in formal ways.

## introduction twitter is one of the most popular social media platforms in the arab region. spoken across more than 20 countries, arabic is one of the most dominant languages on twitter. arabic twittersphere presents us with an audience of diverse demographics. identifying countries of the users can help in various nlp tasks such as dialect identification, author profiling, and recommendation systems. identifying geolocation of twitter users can also help in event detection @xcite or disaster management @xcite . deducing a twitter user's location from geotagged tweets is difficult because less than 1% of tweets are geotagged @xcite . although twitter provides an option to users to declare their location in their profile, this is often noisy. users can choose to specify their location at the level of countries, regions, cities or towns. many of these names are written in informal way and sometimes in mixed languages. some of these names also contain emojis and special symbols. this makes it difficult to automatically infer the country of many users. this complication often prompts researchers to manually annotate user profiles for their countries. many works therefore, (e.g., @xcite ), manually annotate user profiles for their locations. being expensive, manual annotation often limits size of datasets. this is evident in the datasets by @xcite and @xcite since they both contain around 3k manually annotated users. related works for arabic primarily focus on dialect identification (e.g., @xcite @xcite , many of which involve manual annotation of dialects for sentences. our focus in this work significantly differs from dialect identification since our purpose is to provide a dataset that can be used to map twitter user locations to countries, which in turn, can aid in nlp tasks such as dialect identification or event detection. to our knowledge, there has been very few works for arabic that map noisy user locations to countries, with work by @xcite being one of the most notable ones and the closest to our work. @xcite map the most common 10k locations to arab countries in order to build a multidialectal arabic corpus. we refer to this dataset as top10kloc. our work extends top10kloc by increasing unique user locations from most common 10k to random 28k user locations obtained from 160k locations that are self-declared by users foot_0 . the contributions of this paper are summarized below: there has been a number of works that focus on identifying locations of twitter users. krishnamurthy et al. (2008) study geographical growth of twitter using utc offset data about tweets. hecht et al. (2011) built bayesian probability models on tweets to predict countries and state-level locations. they cover four countries (united states, the united kingdom, canada, and australia) and 50 states of united states. miura et al. (2017) use combination of text, metadata and user network representation with neurual network and utilize attention mechanism to predict geolocation. rahimi et al. (2018) use combination of text and user network with graph convolutional neural network to predict user geolocation. rahimi et al. (2015) note that although user network information can improve results, scaling to large datasets may become an issue. huang and carley (2019) build hierarchical neural networks for identifying location of twitter users. mahmud et al. (2014) also use hierarchical approach to predict home location of twitter users. the authors also identify if users are traveling to improve accuracy of location detection. despite arabic being one of the most popular languages on twitter, there has been very few works aimed at mapping user location in the arab region to countries. the related field of dialect identification has received significant attention recently. some works identify country-level dialects of arabic tweets (e.g., @xcite and some focus on dialects at user-level @xcite . while abdelali et al. (2020) as discussed earlier, the closest work to ours that targets converting user locations directly to countries is by @xcite . the authors collect 10k top user locations from 92m tweets. to map these locations to countries, the authors first use geonames dataset and then manually revise them. further, the authors show that after filtering out non-dialectal tweets, the countries obtained from the user locations can be strong indicator of dialects for the remaining tweets. ## data collection we used twarc search api foot_3 to collect arabic tweets. during the years 2018, 2019 and 2020, we collected 88m tweets with language filter set to arabic (lang:ar). from unique users who authored those tweets, we randomly selected 160k unique users for which we obtained 28k unique user locations. the user locations are information provided by twitter users, and they can be real locations (e.g., country and city names written in formal, informal ways or nicknames), landmarks, or unreal locations, and can be written in any language. in our data collection, we found that 62% of users pro-vided non-empty locations. around 60% of the non-empty locations are written in arabic and 40% are written in other languages, mainly in english. ## data annotation we used geopy foot_4 to map user locations to countries. geopy is a python package that locates the coordinates of addresses, cities, countries, and landmarks across the globe using third-party geocoders and other data sources. it includes geocoder classes for the openstreetmap nominatim, google geocoding api (v3), and many other geocoding services. figure 1 shows the output from geopy for an arbitrary location. in our study, we focus on mapping user locations to countries and we use iso 3166-1 alpha-2 for country codes 5 . we observed that geopy has difficulties in identifying many locations when they are short, have special characters, or unreal locations in addition to many correct locations. we used geopy output as an initial mapping of user locations to countries then all unique user locations were revised manually by an arabic native speaker. in addition to mapping clear locations to countries, the annotator was asked to consider any clues in user location string that indicate belonging to a specific country. some common examples and special annotation cases are shown in we randomly selected 500 unique user locations and checked annotation quality. we agreed with the manual annotations in 98% of the cases which indicates that annotation quality is very high. user locations and their country mapping (ul2c dataset) can be downloaded from this link: https://alt.qcri.org/resources/ ul2c-userlocationstocountries.tsv ## data analysis by assigning countries to unique user locations, we could map locations of ≈ 90k users to countries which represent 56% of the 160k users in our dataset. many of user locations were either empty (38%) or cannot be mapped to a specific country (6%). distribution of user countries is shown in figure 3 . although there are 22 arab countries, in our collection we didn't find locations from two countries, namely djibouti and comoros. we observe that users from saudi arabia (sa) represent more than half of arab twitter users. around 70% of twitter users are from gulf region (countries: sa, kw, om, ae, qa and bh), 4% of users are from levant region (jo, ps, lb and sy), 3% of users are from maghreb region (dz, ly, ma and tn), and users from other regions @xcite are in between. it's worth mentioning that country distribution obtained from ul2c and top10kloc datasets are very similar which indicates that most probably any random big collection of tweets will have similar country distribution. from the geographical map of all twitter users shown in figure 4 , we can see that arabic tweets come from almost all world countries. the top 5 countries outside the arab world where arabic tweets come from are: us (united states), gb (united kingdom), tr (turkey), de (germany) and fr (france) in order. this can give an estimation about countries that arabs live in outside arab countries. we notice also that tweets from us are more than those from individual maghreb countries like dz and tn. figure 5 shows the most common words used in user locations for 4 countries, namely sa (saudi arabia), eg (egypt), sy (syria) and dz (algeria) which represent major regions in the arab world (gulf, levant, nile basin and maghreb regions respectively). we can see country and major city names are written in bigger font in different languages. for example, while majority of names are written in arabic in sa (gulf region), they are written in arabic, english and french in dz (maghreb region). arabic and english names are widely used in eg and sy. this gives an indication about the popularity of language usage across different regions in the arab world. ## experiments and results in this section, we compare effectiveness of mapping user locations to countries with classifiers trained on different datasets, namely, ul2c, top10kloc, geonames and combination of these datasets. in our experiments, we merge all countries that are outside arab region to "unk/other" class, yielding a total of 21 classes (20 arab countries + unknown/other). ## interface we build an interface for users to map user locations to countries. the web interface is added to arabic social media analytics and understanding (asad) @xcite at https://asad. qcri.org . figure 6 shows sample outputs from the website. ## conclusion in this paper, we have presented a large manually annotated and publicly available dataset of twitter user locations from the arab region, mapped to their respective countries. we analyzed different characteristics of our data such as country distribution and top locations. we built machine learning models that can use the data to map user locations to countries more effectively compared to existing resources such as geopy python package or geonames geographical database. lastly, we provide a web interface to access this service easily.