Full text
Universidade do Minho Escola de Engenharia Departamento de Informática Ana Rita Miranda Rosendo Ukraine War: An Online Corpus to analyze the impact of the War in Ukraine February 2024
Universidade do Minho Escola de Engenharia Departamento de Informática Ana Rita Miranda Rosendo Ukraine War: An Online Corpus to analyze the impact of the War in Ukraine Master dissertation Integrated Master’s in Informatics Engineering Dissertation supervised by Pedro Rangel Henriques Cristiana Araújo February 2024
i AUTHOR COPYRIGHTS AND TERMS OF USAGE BY THIRD PARTIES This is an academic work which can be utilized by third parties given that the rules and good practices internationally accepted, regarding author copyrights and related copyrights. Therefore, the present work can be utilized according to the terms provided in the license bellow. If the user needs permission to use the work in conditions not foreseen by the licensing indicated, the user should contact the author, through the RepositóriUM of University of Minho. License provided to the users of this work Attribution-NonCommercial CC BY-NC https://creativecommons.org/licenses/by-nc/4.0/
ii STATEMENT OF INTEGRITY I hereby declare having conducted this academic work with integrity. I confirm that I have not used plagiarism or any form of undue use of information or falsification of results along the process leading to its elaboration. I further declare that I have fully acknowledged the Code of Ethical Conduct of the University of Minho. Ana Rita Miranda Rosendo
ACKNOWLEDGMENTS I would like to express my gratitude to all of those who made substantial contributions to the successful conclusion of this work. Firstly, I would like to thank the advisor, Professor Pedro Rangel Henriques, and the supervisor, Cristiana Araújo, for the opportunity. I would also like to thank both of them for their guidance, advice, and help, as well as their continuous support throughout this process. Their guidance was fundamental to the development and success of this work. To my family, I express my deep gratitude for their constant support and encouragement throughout this process. Finally, I express my gratitude to all my friends for their invaluable support throughout this journey, be it academically or socially. They provided stress-free moments and enjoyable times that relieved the pressures of the work. iii
ABSTRACT This document reports a Master’s work, the final project of the 5th year of the Integrated Master’s in Informatics Engineering, that was accomplished at Universidade do Minho in Braga, Portugal. On February 24,2022, a conflict between two countries, Ukraine and Russia, began. The war between two countries is devastating and affects many people, both residents of the countries directly involved and neighboring countries. As a highly significant event, it gathers coverage from many sources globally, including traditional print newspapers, online news platforms, social networks, blogs, television programs, and more. However, all of this information is scattered across different websites and social networks. If researchers (in the areas of Linguistics, History, Humanities, etc.) and curious people want to analyze this data, their work will be very difficult. Therefore, it is essential to gather the information on a single platform. This work aims to create an online corpus in the Portuguese language regarding the Ukraine War, based on Portuguese online newspapers’ news as well as comments on social media. To fulfill the goal of this work, initially, a variety of news sources were considered, and the Portuguese online newspapers “Público” and “Jornal de Negócios” were selected, as well as the platform “Reddit”. To extract the required information, the technique of Web Scraping was used. Therefore, for each source, an extractor was developed that extracted the necessary information and saved it in a JSON file. Following that, Natural Language Processing Techniques were used to process the gathered information. Afterward, the extracted information was stored in a non-relational database, MongoDB. Finally, a website called GUCO was designed and implemented, providing users with the capability to navigate and explore the created corpus. The GUCO website is available at the address: https://guco.epl.di.uminho.pt/. Keywords: Online Corpus, Ukraine War, Rebuild the War through the News, Social Network Analysis, Web Scraping, Natural Language Processing iv
RESUMO Este documento relata um trabalho de mestrado, o projeto final do 5º ano do Mestrado Integrado em Engenharia Informática, que será realizado na Universidade do Minho em Braga, Portugal. Em 24 de fevereiro de 2022, o conflicto entre dois países, Ucrânia e Rússia, começou. A guerra entre dois países é devastadora e afecta muitas pessoas, tanto residentes nos países directamente envolvidos como nos países vizinhos. Sendo um evento altamente importante, este reúne cobertura de muitas fontes por todo o mundo, incluindo jornais tradicionais impressos, plataformas de notícias online, redes sociais, blogs, programas de televisão e muito mais. No entanto, toda esta informação está espalhada por diferentes websites e redes sociais. Se pesquisadores (das áreas de Linguística, História, Ciências Humanas, etc.) e curiosos quiserem analisar esses dados, o seu trabalho será muito difícil. Portanto, é fundamental reunir as informações numa única plataforma. Este trabalho tem como objetivo a criação de um corpus online na língua portuguesa sobre a Guerra da Ucrânia baseado em notícias de jornais online portugueses, bem como em comentários nas redes sociais. Para cumprir o objetivo deste trabalho, inicialmente, foram consideradas diversas fontes de notícias, e os jornais online portugueses “Público” e “Jornal de Negócios” foram selecionados como fontes de informação para o corpus, bem como posts e comentários da plataforma “Reddit ”. Para extrair a informação necessária, foi utilizada a técnica de Web Scraping. Portanto, para cada fonte foi desenvolvido um extrator que extraiu as informações necessárias e guardou-as num ficheiro JSON. De seguida, foram utilizadas Técnicas de Processamento de Linguagem Natural para processar a informação recolhida. Posteriormente, os dados foram armazenadas numa base de dados não relacional, MongoDB. Por fim, foi desenvolvido um website para que o utilizador possa explorar o corpus criado. O website GUCO pode ser acedido em: https://guco.epl.di.uminho.pt/. Palavras-chave: Corpus Online, Guerra da Ucrânia, Reconstrução da Guerra através das Notícias, Análise de Redes Sociais, Web Scraping, Processamento de Linguagem Natural v
CONTENTS 1Introduction 1 1.1Context 1 1.2Objectives 2 1.3Methodology Approach 3 1.4Research Hypothesis 3 1.5Document Structure 3 2State of the Art 5 2.1Online Corpus 5 2.2Computer-Mediated Communication 5 2.3Web Scraping 6 2.4Natural Language Processing 7 2.5Related projects 8 3Proposed Approach 11 3.1System Architecture 11 3.2Extractors 12 4GUCO, Corpus Construction 21 4.1Extractors 21 4.1.1Público 21 4.1.2Jornal de Negócios 25 4.1.3Reddit 29 4.2General JSON Format 32 4.3Data Processing 35 4.3.1Público 35 4.3.2Jornal de Negócios 36 4.3.3Reddit 37 5GUCO, Platform 39 5.1Mockups 39 5.2Backend 43 5.3Frontend 45 5.4A visit to the web platform 47 6Conclusion 55 6.1Future Work 56 vi
LIST OF FIGURES Figure 1System Architecture 12 Figure 2Example of a news publication as an input to the extractor 14 Figure 3 Example of the comments of a news publication as an input to the extractor 15 Figure 4(Mockup) GUCO Website: Home Page 40 Figure 5(Mockup) GUCO Website Menu: Project Page Option 40 Figure 6(Mockup) GUCO Website Menu: Extractors Page Option 41 Figure 7(Mockup) GUCO Website Corpus: Corpus Page 41 Figure 8(Mockup) GUCO Website Corpus: List of results 42 Figure 9(Mockup) GUCO Website Corpus: Result Page 43 Figure 10 GUCO Website: Home Page 48 Figure 11 GUCO Website: Introduction Page 48 Figure 12 GUCO Website: Aims Page 49 Figure 13 GUCO Website: System Architecture Page 49 Figure 14 GUCO Website: “Público” Extractor Page 50 Figure 15 GUCO Website: “Jornal de Negócios” Extractor Page 50 Figure 16 GUCO Website: “Reddit” Extractor Page 51 Figure 17 GUCO Website: Publications Page 51 Figure 18 GUCO Website: Team Page 52 Figure 19 GUCO Website Corpus: Corpus Page 53 Figure 20 GUCO Website Corpus: List of Results Page 53 Figure 21 GUCO Website Corpus: Result Page (1)54 Figure 22 GUCO Website Corpus: Result Page (2)54 vii
2 STATE OF THE ART In this section, an analysis of the current state of the art regarding the scope of this Master’s Work will be made. Therefore, the concepts of an online corpus, computermediated communication, natural language processing, and web scraping will be explored. Additionally, related work to this project will be presented. 2.1 online corpus According to the online Portuguese dictionaries Infopédia of the Porto Editora Group and Priberam, as well as the English online dictionary Dictionary, a corpus can be described as a compilation or collection of documents or information about a certain topic. It can come from a variety of sources, including books, newspapers, magazines, and online information, and it can be used for linguistic research and tasks involving natural language processing. The online corpus included in the NetLang Corpus project (Elias et al.,2021), which focuses on online hate speech, is an example of an online corpus. This project aims to create a corpus consisting of texts from various forums (comment boards of news sites and social networks) that represent the variables that will be analyzed. As such, they intend to analyze and annotate the linguistic structures and discursive organization of those texts. Finally, it aims to contextualize the data obtained in different realities within the community to define awareness and combat strategies. 2.2 computer-mediated communication Computer-Mediated Communication (CMC) can be described as “the process by which people create, exchange, and perceive information using networked telecommunications systems that facilitate encoding, transmitting, and decoding messages” (Romiszowski and Mason, 2013) and it can take place via technology tools like computers, cellphones, and the internet. Email, instant messaging, chat rooms, online forums, social media, and text messaging are just a few of the many activities that are included in the scope of CMC. It is utilized in distant communication, group communication, and other types of social interaction, and 5
2.3. Web Scraping 6 it enables communication between people who are not physically present, which can be advantageous in circumstances where face-to-face interaction is impossible or unpleasant. This Master’s project is focused on this concept. Thus, the purpose of this work is to create an online corpus about the conflict between Russia and Ukraine to recreate this social phenomenon. In order to do so, it will be necessary to gather information on the issue through social communication, and in the modern era, this communication occurs through both online newspapers and social networks, the latter of which is a more casual manner of disseminating information. 2.3 web scraping The technique of Web Scraping will be used to extract information from online sources. Web scraping is an old concept that has existed nearly since the internet was created. As a result, this term has been referred to by various names, including screen scraping and web harvesting. This method entails using software or scripts to automatically extract data from websites. That is, it consists of requesting data from a website’s server, usually in the form of HTML, parsing that data, and then extracting the needed information. To parse the HTML code and extract the needed data, a library like Beautiful Soup can be used (Mitchell,2018). This technique allows the extraction of a wide range of data types, including text, images, videos, and many others. It can be used for a range of tasks, including data collection for research and analysis, data collection for machine learning, and data collection for tasks involving natural language processing. For example, in the business intelligence area, it can be used to extract product information, such as prices and reviews, from various online businesses to compare prices and carry out a market analysis; in the area of data science, it can be used to extract information from social networks to do statistical and sentiment analysis and other things; etc (Khder,2021). Given that web scraping is an old concept, there are several projects that have been developed utilizing this technique. An example is the following project: “Extracting and Archiving Data from Social Media to Support Cultural Heritage Preservation in Nineveh” (Rashid and Qasha,2022). This work intends to collect information about Nineveh’s cultural heritage through many social media sites. With the programming language Python using the Selenium library, the authors of this project scraped social media, such as Twitter, Instagram and YouTube, to gather the needed information. After that, they cleaned the extracted data using Panda and regular expression libraries from Python. Finally, they stored the processed information in a NoSQL database and amazon simple storage s3. Another example is the project “Application of Web Scraping and Google API Service to Optimize Convenience Stores’ Distribution” (Le and Pishva,2015), which is a work on the optimization of convenience stores in Japan. In this project, the authors apply web scraping
2.4. Natural Language Processing 7 techniques to the NAVITIME website by using the programming language Ruby and its external library, Nokogiri. The project “CoviFight: A COVID-19 Resource Tracker Website with Location-wise Search using Web Scraping” is an example of a project that utilizes web scraping to collect information on a recent global issue (Singh et al.,2022). This project aims to create a real-time COVID- 19 resource tracker user-friendly website that scrapes data from social media platforms, such as Twitter, to display relevant information about the resources related to COVID-19, general guidance in symptoms, treatments, precautions, etc. To do so, they extracted the data from Twitter using the Twitter API and created the website where the front-end functionalities are implemented using HTML, CSS, and JavaScript, and the back-end functionalities have been coded in NodeJS. Finally, “Data Analysis by Web Scraping using Python” (Thomas and Mathur,2019) is another example of a project that uses web scraping. This project aims to extract information from different sources, for example, e-commerce sites such as Flipkart and Amazon, using the web crawler Scrapy, which is a web-crawling framework developed in Python. Moreover, the information is stored in a database and analyzed. 2.4 natural language processing Another concept addressed in this project is Natural Language Processing (NLP). NLP is a field of artificial intelligence and computer science that is focused on providing computers with the capacity to comprehend written and spoken words like humans (Kumar, 2013). For instance, NLP gives computers the ability to speak recognition, read text, analyze it, determine the sentiment, and pinpoint the main parts. Various examples of these concepts include digital assistants, voice-operated GPS systems, speech-to-text dictation software, data and text analysis, search engines, and others. To assist the computer in better understanding the text, NLP systems and models use various techniques from computational linguistics, computer science, mathematics, and statistics. NLP is a concept that has existed since the 1950s, and, as previously mentioned, there are multiple techniques. As a result, this concept and its techniques are the subjects of several projects, research papers, articles, etc. Taking into account the related projects found similar to this Master’s work and the aims of this project, the focus will be on the process of text preprocessing. The text preprocessing process consists of cleaning and preparing the data so that it is in a format that can be easily analyzed and processed. It is an essential step in NLP. Typically, this process involves a series of steps that can vary depending on both the type of data being processed and the task to which the data will be applied. For example, the project “Preprocessing the Informal Text for efficient Sentiment Analysis” (Hemalatha et al.,2012)
2.5. Related projects 8 aims to propose an efficient method for text preprocessing preceding the application of any classification algorithm to perform sentiment analysis. The text underwent the following preprocessing steps: removal of URLs, elimination of question words like “how”, “what”, and others, and exclusion of special characters, etc. Another project that is an example of the usage of text preprocessing is the following: “Public Sentiment and Emotion Analyses of Twitter Data on the 2022 Russian Invasion of Ukraine” (Garcia and Cunanan-Yabut,2022). This project aims to study the public sentiments of the international community about the Russian invasion of Ukraine. They performed multiple text preprocessing techniques, such as removing special characters, URLs, noise letters, and others, to prepare the data for emotion and sentiment analysis. 2.5 related projects Because it has been a significant cause of tension and instability in the region for many years, the conflict between Ukraine and Russia is widely discussed on the internet. There have been several incidents as a result of the war, which has historical, political, and economic roots. Furthermore, the ongoing war has had a profound impact on the global community, with multiple nations taking sides and imposing sanctions on each other. Considering the delicate nature of the subject, it has garnered significant attention from the media. After a search, the following project about the war was found: “Twitter Dataset on the Russo-Ukrainian War 1 ” (Shevtsov et al.,2022). This project aimed to analyze the trends and topics discussed concerning the conflict on the social media platform Twitter, analyzing the trends of users, hate speech, and propaganda, among other details. They used a dataset of 57.3million tweets from 7.7million people that was created using the search API of Twitter to extract old tweets, which enabled access to tweets from February 24,2022, for example. Twitter’s streaming API was used to gather more tweets based on trending hashtags associated with the specific topic to gather even more data. To analyze the trends of users, hate speech, and propaganda, among other details, they applied volume and sentiment analysis to the dataset created, more specifically, a pre-trained multi-language XLM-RoBERTa 2 model that enables sentiment analysis for zero-shot classification using user-defined entities. To gather military information, an XLM-RoBERTa model for zero-shot classification using the label “military” was used, and a custom-trained NER (Named-entity recognition) model, using as a base spaCy’s NER model 3 and trained with the created dataset, was applied to identify entities like location, person, weapon, etc., and sort the tweets based on where they were located in Ukraine. 1https://github.com/alexdrk14/RussoUkrainianWar_Dataset 2https://huggingface.co/vicgalle/xlm-roberta-large-xnli-anli 3https://spacy.io/universe/project/video-spacys-ner-model
2.5. Related projects 9 Another similar project was found, “A Reddit Dataset for the Russo-Ukrainian Conflict in 2022" (Zhu et al.,2022), which is an analysis of communities on Reddit about the conflict where they perceive the apparent preference for the pro-Ukraine stance in the “RU Conflict” category, among other aspects. After performing a keyword search to browse Reddit and narrowing down their selection to 12 subreddits, the authors of this project built a dataset comprising user comments about the dispute. The Pushshift.io API 4 was utilized to gather the data. To perform the data analysis and subsequently reach a definitive conclusion, they performed various characterization analyses on the daily volumes, posts’ engagement, rank, term frequency, linguistic aspects, and sentiment analysis of the text. In the case of the sentiment analysis of the text, they resorted to the Vader (Hutto and Gilbert,2014) sentiment analysis tool. Another similar project that also focuses on Reddit is “Happenstance: Utilizing Semantic Search to Track Russian State Media Narratives about the Russo-Ukrainian War On Reddit” (Hanley et al.,2022). This project focuses on the analysis of Russian propaganda on the platform. To analyze the Russian propaganda on new sites and social media, the authors of this project utilized sentence-level topic analysis using the MPNet 5 model on articles. To extract topic keywords, the dimensionality reduction algorithm UMAP (Becht et al.,2019), the density-based clustering algorithm HDBSCAN (McInnes et al.,2017), and the class-based TF-IDF (Özgür et al.,2005) were used. “Public Sentiment and Emotion Analyses of Twitter Data on the 2022 Russian Invasion of Ukraine” (Garcia and Cunanan-Yabut,2022) is another similar project that was found. This project aims to investigate the sentiments and emotions of people around the world and determine public opinion about the 2022 conflict between Ukraine and Russia by analyzing data extracted from Twitter on the first day of the conflict. For the collection, processing, and analysis of data, the authors employed the programming language R. To create a corpus with the extracted data, they used the Twitter API to extract the desired information, collecting a total of 39525 tweets. For each tweet, they performed multiple text preprocessing techniques (such as removing special characters, URLs, noise letters, etc) to prepare the text data. To classify the tweets in terms of polarity and emotion, they used a lexicon-based approach using Bayesian classifiers in the sentiment package. Another project about the conflict between Ukraine and Russia is titled “The Dynamics of Ukraine-Russian Conflict through the Lens of Demographically Diverse Twitter Data” (Sazzed,2022). By examining comments on the social media platform Twitter, this project aims to comprehend the opinions and reactions of its users. To do this, they used a dataset from the website Kaggle, a platform hosting multiple types of datasets covering various topics. The dataset contained about 80000 tweets from users in 7countries across 4 continents. Contrary to the information provided in the description of the selected dataset, 4https://psaw.readthedocs.io/en/latest/ 5https://github.com/microsoft/MPNet
2.5. Related projects 10 the authors found several tweets that had nothing to do with the war between Russia and Ukraine, as well as tweets in a language other than English, among other things. Therefore, to prepare the data for later application of NLP techniques such as sentiment analysis and topic modeling, the authors of this project resorted to text preprocessing. Later, they performed various types of statistical and semantic analysis to investigate user sentiments across the retrieved data. They also explored the presence of highly offensive words and phrases. Finally, to identify the most discussed and prevalent topics, they applied two topic modeling approaches: LDA and transformer-based BERTopic. An additional similar project was identified: “Aspect based Sentiment and Emotion Analysis with ROBERTa, LSTM” (Sirisha and Chandana,2022). This project aims to understand people’s emotions and opinions about this war by using multiple posts from people on Twitter. To accomplish its goal, the authors collected 484221 tweets from a dataset called “Ukraine Conflict Twitter Dataset” present on the website Kaggle. Then, to assess how Twitter discussions about the Ukraine-Russia war affect public sentiment and so perform the sentiment analysis, they applied a combination of the model Roberta with ABSA (Aspect Based Sentiment Analysis) and Long Short-Term Memory (LSTM). However, the objective of this Master’s work is different. As previously stated, the purpose is to reconstruct the 2022 conflict between Ukraine and Russia.
3 PROPOSED APPROACH This chapter presents a proposed approach for the project. The creation of an online corpus regarding the Ukrainian War is the aim of this project. To accomplish this, we must extract the required data, refine it using natural language processing to filter out the relevant information, and then store it in a repository. After completing all the procedures, the online corpus creation will begin. Finally, a website platform will be developed for users to explore the corpus. 3.1 system architecture As mentioned earlier, there are a number of steps that need to be completed in order to accomplish this project, starting with the search and selection of news pertinent to the theme, information extraction, etc., and concluding with the development of a web platform. Therefore, the main system’s architecture is depicted in Figure 1. After the analysis of the texts selected from online newspapers and social media and the selection of the richest, an extractor is applied that extracts the desired information that is later stored in a file. In the following stage, the information is formatted and reduced to only what is essential using natural language processing techniques. Subsequently, the resulting information is converted to JSON format and then stored in a repository, which will thus form the corpus. Finally, to explore the knowledge contained in the corpus, a query processor and Web platform will need to be developed. The query processor will take requests from users of the online platform, search the corpus, and then deliver the requested data. 11
3.2. Extractors 12 Figure 1: System Architecture 3.2 extractors To construct the corpus, it was necessary to select and extract information from online sources such as the Portuguese newspapers Público and Jornal de Negócios, as well as the social media platform and online community Reddit. Público was selected as one of the newspapers for this work due to its popularity until February 2023, according to a report from the newspaper itself. Additionally, this newspaper allows users to share their comments on any articles, which is valuable for this work since knowing people’s opinions on the subject is important. This newspaper provides several articles; however, some are exclusive to subscribers. For this work, only free-access articles were considered. Meanwhile, Jornal de Negócios was selected because it is a technical newspaper, in this case about economics and finance, and therefore has more articles about the economic impact of the conflict, for example. This newspaper enables its users to engage in discussions through the comments section and provides a range of articles accessible free of charge. However, certain articles are reserved for subscribers only, offering exclusive content to this group. We have once again limited our search to only resources that are available for free. Finally, several online platforms were analyzed, such as Facebook, Twitter, and Reddit, to collect the Portuguese’s opinion on the war. As Facebook does not allow information extraction, this option was quickly discarded. Between the two resulting options, Reddit was
3.2. Extractors 13 chosen because, as noted in the projects related to this work’s theme mentioned in Chapter 2, it is less used as a source of information. Concerning news publications, it was necessary to develop an extractor capable of extracting the desired information from a web page. For this purpose, research was conducted in the field of Web Scraping, the term used to describe the automated process of gathering structured data from the web for further analysis. A similar work, the Netlang project 1 ” (Elias et al.,2021;Henriques et al.,2019), which is not about the conflict between Ukraine and Russia but about online speech, as previously mentioned, was used as a reference to the development of the extractors. Therefore, a Python extractor was created that scrapes the website of the Portuguese newspaper Público, and extracts the article’s data. To do that, several Python libraries were used. The focus will be on the following ones: Selenium 2 and Beautiful Soup 3 . Selenium, which is an open-source program, was used to automate the web browser. At first, we chose Chrome as the preferred browser for this project. However, due to incompatibilities with the computer, we changed the chosen browser to Firefox. Therefore, the selenium driver used to open a browser instance and run the script created was the Firefox driver, geckodriver. On the other hand, Beautiful Soup, which is a library for pulling data out of HTML and XML files, was used to extract the desired data related to the news publication, such as the article text, author, title, etc. To extract the comments of a news publication, another extractor in Python, very similar to the previously discussed one, was developed. The same Python libraries were utilized. In the case of the information that was taken from a news article from the online newspaper, it is being stored in a JSON object that holds information about the article’s title and subtitle, its owner, the total number of shares, the data of the article’s publication and its extraction, the language, the platform where it is available, the article’s URL, the text of the article, and the name of the newspaper to which the article belongs. On the other hand, details regarding comments extracted from a newspaper article are saved in a list of JSON objects, where each object has a number of key/value pairs that store the details regarding the comment. The following information is saved: comment ID, commentator profile link, commentator name, comment, and answers to the commentator’s remarks. It should be noticed that the list of JSON objects in the field corresponding to the comments’ responses represents each comment’s response. In Figure 2and Figure 3, an example of an article to be extracted is displayed. It is possible to see the text that has to be extracted as well as some of the comments that were made when the article was published. Two examples of the JSON format in which the news and respective comments are extracted are also displayed. 1https://netlang-corpus.ilch.uminho.pt/ 2https://pypi.org/project/selenium/ 3https://pypi.org/project/beautifulsoup4/
3.2. Extractors 14 Figure 2: Example of a news publication as an input to the extractor
4 GUCO, CORPUS CONSTRUCTION This chapter describes the corpus construction process. In this section, the extractors used to collect information will be explained, as well as the format in which the information was stored. Additionally, the text-cleaning process will be explained. To build the corpus, it was necessary to select and extract information. After researching the project’s theme, several related projects were discovered, but none of them had the purpose of building a corpus in the Portuguese language about the conflict. Therefore, it was decided to create a corpus with information in the Portuguese language. To this end, as explained in Chapter 3, the Portuguese newspapers Público and Jornal de Negócios were chosen, as well as the social media platform and online community Reddit. 4.1 extractors Concerning the articles from newspapers and their comments, it was necessary to develop an extractor capable of extracting the desired information from a web page. As previously mentioned, a similar work, the Netlang project 1 ”Elias et al. (2021); Henriques et al. (2019), which is not about the conflict between Ukraine and Russia but about online hate speech, was used as a reference to the development of the extractors. 4.1.1Público In this section, the extraction of articles about the conflict present in the Portuguese online newspaper, “Público”, is explained. Firstly, an analysis of several news articles was carried out. It was observed that numerous articles lacked comments or had very few, while others had several, ranging from dozens to hundreds of comments. As a result, it was decided to extract news that had at least ten comments to extract the ones that had the most impact on people. Only articles within the time frame of February 24,2022, to July 31,2023, were considered. 1https://netlang-corpus.ilch.uminho.pt/ 21
4.1. Extractors 22 Later on, to gather information from “Público”, a Python extractor was created that scrapes their website and extracts the desired data. The extractor created receives the URL of the chosen article as an argument and returns a JSON file with the extracted data. To do that, as mentioned in Chapter 3, several Python libraries were used, such as Selenium and Beautiful Soup. Selenium, which is an open-source program, was used to automate the web browser. On the other hand, Beautiful Soup, which is a library for pulling data out of HTML and XML files, was used to extract the desired data related to the news publication. Listing 4.1shows the extractor in Python used to collect information related to an article in the newspaper “Público”. from selenium import webdriver from selenium.webdriver.firefox.service import Service from selenium.webdriver.firefox.options import Options from selenium.webdriver import Firefox from selenium.webdriver.common.by import By from bs4 import BeautifulSoup import time import json import re import sys opts = Options() binary = "/usr/bin/firefox" opts.binary_location = binary opts.add_argument("--headless") driver = Firefox(service = Service("../drivers/geckodriver"),options=opts) url = sys.argv[1] driver.get(url) time.sleep(20) dados = driver.find_element("id","story") html = dados.get_attribute("innerHTML") soup = BeautifulSoup(html, "html.parser") dict_news = {} title = soup.find("header", {"id":"story-header"}) for titleN in title.find_all("h1", {"class":"headline story__headline"}): dict_news['title'] = titleN.get_text().strip() subTitle = soup.find("header", {"id":"story-header"}) for subTit in subTitle.find_all("div", {"class":"story__blurb lead"}): dict_news['subtitle'] = subTit.get_text().strip() Listing 4.1: Extractor of Newspaper Articles coded in Python (fragment)
4.1. Extractors 23 To extract the comments of a news publication, another extractor in Python, very similar to the previously discussed one, was developed. In this case, the extractor receives the following data as arguments: the link to the article, to retrieve the article date that is used in the generated JSON filename, and the link to the article comments, that is, the article link plus the text “#comments”. The same Python libraries were used. The retrieved data is saved in a JSON file. At this step of the process, natural language processing techniques have not yet been applied; therefore, the extracted data is unformatted. In the case of information extracted from an article, it is being stored in a JSON object that holds information about the article’s title (title) and subtitle (subtitle), its owner (owner), the total number of shares (shares), the data of the article’s publication (datePosted) and its extraction (dateExtraction), the language in which it is written (language), the platform where it is available (plataform), the article’s URL (url), the text of the article (postText), the name of the newspaper to which the article belongs (nameNewspaper), and the number of comments (comments). Listing 4.2shows an example of the information extracted in JSON format from an article from the newspaper “Público”: 1{ 2"title":"Rússia assume presidência do Conselho de Segurança,a 'pior anedota' de 1 de Abril", 3"subtitle":"Liderança rotativa do órgão das Nações Unidas pertence agora a Moscovo. Ucrânia critica e EUA dizem que não há forma legal de impedir a Rússia de assumir o cargo.", 4"owner":[ 5"Paulo Narigão Reis", 6"Agências" 7], 8"shares":"21 shares", 9"datePosted":"1 de Abril de 2023,13:56", 10 "dateExtraction":"2023-04-11", 11 "language":"pt", 12 "plataform":"Newspaper", 13 "url":"https://www.publico.pt/2023/04/01/mundo/noticia/russia-assume- presidencia-conselho-seguranca-pior-anedota-1-abril-2044664", 14 "postText":[ 15 "A Rússia assumiu este sábado a presidência rotativa do Conselho de Segurança das Nações Unidas,tornando-se no primeiro país a dirigir o órgão cujo Presidente,Vladimir Putin,é alvo de um mandado internacional de captura por alegados crimes de guerra.","Leia os
4.1. Extractors 24 artigos que quiser,até ao fim","Com uma assinatura mensal tem acesso ilimitado a todos os conteúdos e cancela quando quiser","`` É a pior anedota do dia das mentiras do mundo'',disse o ministro dos Negócios Estrangeiros da Ucrânia,Dmitro Kuleba,comentando o facto de Moscovo assumir a presidência do órgão da ONU no dia 1 de Abril.", 16 ... 17 ], 18 "nameNewspaper":"Público", 19 "comments":"10 comments" 20 } Listing 4.2: Example of an extracted article from “Público” in JSON format On the other hand, details regarding comments extracted from a newspaper article are saved in a list of JSON objects, where each object has a number of key/value pairs that store the details regarding a comment. The following information is saved: the id of the comment (ID), the commentator profile link (Profile Link), the commentator ranking (Ranking), the commentator’s name (Name), the text of the comment (Comment), and the answers to the commentator’s remarks (Responses). It should be noticed that the list of JSON objects in the field corresponding to the comments’ responses represents each comment’s response. Listing 4.3shows an example in JSON format of some comments extracted from a newspaper article posted in “Público”: 1{ 2"ID":"3b55697d-f38c-4f2f-d8d1-08db04c372ee", 3"Profile Link":"https://www.publico.pt/utilizador/perfil/05d8f635-ccfc-41 ca-812b-9f3e6b9fcf77", 4"Ranking":"Influente ", 5"Name":"Catarina Pomba ", 6"Comment":"\n Será que o Secretário-Geral das Nações Unidas não poderia exprimir-se - e urgentemente,pois já estamos no dia 2 de abril - um tanto ou quanto fora 7da caixa? ...\n ", 8"Responses":[ 9{ 10 "ID":"9df362a4-3bcc-4a2d-2bd5-08db04d78ace", 11 "Profile Link":"https://www.publico.pt/utilizador/perfil/1f85203e -62da-414d-a56a-e93189dcc5be", 12 "Ranking":"Iniciante ",
4.1. Extractors 25 13 "Name":"joao reis ", 14 "Comment":"\n Catarina a subserviência do Secretário-Geral está em consonância com a hipocrisia generalizada dos países que compõem a organização ao remeteremse ao silêncio nos discursos e nas posições acerca da invasão da Ucrânia. \nSe a honestidade intelectual fosse uma caracterí stica desses países jamais um país invasor teria o direito a participar na organização,quanto mais liderá-la...\n " 15 }, 16 { 17 "ID":"d1a04d53-106d-4160-4bf6-08db256e9d62", 18 "Profile Link":"https://www.publico.pt/utilizador/perfil/05d8f635- ccfc-41ca-812b-9f3e6b9fcf77", 19 "Ranking":"Influente ", 20 "Name":"Catarina Pomba ", 21 "Comment":"\n Concordo 22 consigo,João Reis.\n " 23 } 24 ] 25 } Listing 4.3: Example of some comments extracted from a newspaper article posted in “Público” is presented in JSON format A total of 378 articles and 11334 comments were extracted. 4.1.2Jornal de Negócios In this section, the extraction of articles about the conflict present in the Portuguese online newspaper “Jornal de Negócios” is explained. In this case, the news selection process used was quite similar to that used in the newspaper “Público”. However, it was found that interesting news, such as the impact of the conflict on the countries’ economies, had few comments. Therefore, we decided to reduce the minimum number of comments to five and accept exceptions, that is, news with less than five comments but with information that was personally considered relevant. As in the case of the newspaper “Público”, only articles within the time frame of February 24,2022, to July 31,2023, were considered.
4.1. Extractors 26 To gather data from the selected articles, an extractor mirroring the one used for “Público” articles was developed. Concerning the extraction of comments, another extractor like the one designed for “Público” comments was created. In both cases, because the page structure of the “Jornal de Negócios” newspaper is different, some changes to the extractors were made. At this point, the extracted data is saved in JSON format and NLP techniques have not yet been applied, therefore text cleaning has not yet been done. Because of that, the information is not correctly formatted. Listing 4.4illustrates the JSON-formatted information extracted from a newspaper article featured in “Jornal de Negócios”: 1{ 2"title":"Economia mundial a caminho da estagnação nos próximos cinco anos, avisa FMI", 3"subtitle":"Instituição aponta para um crescimento inferior a 3% para este ano. A confirmarem-se as previsões de médio prazo,ou seja,num perí odo de cinco anos,serão as piores das últimas três décadas.", 4"owner":"Paulo Ribeiro Pinto", 5"datePosted":"06 de Abril de 2023,15:21", 6"shares":"n/a", 7"dateExtraction":"2023-04-21", 8"language":"pt", 9"plataform":"Newspaper", 10 "url":"https://www.jornaldenegocios.pt/economia/conjuntura/detalhe/ economia-mundial-a-caminho-da-estagnacao-nos-proximos-cinco-anos-avisa- fmi", 11 "postText":[ 12 "Apesar da grande robustez do mercado de trabalho e da resistência do consumo privado,a economia mundial deverá crescer este ano abaixo dos 3% e,no médio prazo,ter um comportamento fraco,só visto na d écada de 1990.","Em resumo é esta a ideia central deixada esta quinta-feira pela diretora-geral do FMI,Kristalina Georgieva,no discurso 13 que marca a abertura dos encontros do Banco Mundial e do Fundo Monetá rio,em Washington,nos Estados Unidos.","\"Depois de uma forte recuperação em 2021 chegou um choque severo 14 na guerra na Ucrânia de amplas consequências - o crescimento global em 2022 desceu para praticamente metade,de 6,1% para 3,4%\",começou por lembrar a chefe do FMI. Mas o abrandamento económico manteve-se
4.1. Extractors 27 este ano,frisou. E apesar de \"um mercado de trabalho resiliente tal como o consumo nas economias avançadas\",da recuperação da China devido à reabertura,a economia mundial deverá \"crescer menos de 3% em 2023\",apontou. Uma previsão em linha com as projeç ões de janeiro de 2,9%.", 15 ... 16 ], 17 "nameNewspaper":"Jornal de Negócios", 18 "comments":"\n 10\n comments" 19 } Listing 4.4: Example of an extracted article from “Jornal de Negócios” in JSON format However, in this case, the information extracted from the comments is slightly different since the comments in “Jornal de Negócios” have a different structure. That is, the mostvoted comment appears highlighted at the beginning. However, in that case, its number of likes and dislikes, as well as its responses, are not provided there. Then, the rest of the comments are presented, and the most-voted comment appears again in its correct order with all the information available. In this case, the following information is being saved: the id of the comment (ID), the title of the comment (that is, whether or not it is the most voted comment) (Comment’s Title), the commentator’s name (Name), the comment’s date (Comment Date), the number of likes and dislikes of the comment (Number of Likes and Number of dislikes), the text of the comment (Comment), and the answers to the commentator’s remarks (Responses). It should be noticed that the list of JSON objects in the field corresponding to the comments’ responses represents each comment’s response. Listing 4.5shows comments from a newspaper article from “Jornal de Negócios”, presented in JSON format: 1[ 2{ 3"ID":"n/a", 4"Comment's Title":"Comentário mais votado", 5"Name":"Anónimo", 6"Comment Date":"Há 55 dias e 7 horas", 7"Comment":"\"Barril de petróleo pode subir aos 100 dólares\":Com o corte anunciado pela OPEP+ na produção de petróleo à escala global, na ordem de de 1,16 milhões de barris por dia,a subida de preço daquele combustível é uma tendência altamente provável. Alguns analistas alertam mesmo para a eventualidade de os custos subirem
4.1. Extractors 28 de tal forma que alcancem os 100 dólares por barril.\" - https:// jornaleconomico.pt/noticias/barril-de-petroleo-pode-subir-aos-100- dolares-estes-sao-os-paises-que-seriam-mais-afetados-1015600", 8"Responses":[] 9}, 10 ... , 11 { 12 "ID":"2777102", 13 "Name":"Anónimo", 14 "Comment Date":"Há 55 dias e 7 horas", 15 "Number of Likes":"3", 16 "Number of dislikes":"0", 17 "Comment":"\"Barril de petróleo pode subir aos 100 dólares\":Com o corte anunciado pela OPEP+ na produção de petróleo à escala global, na ordem de de 1,16 milhões de barris por dia,a subida de preço daquele combustível é uma tendência altamente provável. Alguns analistas alertam mesmo para a eventualidade de os custos subirem de tal forma que alcancem os 100 dólares por barril.\" - https:// jornaleconomico.pt/noticias/barril-de-petroleo-pode-subir-aos-100- dolares-estes-sao-os-paises-que-seriam-mais-afetados-1015600", 18 "Responses":[ 19 { 20 "ID":"2777127", 21 "Name":"Anónimo", 22 "Comment Date":"Há 55 dias e 4 horas", 23 "Number of Likes":"1", 24 "Number of dislikes":"0", 25 "Comment":"Pensem é em acabar ou reduzir ao máximo possível este cancro! ", 26 "Responses":[] 27 } 28 ] 29 }, 30 ... , 31 { 32 "ID":"2777095", 33 "Name":"Joaquim Schieder da Silva", 34 "Comment Date":"Há 15 dias e 4 horas",
4.1. Extractors 29 35 "Number of Likes":"3", 36 "Number of dislikes":"2", 37 "Comment":"Entao iniciam uma guerra com a Russia estavam espera de que?", 38 "Responses":[ 39 { 40 "ID":"2777128", 41 "Name":"Anónimo", 42 "Comment Date":"Há 15 dias e 1 horas", 43 "Number of Likes":"0", 44 "Number of dislikes":"0", 45 "Comment":"A invasão,os crimes e as atrocidades não 46 oferecem dúvidas!", 47 "Responses":[] 48 } 49 ] 50 } 51 ] Listing 4.5: Example of comments extracted from a newspaper article from “Jornal de Negócios” in JSON format Ultimately, a total of 730 articles and 6119 comments were collected. 4.1.3Reddit This section explains the process of extracting posts and their comments from the platform “Reddit”. To extract the information, two extractors were developed in the programming language Python. For each extractor, the Python library PRAW 2 (Python Reddit API Wrapper) was used, as it provides an interface for accessing the Reddit API. PRAW is built on top of the Reddit API and allows users to connect their Python code to Reddit. To have access to the data, it was necessary to create a Reddit account and then go to reddit.com/prefs/apps and create a Reddit application. Following that, a scraper instance was created using the Reddit class from the PRAW library. Reddit is a platform full of information from various users from different parts of the world. It is divided into smaller communities, called “subreddit”. There is a community for anything and everything. For this work, we decided to extract information in Portuguese 2https://praw.readthedocs.io/en/stable/
4.1. Extractors 30 about the conflict between the two countries; therefore, only information present in the community “portugal” was considered. As such, in each extractor, the subreddit from which the information would be extracted (“r/portugal”) was defined. To only scrape posts related to the conflict between Ukraine and Russia, the subreddit was searched using the keywords “Ukraine” and “Russia”. The results were limited to the period between February 24,2022, and July 31,2023. The extracted data is currently being saved in JSON format. At this point, since NLP techniques have not yet been applied, the text cleaning has not yet been done. Because of that, the extracted information is unformatted. In the case of information extracted from a post, it is being stored in a JSON object that holds information about the post’s title (title), its score (score), its id (id), the post’s URL (url), the number of comments (comms_num), its timestamp (created), and its description (body). Listing 4.6presents an example of a post extracted from the platform “Reddit” in JSON format: 1{ 2"title":"Portugal prepara envio de quatro tanques para a Ucrânia", 3"score":"108", 4"id":"10kwru0", 5"url":"https://www.reddit.com//r/portugal/comments/10kwru0/ portugal_prepara_envio_de_quatro_tanques_para_a/", 6"comms_num":"104", 7"created":"2023-01-25 11:44:41", 8"extracted":1693534312, 9"body":"Portugal prepara envio de quatro tanques Leopard 2 para a Ucrânia, depois de a Alemanha ter cedido finalmente à pressão dos aliados a dado luz verde ao envio daqueles carros de combate. Refira-se que Portugal tem 37 daqueles blindados,12 dos quais totalmente operacionais. \n\nAceitam-se apostas:os 4 para enviar fazem parte dos 12 operacionais,ou vai ser como com helicópteros?\n\nFonte:[https:// www.cmjornal.pt/mundo/detalhe/portugal-prepara-envio-de-quatro-tanques- para-a-ucrania](https://www.cmjornal.pt/mundo/detalhe/portugal-prepara- envio-de-quatro-tanques-para-a-ucrania)" 10 } Listing 4.6: Example of a post extracted from the platform “Reddit” in JSON format On the other hand, details regarding comments extracted from a post are saved in a list of JSON objects, where each object has many key/value pairs that store the details regarding the comment. The following information is saved: the comment id (comment_id), the id of the
4.3. Data Processing 37 number of comments leaving it with just the numeric value. Both the article extraction date and publication date were changed to follow the general JSON format previously created (“yyyy-mm-dd hh:mm”). In the case of the information extracted regarding the comments of each article, an analysis was carried out and it was verified, once again, the exaggerated existence of line change characters in a row; the existence of comments that can be classified as SPAM, such as “O Google pagou por trabalho online diário de casa de 400 a800 dólares”,“Boas notícias para todos os meus amigos ..... Googleee pagando”, and “O Google pagou por cada semana de trabalho on-line em casa de 6.000 a10.000 euros”; and the presence of the character “\” behind the character corresponding to the quotation marks. As such, a Python script was developed that made the mentioned changes. In addition, it also eliminated repeated comments and adapted the format of the comment’s date to the general format created. Finally, this script adapted the format of the extracted information to the general format. Using a methodology similar to that of the “Público” newspaper, a final script was generated to combine the information from the articles and their corresponding comments into a single JSON file. 4.3.3Reddit In this section, an explanation of the text cleaning process applied to all the information extracted from the platform “Reddit” will be provided. As an initial step, an analysis of the extracted information was conducted. During this analysis, posts unrelated to the conflict were identified and, consequently, removed. Subsequently, two distinct scripts were created: one for the information linked to posts retrieved using the keyword “Ucrânia”, and the other for posts extracted with the keyword “Russia”. These scripts filtered out posts lacking specific keywords in their titles or body, such as “guerra”, “conflicto”, “invasao”, “conflito”, “batalha”, “confronto”, “vladimir”, “putin”, “zelensky”, “volodymyr”, “combate”, “disputa”, “refugiado”, “adesao a ue”, “adesao a uniao europeia”, “pro-ucrania”, and “pro-russia”. Following a thorough review of the outcomes, non-conflict-related posts and those with five or fewer comments were eliminated. Additionally, since the search using the keywords “Russia” and “Ucrânia” was conducted within the same subreddit, a Python script was developed to ensure the absence of duplicate posts. In the case of redundant posts, one of the duplicates was removed. While analyzing the posts, it was also observed that the extraction of the language in which the posts and comments were written, along with the identification of the post’s author, was not done. For this reason, two scripts in Python were created, one to extract the language used in the posts and comments, and the other to extract the authors of the posts.
4.3. Data Processing 38 In the case of the language identification, the nltk library was used to do text classification and guess the language of the text. After that, a script in python to clean the posts and adapt their format to the general format was created. This script removes the slashes before the quotation marks; change the quotation marks to “ ’ ’ ”; modify the date of the post and when it was extracted to the correct format (“yyyy-mm-dd hh:mm”) ; remove the extra slash in the post’s URL, remove special characters and convert the body of the post to a list of strings. Afterwards, the comments on the posts were analyzed. Firstly, it was found that the comments were not extracted in the correct order. Also, in several comments, a slash appeared before the quotation marks, there were several line change characters in a row, there was the presence of special characters, and an extra slash in the comment URL. To this end, a Python script was created that makes the mentioned changes, adapts the comment format to the general format, and orders the comments. Finally, a script in Python was developed to merge the information from the posts and their comments into a single JSON file.
5 GUCO, PLATFORM After extracting and applying natural language processing techniques, the next steps were to store the information and provide users with a platform to explore the knowledge contained in the corpus. Hence, this chapter describes the development of the project website created called “GUCO”. In this Chapter, the backend and frontend of the website will be explained. Additionally, the mockups designed for the website will be presented, as well as its ultimate design. Moreover, we will offer guidance on effectively navigating and utilizing the platform. 5.1 mockups In this section, the mockups designed for the GUCO site will be presented. Before building the website, mockups were created to formalize the idea of how the information should be presented to the users. To this end, the tool Figma1was used. Considering the theme of this project, it was decided that it would be best to design a website that is visually simple and user-friendly. As such, we decided to follow the same idea on almost every page: a fixed side menu on the left side of the page, and the right side of the page changes depending on the menu option that was selected. Figure 4represents the home page of the web platform. On the home page, the idea was to display the abstract and introduction of the project on the right side of the page and have a fixed menu on the left side of the page in which the user can choose where to go. 1https://www.figma.com/ 39
5.1. Mockups 40 Figure 4: (Mockup) GUCO Website: Home Page Figure 5displays the “Project” option on the menu. The menu provides the users with multiple options, including the project’s introduction, objectives, system architecture, and details about the extractors created for the project. Figure 5: (Mockup) GUCO Website Menu: Project Page Option
5.1. Mockups 41 Figure 6shows the “Extractors” option on the menu. This provides multiple options to the users, including information about the extractors created for extracting data from both newspapers, “Público” and “Jornal de Negócios”, as well as the extractor created for the platform “Reddit”. Figure 6: (Mockup) GUCO Website Menu: Extractors Page Option Figure 7portrays the “Corpus” page. On this page, the users can access the corpus. To do that, they need to fill out the provided form that allows them to select the platform they want to analyze the information from (Público, Jornal de Negócios, or Reddit) as well as the date range of that information. To make room for these options, the side menu was relocated to the top of the page. Figure 7: (Mockup) GUCO Website Corpus: Corpus Page
5.1. Mockups 42 Figure 8represents the page of the result of a search in the corpus. On this page, all the titles of the articles or posts resulting from the search in the corpus are presented to the users. Figure 8: (Mockup) GUCO Website Corpus: List of results After selecting one of the results from the search on the corpus, all the information about an article or post becomes available to the users. Figure 9illustrates the presentation of that information.
5.2. Backend 43 Figure 9: (Mockup) GUCO Website Corpus: Result Page Mockups were not created for the remaining pages as they would be identical to those created for the home page, for example. 5.2 backend In this section, the database used and how the data is being stored will be discussed, as well as the website backend development process.
5.2. Backend 44 For this project, it was decided to use a non-relational database due to its high flexibility, high performance, and low complexity. As such, a MongoDB 2 database was chosen. MongoDB is a document database in which data is stored in collections as BSON documents, which are formatted similarly to JSON. Therefore, the corpus information is stored in a database called “GUCOdb” and is divided into three different collections. That is, all articles and their comments extracted from the “Público” newspaper are stored in a collection called “publico”. On the contrary, all articles and their comments extracted from “Jornal de Negócios” are saved in a collection called “jornal_negocios”. Finally, all posts and respective comments extracted from the “Reddtit” platform are stored in a collection called “reddit_posts”. Throughout the process of storing the extracted information, we encountered a challenge. When attempting to import a JSON file containing data related to a Reddit post, an error occurred during the database import. This issue appeared due to the presence of numerous nested comments, exceeding MongoDB’s limit of 100 nested BSON documents. To address this limitation, we opted for GridFS, a specification for storing and retrieving files that surpasses MongoDB’s constraints. GridFS divides the file into parts, or chunks, and stores each chunk as a separate document. To store each document, two collections were used. One stores the file chunks, and the other stores the document metadata. After storing the information, the process of creating a Web platform in which users would be able to explore the corpus was initiated. To do so, the Python framework Flask 3 was used. Flask is a framework designed for the Python programming language, used to build web applications. In this project, the Flask application (app) is divided into many scripts and folders. The “app.py” script is used to create the Flask app. Also, in this script, the blueprint created in “views.py” is imported and registered. In the “views.py” script, a blueprint is created to organize the related views, which are the functions used to respond to the requests of the application. Additionally, in this script, the connection to the database is made. In the folder called “templates”, all the HTML files used to render the information on the browser are located. Finally, in the folder called “static”, the CSS file used to define the visual presentation of the HTML elements is located. The focus will be on the “views.py” script and the functions created responsible for handling HTTP requests and rendering responses. Firstly, a function to define the route to the home page was created. This route handles the requests to the URL “/”. It dynamically retrieves a list of images from the “images” folder within the “static” directory, creates a list of captions and credits for each image and subsequently renders the “base.html” template by passing the images, captions, and credits as variables. Then, a function was crafted to establish the route to the team page. This particular route manages requests to 2https://www.mongodb.com 3https://flask.palletsprojects.com/en/3.0.x/
5.3. Frontend 45 the URL “/team” and renders the “team.html” template. Subsequently, another function was created to define the route to the publications page. It responds to requests from the URL “/publications” and renders the “publications.html” template. After that, a new route to the introduction page of the project was implemented. It handles the request from the URL “/intro” and renders the “intro.html” template. Following that, a route to the objectives of the project page was created. It handles the request from the URL “/aims” and renders the “aims.html” template. For the pages presenting the extractors designed to collect information from three distinct sources, many routes were established. Each route handled the requests from different URLs, such as “/extr_pub”, “/extr_jn”,“/extr_red”, and rendered the “extr_pub.html”, the “extr_jn.html”, and the “extr_red.html” templates respectively. Additionally, the route to the corpus page was created. It handles a “GET” or “POST” request to the URL “/corpus”. First, it tests if the request is typed “POST”. If true, it stores the information that was inserted from the user in the form and uses it to search the database for the required articles or posts. Then, it renders the “corpus.html” template by passing multiple variables such as the final result of the search on the corpus, the list of chosen sources, the list of terms inserted, and both the start and end dates selected by the user. Finally, a route to the result page of a search on the corpus was created. It handles a request to the URL “/elem/<source>/<elem_title>”. Given the source (“Publico”, “Jornal de Negócios” or “Reddit”) and the title of the result, the function searches on the database and renders the template “elem2.html” with all the information related to the result article or post. 5.3 frontend This section aims to provide an exploration of the frontend development process for the entire website. It will detail the technologies employed in the process and explain the website’s design. On this project’s website, the frontend was built with HTML (Hypertext Markup Language), CSS (Cascading Style Sheets), and JavaScript. HTML is a language that specifies web page structure. CSS is a language used to describe the web page’s appearance. JavaScript is used in web development to specify the behavior of the web page. To facilitate the creation of responsive and aesthetically pleasing pages, Bootstrap 4 , which is an open-source framework, was used. To be more precise, the SB Admin 5 template was used as the basis of the website. As mentioned before, the Flask website is divided into folders and scripts. Inside the “templates” folder, the HTML scripts used to render the information on the browser are 4https://getbootstrap.com/ 5https://startbootstrap.com/template/sb-admin
5.3. Frontend 46 located. However, inside the “static” folder, the CSS file called “styles.css”, is used to define the visual presentation of the HTML elements. As presented in the mockups, the design of most pages is quite similar. Generally, each page consists of a fixed side menu, present on the left side of the page, which has the name of the project and the website credits, as well as buttons for the possible pages of the website: Home, Project, Corpus, Publications, and Team. The Project button is divided into several options: the project’s introduction, its objectives, the system architecture, and information about the many extractors created. Usually, on the right side of the page the title of the project is displayed along with other information depending on the page the user is in. However, during the development of the frontend, it was noted that some changes to the design were needed. At first, on the corpus page, the left-side menu was designed to be on the top of the page and the results of a search in the corpus would be displayed on the right side of the corpus search form. Nonetheless, it was concluded that the information shouldn’t be presented that way because it would not be visually appealing as there could be a lot of information in the same space given the number of results of a search on the corpus. Moreover, in the mockups, upon the user’s click on each result, all pertinent information would be showcased on the same page. It became clear that displaying multiple results and their information in the same page would not be a good idea as it would cause the page to grow significantly in size. Therefore, it was decided that on the corpus page, the left-side menu would stay in its place like on the other pages, and only the titles of the results of a search on the corpus would be displayed on that same page. However, the information about each result would be shared on a new web page, after clicking on its title’s button. Finally, the color scheme of the website was also changed to a darker color as the light color was not as appealing and was too intense, which made the site’s visibility difficult on some devices. Additionally, another field was added to the form on the corpus page (the “Select terms”) so the user could filter the information of the corpus and only have access to the articles or posts with the terms inserted present on their title. Due to the identical design across most pages, an HTML script with the common information was created to reduce code length and avoid redundancy. In this script, called “base.html”, information related to the fixed left-sided menu is rendered, and the title of the project is positioned on the right side of the page. To display the rest of the information on each page, a block was used, called “content_rightside”, whose content can be replaced or extended in child templates. To render the information about the home page, that script was used and the images and respective captions, as well as the definition of the day on which the conflict began, were inserted in the “content_rightside“ block. For the project introduction page, another template was created. This template extends the template “base.html”, therefore its content will be combined in the base template. On this page, a sample of the project’s introduction is presented. On another page, the project’s
5.4. A visit to the web platform 53 Figure 19: GUCO Website Corpus: Corpus Page After submitting the form, the titles of the various resulted articles and/or posts are made available on the website. Figure 20 contains the list of results after searching the corpus for an article in the newspaper “Público”, which contains the word “guerra” in its title and was published between the dates of February 24,2022 and September 30,2023. Figure 20: GUCO Website Corpus: List of Results Page To access each article or post and respective comments, the user must choose one of the results. After that, all information relating to that article or post is available on a new web page. Figures 21 and 22 presents the information about an article of the corpus.
5.4. A visit to the web platform 54 Figure 21: GUCO Website Corpus: Result Page (1) Figure 22: GUCO Website Corpus: Result Page (2)
6 CONCLUSION This Master’s work aims to create an online corpus regarding the conflict between Russia and Ukraine that began in February 2022. In Chapter 1, the introduction to the problem is described, focusing on its contextualization and a brief description of related projects. This part of the document also explains the objectives of this dissertation, the methodology approach, the research hypothesis, and the structure of the document. Then, in Chapter 2, the state of the art is explored, where concepts such as corpus, CMC, and NLP are addressed. Moreover, a few examples of related projects are listed and explained. Afterward, a system architecture for the project is suggested in Chapter 3. In this chapter, the chosen sources of information are revealed and an explanation for their selection is provided. Additionally, extractors create to collect data from the newspaper “Público” were also covered in this section. Moreover, it is possible to see an example of a news story from the Portuguese online newspaper “Público” as well as examples of the information extracted in JSON format. Chapter 4explains the corpus construction process. This chapter provides a detailed explanation of how the extractors were created to collect information from each source. Some examples of extracted information saved in a JSON file are provided. Additionally, the general format in which the information should be stored is described. Lastly, the chapter also explains the text-cleaning process made of the extracted information. After gathering all the desired information, the next step was to store the information in a repository. In Chapter 5, the database used to store the information is described. Then, a website was created so the user could explore the corpus created. In this chapter, the process of developing the website is provided. The initially designed mockups of the website are presented, along with explanations of both the backend and frontend components. Finally, a demonstration of how to navigate and utilize the website is provided. The website can be accessed at: https://guco.epl.di.uminho.pt/. 55
6.1. Future Work 56 6.1 future work All the objectives defined at the beginning of this master project were completed. However, there are several changes that can be implemented to improve this work. In future work, the updating of the extracted articles and posts is proposed. In this work, the extraction of the information stopped at the end of July 2023. However, the conflict persists. The extraction of articles and posts about events after the end of July 2023 should be done to keep the corpus up to date. In the created website, the user can explore the corpus and filter the information using its source, the articles or posts’ date, and using a list of terms to search for the desired articles or posts comparing them to their title. As a proposal for future work, it is suggested to categorize the articles and the posts. In other words, it is suggested to divide the information into articles or posts about economics, personal opinions, and more. Lastly, an additional task is suggested. In this work, in the stage of extracting information from online newspapers, the process is being carried out and supervised by a human. That is, a person has to choose among several articles the ones that best fit the context of this work and then pass its link as an argument to the extractors created to extract the information. A proposal for future work would be to automate this step using artificial intelligence approaches.
BIBLIOGRAPHY Etienne Becht, Leland McInnes, John Healy, Charles-Antoine Dutertre, Immanuel WH Kwok, Lai Guan Ng, Florent Ginhoux, and Evan W Newell. Dimensionality reduction for visualizing single-cell data using umap. Nature biotechnology,37(1):38–44,2019. Constança Elias, Jorge Brandão Gonçalves, Maria Araújo, Pedro Pinheiro, Cristiana Araújo, and Pedro Rangel Henriques. Netac, an automatic classifier of online hate speech comments. In World Conference on Information Systems and Technologies, pages 494–505. Springer, 2021. Manuel B. Garcia and Armi Cunanan-Yabut. Public sentiment and emotion analyses of twitter data on the 2022 russian invasion of ukraine. In 2022 9th International Conference on Information Technology, Computer, and Electrical Engineering (ICITACEE), pages 242–247, 2022. doi: 10.1109/ICITACEE55701.2022.9924136. Hans WA Hanley, Deepak Kumar, and Zakir Durumeric. Happenstance: Utilizing semantic search to track russian state media narratives about the russo-ukrainian war on reddit. arXiv preprint arXiv:2205.14484,2022. URL https://arxiv.org/pdf/2205.14484.pdf. I Hemalatha, GP Saradhi Varma, and A Govardhan. Preprocessing the informal text for efficient sentiment analysis. International Journal of Emerging Trends & Technology in Computer Science (IJETTCS),1(2):58–61,2012. Pedro Rangel Henriques, Cristiana Esteves Araújo, Isabel Ermida, and Idalete Dias. Scraping news sites and social networks for prejudice term analysis. 2019. doi: http://repositorium.sdum.uminho.pt/handle/1822/66512. Clayton Hutto and Eric Gilbert. Vader: A parsimonious rule-based model for sentiment analysis of social media text. In Proceedings of the international AAAI conference on web and social media, volume 8, pages 216–225,2014. Moaiad Ahmad Khder. Web scraping or web crawling: State of art, techniques, approaches and application. International Journal of Advances in Soft Computing and its Applications, 13(3):144 –168,2021. URL https://www.scopus.com/inward/record.uri?eid=2-s2. 0-85120853380&partnerID=40&md5=3b03613c6d348041161c889f859172b2. Ela Kumar. Natural language processing. IK International Pvt Ltd, 2013. 57
BIBLIOGRAPHY 58 Quang Thai Le and Davar Pishva. Application of web scraping and google api service to optimize convenience stores’ distribution. In 2015 17th International Conference on Advanced Communication Technology (ICACT), pages 478–482. IEEE, 2015. Leland McInnes, John Healy, and Steve Astels. hdbscan: Hierarchical density based clustering. J. Open Source Softw.,2(11):205,2017. Ryan Mitchell. Web scraping with Python: Collecting more data from the modern web. " O’Reilly Media, Inc.", 2018. Arzucan Özgür, Levent Özgür, and Tunga Güngör. Text categorization with class-based and corpus-based keyword selection. In International Symposium on Computer and Information Sciences, pages 606–615. Springer, 2005. Shaimaa Fahad Rashid and Rawaa Putros Qasha. Extracting and archiving data from social media to support cultural heritage preservation in nineveh. In 2022 International Conference on Computer Science and Software Engineering (CSASE), pages 295–300,2022. doi: 10.1109/CSASE51777.2022.9759782. Alexander Romiszowski and Robin Mason. Computer-mediated communication. In Handbook of research on educational communications and technology, pages 402–436. Routledge, 2013. Salim Sazzed. The dynamics of ukraine-russian conflict through the lens of demographically diverse twitter data. In 2022 IEEE International Conference on Big Data (Big Data), pages 6018–6024,2022. doi: 10.1109/BigData55660.2022.10020274. Alexander Shevtsov, Christos Tzagkarakis, Despoina Antonakaki, Polyvios Pratikakis, and Sotiris Ioannidis. Twitter dataset on the russo-ukrainian war, 2022. Shivangi Singh, Reshma Rajan, Laasyasree, Drishya Ramesh, Jasna Suresh, Vaishnavi KP, and Anjali T. Covifight: A covid-19 resource tracker website with location-wise search using web scraping. In 2022 4th International Conference on Smart Systems and Inventive Technology (ICSSIT), pages 1326–1331,2022. doi: 10.1109/ICSSIT53264.2022.9716527. Uddagiri Sirisha and Bolem Sai Chandana. Aspect based sentiment and emotion analysis with roberta, lstm. International Journal of Advanced Computer Science and Applications,2022. doi: 10.14569/IJACSA.2022.0131189. URL https: //www.scopus.com/inward/record.uri?eid=2-s2.0-85143858476&doi=10.14569% 2fIJACSA.2022.0131189&partnerID=40&md5=fd26a29d43e0c603d533410ddf16c4bb . All Open Access, Gold Open Access. David Mathew Thomas and Sandeep Mathur. Data analysis by web scraping using python. In 2019 3rd International conference on Electronics, Communication and Aerospace Technology (ICECA), pages 450–454,2019. doi: 10.1109/ICECA.2019.8822022.
BIBLIOGRAPHY 59 Yiming Zhu, Ehsan-ul Haq, Lik-Hang Lee, Gareth Tyson, and Pan Hui. A reddit dataset for the russo-ukrainian conflict in 2022.arXiv preprint arXiv:2206.05107,2022.