## 4 Proposed Approach
### Priority Computing Unit
#### 4.2.2 Event Grader Module
Afterwards, the textual information of each \(w_{p}\in E_{t}\) is properly preprocessed to remove noisy information by using common NLP techniques: a twitter-aware tokenizer [70]; Snowball Stemmer to remove morphological affixes; and a process of stopword removal [70]. Further, each processed tweet is converted into vector representation \(w_{p}.f\) using term frequency-inverse document frequency (TF-IDF) [71] and fed, as training data, into a Multinomial Naive Bayes classification model which is used to determinate the contextual severity of a event. In general, the Naive Bayes (NB) algorithm has a high recall and precision while classifying textual data, being one of the most suitable algorithm this task [50; 62; 72]. The same event may have different associated risks according to its scope. In other words, a city is composed by several facilities and each one has its own routine. For example, a given bakery is probably crowded in the morning, while most nightclubs tends to be empty at daytime and crowded at night. Thus, an event happening at rush hour of a place (e.g., crime near a nightclub at night) is more important than an event happening while the place is under its capacity. To increase the priority precision, providing different approaches to events with the same nature in different regions, the \"scope\" is defined as the average number of _Twitter_ users on a certain area at the event moment, giving a good perception of the expected impact on people. To estimate the average population of a given area in a specific time window, it is assumed that the considered city (associated with the processed _Twitter_ data flow) follows a weekly routine (e.g., beaches are most frequented on Saturdays and Sundays). Following this premise, the city historical data is grouped according to the weekday in which the _tweet_ was sent, resulting in seven different data clusters. Further, a spatio-temporal query [57] is performed on the corresponding cluster (e.g., cluster for Saturday _tweets_), returning the number of users in the given region in different weeks. The average value of the result set is defined as the event scope value, which is an important information to compute the priority of the events. For a time window \(\Delta_{t}\), a set \(E\) of events is detected and fed into the Priority Computing Algorithm (PCA), defined in Algorithm 1. The PSA is responsible to calculate, scale and combine the priority components. Thus, for each event \(e\in E\), the contextual severity (\(sev(e)\)) and the associated scope value (\(sco(e)\)) are measured by using the previously mentioned techniques and attached to the event descriptor (lines 3-4). After that, the algorithm performs a normalization on the scope value by a factor of the maximum \(sev(e)\) divided by the maximum \(sco(e)\) (line 6), resulting in similar numeric scales for both severity and scope values. On line 8, we combine the grades obtained by the event weighted by a parameter \(0<\alpha<1\), resulting in the event priority (\(e.p\)). On line 9, the event descriptor \(e\) is stored in a max-heap \(Eo1\). After calculating the priority of all events, \(Eo1\) is returned containing all detected and classified events. ```
Input:\(E\)//List of detected events Input:\(\alpha\)//Balancing parameter Output:\(Eo1\)//Events associated to priorities
1\(Eo1\leftarrow\emptyset\)
2 foreach\(e\in E\)do
3\(sev(e)=calculateContextualSeverity(e)\)
4\(sco(e)=calculateSpatialSeverity(e)\)
5 end for
6\(performSpatialNormalization(sev,sco)\)
7 foreach\(e\in E\)do
8\(e.p=\alpha\times sev(e)+(1-\alpha)\times sco(e)\)
9\(Eo1.insert(e)\)
10 end for return\(Eo1\)
```  
**Algorithm 1**Priority Computing Algorithm (PCA)