## 4 Functional Model of the Framework
### Level 2--Traffic Congestion on Main Streets  
Congestion in main streets is usually due to obstacles such as excavations, traffic barriers, traffic accidents, rain and floods, and so on. Therefore, it is more important to discover the cause of congestion instead of just noting its occurrence. The solution is to then distribute the vehicular load of the congested street by informing the commuters about the condition of the street so that they can reroute to reach their destinations. Traffic lights can also be used to slow down the flow towards the congested street. The integration between different approaches listed below provides a higher level of accuracy and reliability for the information center to make such decisions. 1. Using information from service providers, such as Google Maps, OpenStreetMap, and so on, to determine the traffic status of streets and the degree of congestion, without specifying the cause or type of congestion. In our implementation of the framework, we used Google Maps. 2. Using crowd sourcing to exchange data between vehicles through a specific application in the event of any congestion or abnormal traffic on the street. This approach is more accurate as the incoming data are specific to the event, but it requires a high level of awareness from commuters in their use of the service. In future, this service can be automated within smart vehicles. In our implementation of the framework, we built an application for this service that works on smartphones, and contributes to the dissemination of this information to allow others to confirm the news. 3. Drones distributed at central vital points can be used to capture and share images to the information center to be processed automatically. This can provide information on the size of the congestion and help in distributing the vehicular load to other streets. In our implementation of the framework, we used an image processing algorithm to calculate the severity of the congestion that has been previously published [63]. Social media is one of the fastest ways to spread news today. In our implementation of the framework, we used Twitter. We proposed two algorithms based on text exploration and natural language processing to detect traffic congestion. The objective of first algorithm is to classify tweets related to the vehicular traffic in a particular street or area, whereas the second algorithm detects and reports the events related to congestion. Listing 2 shows the algorithm used to classify the tweets, which is described below. 1. Collect tweets from Twitter. 2. Filter the collected tweets and extract only those that are related to the specific area. 3. Remove repeated tweets to reduce the total number of tweets. 4. Pre-process each tweet in the selected group. 1. Clean the tweets of special letters, punctuation, letters from other languages, numbers, etc., and replace them with empty spaces. 2. Encode the tweet to the list of symbols in each blank space. 3. Remove the lexemes that do not affect the result of the classification (such as articles, pronouns, etc.) using the NLTK library [64]. 4. Normalize the text. This is needed when there are many similar characters with the same meaning. 5. Stammering--return the word to its original root by removing some characters (such as the prefix or suffix) using [PERSON]'s algorithm [64]. Note that the above listed steps reduce the size of the number of different words or terms by more than 60% compared to the original text. 5. Extract features and classify the tweets. 1. One approach that can be used is based on machine learning to extract the features of each tweet by calculating the TF-IDF factor for each term. IDF refers to the number of tweets containing the term T divided by the total number of tweets.