key: cord-0781910-yc9w00qd authors: Ouerhani, Nourchène; Maalel, Ahmed; Ben Ghézala, Henda title: SMAD: SMart assistant during and after a medical emergency case based on deep learning sentiment analysis: The pandemic COVID-19 case date: 2022-05-09 journal: Cluster Comput DOI: 10.1007/s10586-022-03601-7 sha: 29518d352ffef7e0c73e544798554e2a6b0a1055 doc_id: 781910 cord_uid: yc9w00qd The huge cost of emergency situations could have fatal effects on humanity and society, and it could present a genuine threat to both of them. In fact, most people confronted with an emergency could feel psychological trauma, which will, for the most part, change over time as they can exhibit chaotic or even turbulent behaviours. The situation could worsen in the case of a pandemic as fear and anxiety invade and spread in addition to isolation and quarantine. In this paper, we propose to build a smart assistant, called SMAD, that could detect the symptoms of an emergency case as well as symptoms of a mental disorder while analysing the natural language speech of an ordinary citizen, during and after an emergency situation using natural language processing and deep learning sentiment analysis model to track the patient’s mental state during an ongoing conversation. Our proposed smart assistant is an online human-bot interaction that could handle a variety of physical and mental circumstances of any emergency situation. The proposed approach is a smart healthcare service that consists of four interconnected modules: The information understanding module, the data collector module, the action generator module, and the mental analysis module, which is based on the sentiment analysis model performed on a social media dataset using a pre-trained word-embedding model. According to the World Health Organization (WHO), one in eleven people who have lived through a war or other form of conflict or emergency in the previous ten years will suffer from a moderate or serious mental disorder. 1 In fact, most people could experience shock and/or denial during and after experiencing an emergency. In such cases, they show sadness, frustration, anxiety, anger, etc for several hours and sometimes days. 2 If these emotions continue, they may lead to more severe mental health issues such as post-traumatic stress disorder (PTSD) and depression. Consequently, providing assistance in an emergency is difficult, and providing it while considering the mental aspect is even more difficult. Given the aforementioned circumstances, this paper proposes a smart assistant, called SMAD, to help ordinary people overcome an emergency situation both physically and mentally. This assistance will take the form of a natural language conversation. Our assistant's smartness aspect will allow it to endure several challenges, including understanding the user's intent through natural language processing, recognizing the emergency, responding with the appropriate medical gestures, and tracking the patient's mental state during an ongoing conversation through a deep learning sentiment analysis model based on a pretrained word-embedding. The proposed approach is a smart healthcare service that is made up of four interconnected modules: the information understanding module (IUM), in which the natural language processing (NLP) is performed to help the assistant better understand the user's input (voice/text), the data collector module (DCM) that gathers user's non-confidential information to be used later by the action generator module (AGM) to generate and manage the assistant's answers. And, finally, the mental analysis module (MAM) that detects alarming behaviours in the text or voice input through a deep learning sentiment analysis model to help AGM deliver more adequate responses such as asking the patient a predefined set of questions from one of the validated scales for depression. If the patient's depression score, according to the used scale, seems to be very high, the patient should be referred to a list of the closest psychiatrists to his/her location. In the meantime, to alleviate stress, anxiety or depression, our assistant could provide some insights and positive responses. The remainder of the paper is organized as follows: First, we enumerate some solutions based on NLP and sentiment analysis model proposed to fight emergencies, in 2. Next, we explain our approach through a global architecture and the articulation between the different modules of our assistant 3. Then, we evaluate our work through a test case: COVID-19 in 4. Finally, we end the paper with a conclusion and an outlook on future works for interesting research directions 5. Virtual assistants prove their potential in the healthcare field. In our research, we found some papers that are similar to our proposal. Such as SPeCECA [1] , which is a smart pervasive chatbot for emergency case assistance and designated to interact with ordinary citizens to help them overcome emergency situations by suggesting the accurate first aid actions to be taken. Additionally, Mandy [2] is a chatbot that communicates with normal people using natural language in order to provide online healthcare suggestions. In [3] , a chatbot is designed to mimic human interaction in a medical case. It aims to help ordinary people choose the most appropriate way to prevent disease. Finally in [4] , a mobile chatbot is developed for health care service. This chatbot is able to collect and detect the user's daily health data, in order to diagnose chronic diseases, and provide preventive information and fast treatment after accidents that may occur in everyday life. A Japanese based Bespoke company used artificial intelligence to launch an online chatbot called Bebot that provides up-todate information on the COVID-19 and preventative actions with a possibility to check symptom [5] . However, all of the papers cited above neglect the psychological aspect during an emergency and/or while providing health assistance. The second part of our research studies the impact of virtual assistants and NLP to overcome stressful situations. In [6] , the authors built a sentiment analysis model based on the bidirectional encoder representations from transformers (BERT) [7] to study the impact of the COVID-19 in social life. The main purpose of this model is to gain insight into people's mental states via their publicly-posted opinions on a social media platform. For instance, a messenger chatbot was built to recognize and manage emotional stress through a predefined set of questions [8] . Based on almost the same principle, [9] presents a chatbot for mental health counselling also using a set of questions to assess a user's depression without a deep learning sentiment analysis. However, other works [10] [11] [12] [13] [14] have benefited from the power of deep learning sometimes to adjust the sentiment of the chatbot response, and sometimes to detect depression in text sequences. The evaluation of most of these models, which are based on LSTM [15] , was made using the performance Measures (recall, precision, accuracy and F1-score) as shown in Table 1 . Table 2 shows a comparative analysis of some research works based on NLP according to several criteria: virtual assistant-based (VA), emergency case assistance, physical assistance-based, psychological assistance-based (Question/answer(QA)/sentiment analysis model(SAM)), Beneficiary(expert/normal citizen). From the research we have conducted, it is becoming more common to use the power of NLP and virtual assistants to provide physical healthcare assistance [2] [3] [4] , even for emergency cases [1, 5] . On the other hand, NLP is also used for a psychological assistance through the use of text sentiment analysis systems [6, 10, 11] , others through a predefined set of questions [8, 9] . Another relevant fact is the emphasis on providing services to ordinary citizens [1-5, 8, 9] while minimizing direct contact with health professionals [6, 10, 11] However, the use of NLP for physical and psychological assistance for emergency cases is almost non-existent. For this reason, we seek a smart assistant to ensure communication and interaction with ordinary people using natural language processing (NLP) methods and based on a deep learning sentiment analysis model in order to assist them physically and psychologically during and after experiencing an emergency situation. During an emergency situation, an overgrowth of fear and anxiety is noticed whether for the patient or his companions. So, it is necessary to maintain calmness in order to aid the patient effectively and successfully. After experiencing an emergency, it is often critical to provide psychological assistance to the patient in order to avoid aggravating the situation. Therefore, our main contribution focuses on the use of NLP for the physical and psychological assistance of a patient in an emergency situation. In fact, our assistant could recommend the accurate first aid measures to take in any given emergency situation. Furthermore, a sentiment detection system is being developed to track the patient's psychological state. If our system predicts the possibility of depression, our assistant's responses change and a depression screening scale is launched to calculate the depression score. According to the used scale, in case of a serious depression, a professional psychotherapy intervention is required. As a result, our assistant advise the patient to visit the nearest psychiatrist promptly depending on his/her location. This process can be tailored to the specific emergency situation. Our adopted approach is organised in a modular manner. To improve the consistency of the implementation, the individual modules of the workflow have been separated into self-contained phases. SMAD's architecture is shown in Fig. 1 , so we divide it into four main modules: information understanding module (IUM), action generator module (AGM), data collector module (DCM) and mental analysis model (MAM). U U U Cameron et al. [9] U U U Yenter et al. [12] U U U Wang et al. [14] U U U Wang et al. [13] U U U Fig. 1 Architecture of SMAD Information understanding module (IUM) SMAD receives the input message sent from the user through IUM. The input could be either a voice or a text. The first task IUM have to do is the input recognition. As a result, there are two processes: -Text input process IUM transmits the input straight to the text analysis. -Voice input process IUM must convert speech to text before passing it on to the text analysis. Then IUM has to transform unstructured text to a structured representation composed of entities and intents through the Text Analysis sub-module. For this reason, the NLP is used. We have grouped the various steps of NLP into three categories as shown in Fig. 2 : -Lexical analysis Includes tokenization [16] splitting the text into tokens (punctuation marks, numbers, words, etc). -Entities extraction [19] Aims to limit the task to entities that could be important for the next step. -Semantic analysis Recognition of the goal that the user is attempting to achieve. This problem is treated as a multi-classification one, with classes representing the set of possible user intents. Mental analysis module (MAM) We created a sentiment analysis model to solve the sentiment detection problem. Sentiment analysis [20] is the process of computationally recognizing and classifying sentiments expressed in a piece of text. The sentiment analysis is a multi-class classifier: -Positive When the person presents the following emotions: happiness, joy and love as shown in Fig. 3 -Negative When the person presents the following emotions: sadness, anger and fear as shown in Fig. 4 -Neutral When the person presents no specific emotions as shown in Fig. 5 We want to detect and predict the user's emotions while communicating with our assistant. Rather than learning the response of immediate dependency, our model learns the response of long-term dependency. The MAM's output is stored in DCM as the user's mental status which is later used by the AGM. As regular recurrent neural networks (RNN) [21] are difficult to train due to exponential growth from repeatedly multiplying gradients over long sequences [22] , we used the long short term memory (LSTM) [15] network. We chose the LSTM because it outperformed gated recurrent units (GRU) [23] in our tests. Thus, as shown in Fig. 6 , we developed a sequential neural network model composed of four layers: one embedding layer and one LSTM layer followed by two fully-connected layers. We used the sigmoid activation function [24] as it can turn the output values into a value between 0 and 1. Action generator module (AGM) SMAD has to provide precise, effective, and rapid actions after recognizing and understanding the user's request. The action generator module (AGM) is in charge of this task. Since we have found no publicly-accessible conversational data sources between doctors and ordinary people about emergencies, AGM is trained on customised data that we have created from scratch. As this is a classification problem, we use the decision tree algorithm [25] to generate actions. The actions delivered by SMAD are dependent on the user's input. We have divided AGM into three sub-modules: -Emergency recognizer: This sub-module is trained to recognize the emergency using symptoms stored in the DCM. -Daily medical checker: After an emergency, a medical check-up is unquestionably the best way to get a full picture of the patient's health and allow early detection of complications. The data will then be stored in the Cluster Computing data collector module, so that experts (doctors, data scientists, and so on) will be able to access it. -Depression detector: AGM will be able to detect the user's actions during a conversation due to the MAM output. If the user sends three successive negative messages, AGM will try to make the user feel better by giving him or her reassuring messages or pleasantries, even asking him or her why he or she is in such a bad mood. However, if the bad behaviour persists throughout the conversation, AGM will immediately start one of the validated depression scales such as the depression anxiety stress scales-21 (DASS-21) [26] , Montgomery-Asberg depression rating scale (MADRS) [27, 28] , Hospital anxiety and depression scale (HADS) [29] , Beck depression inventory (BDI) [30] , patient health questionnaire (PHQ-9) [31] , etc. The use of a validated scale ensures the assessment of depression, anxiety, stress, and other related scores in order to assess the intensity of the user's status in those parameters. This will allow the AGM to determine whether or not the user is depressed. To speed up interactions between SMAD and the user, there are answers suggested to the user to control the conversation in order to minimize errors as much as possible. Data collector module (DCM) The purpose of DCM is to collect important non-confidential data (mainly symptoms) from users and create a dataset that can later be used in machine learning. This information could have an impact on SMAD's response. the COVID-19 case COVID-19 is the abbreviated name of the current 2019 coronavirus outbreak, which is a respiratory disease that spreads from person to person. 3 This outbreak is the seventh member of the coronavirus family that infects humans, unlike both MERS-CoV and SARS-CoV [32, 33] . It was first reported in December 2019 in Wuhan City in China. Up to February 2022, almost 5 Million people died worldwide because of the COVID-19, with more than 390 Millions infections reported in most countries, according to the World Health Organization. As a result, the COVID-19 has been declared a pandemic. 4 The COVID-19 pandemic has had a significant impact on global mental health, including anxiety, depression, trauma, and stress. It has also led to people fearing and panicking about COVID-19 infection [34, 35] . Worse still, suicide can be triggered by such mental health issues [36] . The following are the key goals of SMAD in case of a pandemic: -To raise awareness, but still send out reassuring messages to encourage people to take the necessary precautions against the pandemic. -To collect data from users (non-confidential information) for later use in machine learning. -To instruct both uninfected and infected individuals on how to defend themselves and their companions against further infection. -To determine whether or not the person is depressed and help him/her cope with stress in such a situation, otherwise, if a serious depression is detected, recommend that he or she have to consult a psychiatrist without delay. Our solution is cloud based. Therefore, we developed three separate, but interdependent applications: The mobile and web applications used by citizens and the cloud-based platform, where each of the proposed modules is deployed as a web service. Our web services are exposed as REST API micro-services on the cloud, referenced via their URI as shown in Fig. 7 . The IUM, as explained in Sect. 3, focuses on teaching the assistant how to interpret and understand user's inputs. We build a natural language understanding (NLU) model and feed it with training data to accomplish this task. After that, the model can learn to convert the data into a structured format with intents and entities. The user messages would then be classified into one or more user intents. We have already chosen to work with the spacy_sklearn pipeline, so that this intent classifier loads a pre-trained language model, which is then used to represent each word in the user's message as a word-embedding vector. Wordembedding models have been trained on massive text corpora created from Google news and similar sources so the representations may not always transfer well to specific domains. For example, the word ''python'' means a very large snake in the everyday context while it means a programming language in the field of computer science. These differences become even more relevant in our case because we are supposed to analyse medical data. Our solution is to simply train the global vectors for word representation (GloVe) [37] on our domain-specific data. Since the embeddings are already trained, the SVM [38] requires only little training to make confident intent predictions. So far, the assistant has been able to understand and process the user's input. The next step is to train the AGM to teach SMAD to respond to messages. Scenarios are the training data for AGM. The user's inputs are represented by intents and their corresponding entities, while the assistant's responses are represented by actions. Finally, we will train AGM based on the policies that should be followed. Because there are no publicly accessible conversational data sources between doctors and ordinary people about COVID-19, AGM is trained on customised data that we created from scratch. As this is a classification problem, we use the decision tree algorithm [25] to generate actions. Since the actions delivered by SMAD are dependent on the When the conversation starts, DCM gathers entities and stores them to create a dataset: -Location -Symptoms (fever, cough, dyspnea, ageusia, anosmia, etc) -Age -Gender -Status (infected, not infected/suspected to be infected) -Contact with infected person -Recent travel -Chronic diseases (Alzheimer disease and dementia, arthritis, asthma, heart disease, cancer, diabetes, etc) -User's mental status As for MAM, we used the deep learning library Keras [39] . This is where we get to use the LSTM layer. As we said in 3, our model is composed of an embedding layer, LSTM layer and two dense layers, which form a fully-connected neural network. The first dense layer is based on a ReLU activation function aiming to reach higher accuracy. This layer has no parameters. The second is a sigmoid dense layer. We added dropouts between layers to avoid overfitting. We chose a dataset from the social media world due to the fact that people nowadays express themselves through these platforms, especially Twitter. On a public Twitter dataset that includes 14,375 data with labelled sentiment (neutral, negative, positive), the sentiment analysis model is performed using the GloVe [37] model. After training and testing our model we got 92% of accuracy and 80.78% of F1-score on a validation set. When we measured the number of correct predictions, we found that negative messages work better for the Network than deciding the positive ones as shown in Table 3 . We evaluated our model's results on the basis of F1score and accuracy. F1-score, as the primary performance measure and accuracy as the secondary one. To calculate the F1-score we had to calculate first precision and recall Here are the equations that we used: Recall As shown in Table 4 , when we use LSTM Layer we get an F1-score of 80.78% whereas GRU has achieved a lower F1-score of 77.75%. The accuracy is 92% for both LSTM and GRU models. For this reason, we opt for the LSTM layer for our model. Also, we can observe low recall, high precision: This shows that we missed some Correct answers. When compared to other LSTM-based models mentioned in Sect. 2, our model is among the best in terms of accuracy. To sum up, SMAD keeps requesting information from the user to understand his/her situation and to collect information that will be used for further machine learning. Once the determination is complete, the actions suggested by SMAD are performed. Figs. 8, 9 and 10 demonstrate an example of an executed scenario: In this paper, we presented SMAD: smart assistant during and after a medical emergency case based on a deep learning sentiment analysis. The main purpose of SMAD is to assist a normal citizen to overcome an emergency situation physically and mentally. We build a deep learning sentiment analysis model to track the user's psychological state. When bad behaviour occurs and persists in an ongoing conversation, SMAD will execute a questionnaire based on validated scales to determine if the bad behaviour is related to a mental disorder or not. SMAD is presented through its four modules: information understanding module (IUM), action generator module (AGM), data collector module (DCM) and mental analysis module (MAM)in which a sentiment analysis model based on the LSTM neural network was applied. Henda Ben Ghézala is currently Professor of Computer Science at National School of Computer Sciences of Tunis. Her research interests lie in the areas of information modeling, databases, temporal data modeling, object-oriented analysis and design, requirements engineering and specially change engineering, method engineering. She is Director of the RIADI labs., ENSI, University of Manouba SPeCECA: a smart pervasive chatbot for emergency case assistance based on cloud computing MANDY: towards a smart primary care chatbot application Chatbots meet eHealth: automatizing healthcare Chatbot-based heathcare service with a knowledge base for cloud computing Launches free coronavirus information bot Sentiment analysis on the impact of coronavirus in social life using the BERT model BERT: pretraining of deep bidirectional transformers for language understanding, CoRR A Development of Chatbot for Emotional Stress Recognition and Management using NLP KO Towards a chatbot for digital counselling Detecting depression with audio/text sequence modeling of interviews Scalable Sentiment for Sequence-to-sequence Chatbot Response with Performance Deep CNN-LSTM with combined kernels from multiple branches for IMDb review sentiment analysis Attention-based LSTM for aspect-level sentiment classification Dimensional sentiment analysis using a regional CNN-LSTM model Long short-term memory The 15th International Conference on Computational Linguistics Part of Speech Taggers for Morphologically Rich Indian Languages: A Survey Lemmatization and morphological tagging in German and Latin: a comparison and a survey of the state-of-the-art Naming and Necessity A Practical Guide to Sentiment Analysis On the difficulty of training recurrent neural networks Gradient Flow in Recurrent Nets: The Difficulty of Learning Long-Term Dependencies A field guide to dynamical recurrent neural networks Neural machine translation by jointly learning to align and translate Representation of functions by superpositions of a step or sigmoid function and their applications to neural network theory C45: Programs for Machine Learning Manual for the Depression Anxiety Stress Scales The Montgomery Asberg and the Hamilton ratings of depression: a comparison of measures A new depression scale designed to be sensitive to change The hospital anxiety and depression scale Manual for the Beck Depression Inventory-II. Psychological Corporation The PHQ-9: A new depression and diagnostic severity measure Novel Coronavirus Pneumonia Emergency Response Epidemiology Team The Epidemiological Characteristics of an Outbreak of 2019 Novel Coronavirus Diseases (COVID-19) in China Wenjie T: A Novel Coronavirus from Patients with Pneumonia in The Fear of COVID-19 Scale: Development and Initial Validation Exploring COVID-19 stress and its factors in Bangladesh: a perception-based study Fear of COVID 2019: First suicidal case in India! Glove: global vectors for word representation LIBSVM: A library for support vector machines Publisher's Note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations. Nourche'ne Ouerhani is a PhD student in computer science at RIADI laboratory, National School of Computer Sciences (ENSI-Tunisia) His research interests are related to these topics: Machine Learning, Support Decision Systems, Knowledge Management and Semantic Web. He served as technical chair, TPC member and reviewer for many leading international CS conferences and journals. He is IEEE Acknowledgements The authors would like to thank Associate Professor Badii AMAMOU (Department of Psychiatry, University Hospital of Monastir) for his collaboration.Funding No funding was received. Conflict of interest The authors declare that they have no conflict of interest.Research involving human and animal participants This article does not contain any studies with human participants or animals performed by any of the authors.