{'fraction_non_alphanumeric': 0.028145329025976898, 'fraction_numerical': 0.007169093242465814, 'mean_word_length': 4.712335692618807, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Towards Deep Semantic Analysis Of Hashtags

Hashtags are semantico-syntactic constructs used across various social networking and microblogging platforms to enable users to start a topic specific discussion or classify a post into a desired category. Segmenting and linking the entities present within the hashtags could therefore help in better understanding and extraction of information shared across the social media. However, due to lack of space delimiters in the hashtags (e.g #nsavssnowden), the segmentation of hashtags into constituent entities ("NSA"and"Edward Snowden"in this case) is not a trivial task. Most of the current state-of-the-art social media analytics systems like Sentiment Analysis and Entity Linking tend to either ignore hashtags, or treat them as a single word. In this paper, we present a context aware approach to segment and link entities in the hashtags to a knowledge base (KB) entry, based on the context within the tweet. Our approach segments and links the entities in hashtags such that the coherence between hashtag semantics and the tweet is maximized. To the best of our knowledge, no existing study addresses the issue of linking entities in hashtags for extracting semantic information. We evaluate our method on two different datasets, and demonstrate the effectiveness of our technique in improving the overall entity linking in tweets via additional semantic information provided by segmenting and linking entities in a hashtag.


Introduction
Microblogging and Social Networking websites like Twitter, Google+, Facebook and Instagram are becoming increasingly popular with more than 400 million posts each day. This huge collection of posts on the social media makes it an important source for gathering real-time news and event information. Microblog posts are often tagged with an unspaced phrase, prefixed with the sign "#" known as a hashtag. 14% of English tweets are tagged with at least 1 hashtag with 1.4 hashtags per tweet [1]. Hashtags make it possible to categorize and track a microblog post among millions of other posts. Semantic analysis of hashtags could therefore help us in understanding and extracting important information from microblog posts.
In English, and many other Latin alphabet based languages, the inherent structure of the language imposes an assumption, under which the space character is a good approximation of word delimiter. However, hashtags violate such an assumption making it difficult to analyse them. In this paper, we analyse the problem of extracting semantics in hashtags by segmenting and linking entities within hashtags. For example, given a hashtag like "#NSAvsSnowden" occurring inside a tweet, we develop a system that not only segments the hashtag into "NSA vs Snowden", but also tells that "NSA" refers to "National Security Agency" and "Snowden" refers to "Edward Snowden". Such a system has numerous applications in the areas of Sentiment Analysis, Opinion Mining, Event Detection and improving quality of search results on Social Networks, as these systems can leverage additional semantic information provided by the hashtags present within the tweets. Our system takes a hashtag and the corresponding tweet text as input and returns the segmented hashtag along with Wikipedia pages corresponding to the entities in the hashtag. To the best of our knowledge, the proposed system is the first to focus on extracting semantic knowledge from hashtags by segmenting them into constituent entities.

Related Work
The problem of word segmentation has been studied in various contexts in the past. A lot of work has been done on Chinese word segmentation. Huang et al. [3] showed that character based tagging approach outperforms other word based segmentation approaches for Chinese word segmentation. English URL segmentation has also been explored by various researchers in the past [2][5] [6]. All such systems explored length specific features to segment the URLs into constituent chunks 1 . Although a given hashtag can be segmented into various possible segments, all of which are plausible, the "correct" segmentation depends on the tweet context. For example, consider a hashtag 'notacon'. It can be segmented into chunks 'not, a, con' or 'nota, con' based on the tweet context. The proposed system focuses on hashtag segmentation while being context aware. Along with unigram, bigram and domain specific features, content in the tweet text is also considered for segmenting and linking the entities within a hashtag.
Entity linking in microposts has also been studied by various researchers recently. Various features like commonness, relatedness, popularity and recentness have been used for detecting and linking the entities in the microposts [11][12] [13]. Although semantic analysis of microposts has been studied vastly, hashtags are either ignored or treated as a single word. In this work, we analyse hashtags by linking entities in the hashtags to the corresponding Wikipedia page.

System Architecture
In this section, we present an overview of our system. We also describe the features extracted, followed by a discussion on training and learning procedures in Section 4.
As illustrated in Fig. 1, the proposed system has 3 major components -1) Hashtag Segmentations Seeder, 2) Feature Extraction and Entity Linking module, and 3) Segmentation Ranker. In the following sections, we describe each component in detail.

Hashtag Segmentations Seeder
Hashtag Segmentations Seeder is responsible for generating a list of possible segmentations of a given hashtag. We propose Variable Length Sliding Window technique for generating a set of highly probable hashtag segmentations for the given hashtag in the first step.
The Variable Length Sliding Window technique is based on an assumption that for a given hashtag "#AXB ", if A and B are valid semantic units (a single word or a collection of words concatenated together without a space), it is reasonable to hypothesize that X is also a valid semantic unit. For example, in the hashtag "#followUCBleague", since, 'follow ' and 'league' are well known dictionary words, and collectively this hashtag has some semantic meaning associated with it as it has occurred in a tweet, it is reasonable to assume that 'UCB ' is also a valid semantic unit with some meaning associated with it. The length of the sliding window(X) is varied from MIN LEN to MAX LEN with each iteration, and the window is slid over the hashtag. O(n 2 ) triplets of the form (A, X, B) are generated using the sliding window technique, where n is the length of the hashtag, X is the part of the hashtag lying within the window and A and B are the parts of the hashtag (of length ≥ 0) that lie on the left and right of the window respectively.
Each segment A and B of the triplet (A, X, B) is assigned a score according to the classically known Dynamic Programming based algorithm for Word Segmentation [7], hereby referred to as V iterbiW ordSeg. V iterbiW ordSeg takes a string as input and returns the best possible segmentation BestSeg (ordered collection of chunks) for that string. The score assigned to the segmentation by V iterbiW ordSeg is the sum of log of probability scores of the segmented chunks based on the unigram language model.
We used Microsoft Web N-Gram Services 2 for computing the unigram probability scores. The aforementioned corpus contains data from the web, and hence various acronyms and slang words occur in it. This holds critical importance in the context of our task. Next, for each triplet of the form (A, X, B), we compute the Sliding Window score as follows.
where W ordLenP rob(x) is the Ordinate value at x in Figure 2    To find the suitable value of MIN LEN and MAX LEN, we plot the percentage of frequency vs. word length graph using 50 million tweets 3 . Figure 2 shows the plot obtained.
It is observed that 79% of the tweet words are between length 2 to 6. Hence, we set MIN LEN and MAX LEN as 2 and 6 respectively.
The major benefit of this technique is that we are able to handle named entities and out of vocabulary (OOV) words. This is achieved by assigning score as a function of W ordLenP rob and smoothed backoff unigram probability (Equation 2) for words within the window. Now that we have a list of O(n 2 ) segmentations and their corresponding Score SlidingW indow , we pick the top k segmentations for each hashtag on the basis of this score. We set k = 20, as precision at 20 (P @20) comes out to be around 98%. This establishes that the subset of segmentations we seed, which is of O(n 2 ), indeed contains highly probable segmentations out of a total possible 2 n−1 segmentations 4 .

Feature Extraction and Entity Linking
This component of the system is responsible for two major tasks, feature extraction from each of the seeded segmentations, and entity linking on the segmentations. The features, as also shown in the System Diagram, are 1) Unigram Score, 2) Bigram Score, 3) Context Score, 4) Capitalisation Score, and 5) Relatedness Score. The first feature, Unigram Score, is essentially the V iterbiW ordSegScore computed in the previous step. In the following sections, we describe the rest of the features.
Bigram Score: For each of the segmentations seeded by the Variable Length Sliding Window Technique, a bigram based score using the Microsoft Web N-Gram Services is computed. It is possible for a hashtag to have two perfectly valid segmentations. Consider the hashtag #Homesandgardens. Now this hashtag can be split as "Homes and gardens" which seems more probable to occur in a given context than "Home sand gardens". Bigram based scoring helps to rank such segmentations, so that higher scores are awarded to the more semantically "appealing" segmentations. The bigram language model would score one of the above segmentations -"Homes and gardens" as P (Homes, and, gardens) ≈ P (Homes| < s >) * P (and|Homes) * Context Score: Context based score is an important feature. This is responsible for bubbling up of the segmentations with maximum contextual similarity with the tweet content. Using the CMU TweetNLP toolkit [8], words having POS tags like verb, noun and adjective are extracted both from the candidate segmentation of the hashtag and the tweet context, i.e. the text of the tweet other than the hashtag. Next, Wu Palmer similarity from Wordnet [9] is used on these two sets of words to find how similar a candidate segmentation is to the tweet context. These scores are normalized from 0 to 1.
Capitalisation Score: Hashtags are of varied nature. Some hashtags have a camelcase-like capitalisation pattern as in #HomesAndGardens, while others have everything in lowercase or uppercase characters like #homesandgardens. However, we can easily see that camelcase conveys more information as it helps segment the hashtag into "Homes and gardens" and not "Home sAnd Gardens". Capitalisation score helps us to capture the information conveyed by capitalisation patterns within the hashtags. We use the following two rules. For a hashtag, -If a set of characters occuring together are in capitals as in #followUCBleague, they are considered to be a part of an "assumed cluster" ("UCB" in this case).
-If it has a few capital letters separated by a group of lower case letters as in #SomethingGood, we assume the capital letters are delimiters and hence derive a few assumed clusters from the input hashtag.
We calculate the capitalisation score for a given segmentation S containing chunks s 1 , s 2 ...s i ..s n as where assumedClusterN otIntact(s i ) returns 1, if s i fails to keep an assumed cluster intact, and 0 otherwise.
Relatedness Score: Relatedness score measures the coherence between the tweet context and the hashtag segmentation. This score is computed on the basis of semantic relatedness between the entities present within the segmented hashtag and the tweet context. We calculated the relatedness between all the possible mentions in the segmented hashtag (M H ) to all other possible mentions in the tweet context (M T ). For computing relatedness between the two entities, we used the Wikipediabased relatedness function as proposed by Milne and Witten [4].
Relatedness between two Wikipedia pages p a and p b is defined as follows: where, in(p a ) is the set of Wikipedia pages pointing to page p a and W is the total number of pages in Wikipedia. The overall vote given to a candidate page p a for a given mention a by a mention b is defined as where P g(b) are all possible candidate pages for the mention b and P r(p b |b) is the prior probability of b linking to a page p b . The total relatedness score given to a candidate page p a for a given mention a is the sum of votes from all other mentions in the tweet context (M T ).
Now the overall relatedness score for a given hashtag segmentation, h is The detected page p a for a given mention in the segmented hashtag is the Wikipedia page with the highest rel a (p a ). Since not all the entities are meaningful, we prune the entities with very low rel a (p a ) scores. In our case, the threshold is set to 0.1. This disambiguation function is considered as state-of-the-art and has also been adopted by various other systems [12] [16]. The relatedness score, score h is used as a feature for hashtag segmentation. The entities in the segmented hashtag are returned along with the score for further improving the hashtag semantics.

Segmentation Ranker
This component of the system is responsible for ranking the various probable segmentations seeded by the Hashtag Segmentations Seeder Module. We generated five features for each segmentation using Feature Extraction and Entity Linking Module in the previous step. These scores are combined by modelling the problem as a regression problem, and the combined score is referred to as Score Regression . The segmentations are ranked using Score Regression . In the end, the Segmentation Ranker outputs a ranked list of segmentations along with the entity linkings.
In the next section, we discuss the regression and training procedures in greater detail.

Training Procedure
For the task of training the model, we consider the Score Regression of all correct segmentations to be 1 and all incorrect segmentations as 0. Our feature vector comprises of five different scores calculated in Section 3.2. We use linear regression with elastic net regularisation [14]. This allows us to learn a model that is trained with both L1 and L2 prior as regularizer. It also helps us take care of the situation when some of the features might be correlated to one another. Here, ρ controls the convex combination of L1 and L2.
The Objective Function we try to minimize is where X, y and w are Model Matrix, Response Vector, and Coefficient Matrix respectively. The parameters alpha(α) and rho(ρ) are set by cross validation.

Experiments and Results
In this section we describe the datasets used for evaluation, and establish the effectiveness of our technique by comparing our results to a well known end-toend Entity Linking system, TAGME [12], which works on short texts, including tweets.

Evaluation Metrics and Datasets
This section is divided into two parts. First, we explain the evaluation metrics in the context of our experiments, and later, we discuss the datasets used for evaluation.
Evaluation Metrics We evaluated our system on two different metrics. Firstly, the system is evaluated based on its performance in the segmentation task. As the system returns a list of top-k hashtag segmentations for a given hashtag, we evaluated the precision at n (P@n) scores for the hashtag segmentation task.
We also compared our P@1 score with Word Breaker 5 , which does the task of word segmentation. Secondly, the system is also evaluated on the basis of its entity linking performance on the hashtags. We computed Precision, Recall and F-Measure scores for the entities linked in the top ranked hashtag. For Entity Linking task, we used the same notions of Precision, Recall, and F-Measure as proposed by Marco et al. [10]. We compared our system with the state-of-the-art TAGME system. We show that adding semantic information extracted from the hashtags leads to an improvement in the overall tweet entity linking. For this, we performed a comparative study on the output of the TAGME system when a tweet is given with un-segmented hashtag vs. when it is given with segmented and entity-linked hashtag 6 . The case when un-segmented hashtag is fed to TAGME is considered  as a baseline to show how much improvement can be attributed to our method of enriching the tweet with additional semantic information mined by segmenting and linking entities in a hashtag.
Datasets The lack of availability of a public dataset that suits our task has been a major challenge. To the best of our knowledge, no publicly available dataset contains tweets along with hashtags, and the segmentation of hashtag into constituent entities appropriately linked to a Knowledge Base. So, we approached this problem from two angles -1) Manually Annotated Dataset Generation (where dataset is made public), 2) Synthetically generated Dataset. The datasets are described in detail below.

Microposts NEEL Dataset:
The Microposts NEEL Dataset [15] contains over 3.5k tweets collected over a period from 15th July 2011 to 15th August 2011, and is rich in event-annotated tweets. This dataset contains Entities, and the corresponding linkages to DBPedia. The problem however, is that this dataset does not contain the segmentation of hashtags. We generate synthetic hashtags by taking tweets, and combining random number of consecutive words with each entity present within them. The remaining portion of the tweet that does not get combined is considered to be the tweet context. If no entity is present within the tweet, random words are combined to form the hashtag. This solves the problem of requiring human intervention to segment and link hashtags, since now we already know the segmentation as well as the entities present within the hashtag.  Our system achieved an accuracy (P @1) of 91.4% in segmenting the hashtag correctly. The accuracy of Word Breaker in this case was 80.2%. This, however, can be attributed to a major difference between our system and Word Breaker. Word Breaker is not context aware. It just takes an unspaced string, and tries to break it into words. Our method takes into account the relatedness between the entities in a hashtag and the rest of the tweet content. Also, various other hashtag specific features like Capitalisation Score play an important part in improving the accuracy.
The comparative results of Entity Linking (in hashtags and overall), as well as P @n at various values of n for segmentation task are contained in Table 1.
All the values are calculated by k-fold Cross-validation with k=5.

Manually Annotated Stanford Sentiment Analysis Dataset:
To overcome the limitation that a synthetically generated hashtag might not actually be equivalent to a real world hashtag, we sampled around 1.2k tweets randomly from the Stanford Sentiment Analysis Dataset 8 , all of which contained one or more hashtags in them. After this, we generated around 20 possible segmentations for each hashtag by passing the hashtag and tweet from Segmentations Seeder Module. In the end we had around 21k rows which were given to 3 human annotators to annotate as 0 or 1 depending on whether or not a given segmentation is correct (for a given hashtag) according to their judgement.
Determining the "correct" segmentation for a given hashtag is particularly challenging, as there may be many answers that are equally plausible. It has been long established that there exist style disagreements among various editorial content ("Homepage" vs "Home page"). There are also various new words that come into existence like "TweetDeck" which are brand or product names. So,  Table 3: Importance of each feature our annotation guidelines in case of Stanford Sentiment Analysis Dataset allow for annotators to mark multiple segmentations as correct.
The rows were labelled 0, if at least 2 annotators out of 3 agreed on the label 0, similarly the rows were labelled 1, if at least 2 out of 3 annotators agreed on the label 1. The labels are essentially Score Regression as described in Section 4. The value of Fleiss' Kappa (κ), which is a measure of inter annotator agreement, comes out to be 0.89, showing a good agreement between annotators. This dataset is made public to ease future research in this area 9 .
Our system achieved a precision (P @1) of 87.3% in segmenting the hashtags correctly. The P @1 score of Word Breaker in this case was 78.9%. The difference in performance can again be attributed to same reasons as in the case of NEEL Dataset.
The comparative results of Entity Linking (in hashtags and overall), as well as P @n at various values of n for the task of segmentation are contained in Table 2. All the values are calculated by k-fold Cross-validation with k=5.

Results
We demonstrate the effectiveness of our technique by evaluating on two different datasets. We also show how overall Entity Linking in tweets was improved, when our system was used to segment the hashtag and link the entities in the hashtag. We achieved an improvement of 36.1% F-Measure in extracting semantics from hashtags over the baseline in case of NEEL Dataset. We further show that extracting semantics led to overall increase in Entity Linking of tweet. In case of NEEL Dataset, we achieved an improvement of 15.3% F-Measure over baseline in overall tweet Entity Linking task as can be seen in Table 1. Similar results were obtained for the Annotated Stanford Sentiment Analysis Dataset as well, as shown in Table 2. Further, we measured the effectiveness of each feature in ranking the hashtag segmentations. The results are summarized in Table 3.

Conclusions
We have presented a context aware method to segment a hashtag, and link its constituent entities to a Knowledge Base (KB). An ensemble of various syntactic, as well as semantic features is used to learn a regression model that returns a ranked list of probable segmentations. This allows us to handle cases where multiple segmentations are acceptable (due to lack of context in cases, where tweets are extremely short) for the same hashtag, e.g. #Homesandgardens.
The proposed method of extracting more semantic information from hashtags can be beneficial to numerous tasks including, but not limited to sentiment analysis, improving search on social networks and microblogs, topic detection etc.