%% BioMed_Central_Tex_Template_v1.06
%%                                      %
%  bmc_article.tex            ver: 1.06 %
%                                       %

%%IMPORTANT: do not delete the first line of this template
%%It must be present to enable the BMC Submission system to
%%recognise this template!!

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                     %%
%%  LaTeX template for BioMed Central  %%
%%     journal article submissions     %%
%%                                     %%
%%          <8 June 2012>              %%
%%                                     %%
%%                                     %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                                                 %%
%% For instructions on how to fill out this Tex template           %%
%% document please refer to Readme.html and the instructions for   %%
%% authors page on the biomed central website                      %%
%% http://www.biomedcentral.com/info/authors/                      %%
%%                                                                 %%
%% Please do not use \input{...} to include other tex files.       %%
%% Submit your LaTeX manuscript as one .tex document.              %%
%%                                                                 %%
%% All additional figures and files should be attached             %%
%% separately and not embedded in the \TeX\ document itself.       %%
%%                                                                 %%
%% BioMed Central currently use the MikTex distribution of         %%
%% TeX for Windows) of TeX and LaTeX.  This is available from      %%
%% http://www.miktex.org                                           %%
%%                                                                 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%% additional documentclass options:
%  [doublespacing]
%  [linenumbers]   - put the line numbers on margins
%%% loading packages, author definitions

%\documentclass[twocolumn]{bmcart}% uncomment this for twocolumn layout and comment line below
\documentclass{bmcart}

%%% Load packages
\usepackage{amsthm,amsmath}
\usepackage{setspace}
\usepackage{lineno}
%\RequirePackage{natbib}
%\RequirePackage[authoryear]{natbib}% uncomment this for author-year bibliography
%\RequirePackage{hyperref}
\usepackage[utf8]{inputenc} %unicode support
%\usepackage[applemac]{inputenc} %applemac support if unicode package fails
%\usepackage[latin1]{inputenc} %UNIX support if unicode package fails

%\usepackage{graphicx}    %%% пакет для рисунков
%\usepackage{subcaption}
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                             %%
%%  If you wish to display your graphics for   %%
%%  your own use using includegraphic or       %%
%%  includegraphics, then comment out the      %%
%%  following two lines of code.               %%
%%  NB: These line *must* be included when     %%
%%  submitting to BMC.                         %%
%%  All figure files must be submitted as      %%
%%  separate graphics through the BMC          %%
%%  submission process, not included in the    %%
%%  submitted article.                         %%
%%                                             %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%\def\includegraphic{}
%\def\includegraphics{}



%%% Put your definitions there:
\startlocaldefs
\endlocaldefs


%%% Begin ...
\begin{document}

%%% Start of article front matter
\begin{frontmatter}

\begin{fmbox}
\dochead{Research}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                          %%
%% Enter the title of your article here     %%
%%                                          %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\title{Chemical named entity recognition in the texts of scientific publications using the naïve Bayes classifier approach }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                          %%
%% Enter the authors here                   %%
%%                                          %%
%% Specify information, if available,       %%
%% in the form:                             %%
%%   <key>={<id1>,<id2>}                    %%
%%   <key>=                                 %%
%% Comment or delete the keys which are     %%
%% not used. Repeat \author command as much %%
%% as required.                             %%
%%                                          %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\author[
   addressref={aff1},                   % id's of addresses, e.g. {aff1,aff2}
   corref={aff1},                       % id of corresponding address, if any
  % noteref={n1},                     % id's of article notes, if any
   email={olga.a.tarasova@gmail.com}   % email address
]{\inits{OA}\fnm{Olga} \snm{Tarasova}}
\author[
]{\inits{NYu}\fnm{Nadezhda} \snm{Biziukova}}
\author[
]{\inits{DA}\fnm{Dmitry} \snm{Filimonov}}
\author[
]{\inits{VV}\fnm{Vladimir} \snm{Poroikov}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                          %%
%% Enter the authors' addresses here        %%
%%                                          %%
%% Repeat \address commands as much as      %%
%% required.                                %%
%%                                          %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\address[id=aff1]{%                           % unique id
  \orgname{Laboratory of Structure-Function Based Drug Design, Department of Bioinformatics, Institute of Biomedical Chemistry}, % university, etc
  \street{Pogoniskaya st., 10-7},                     %
  \postcode{119121}                                % post or zip code
  \city{Moscow},                              % city
  \cny{Russia}                                    % country
}
\begin{artnotes}
%\note{Sample of title note}     % note to the article
\note[id=n1]{equal contributor} % note, connected to author
\end{artnotes}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                          %%
%% Enter short notes here                   %%
%%                                          %%
%% Short notes will be after addresses      %%
%% on first page.                           %%
%%                                          %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{fmbox}% comment this for two column layout

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                          %%
%% The Abstract begins here                 %%
%%                                          %%
%% Please refer to the Instructions for     %%
%% authors on http://www.biomedcentral.com  %%
%% and include the section headings         %%
%% accordingly for your article type.       %%
%%                                          %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{abstractbox}

\begin{abstract} % abstract
\parttitle{Motivation} %if any
Application of chemical named entity recognition (CNER) algorithms allows retrieval of information from texts about chemical compound identifiers and creates associations with physical-chemical properties and biological activities. Scientific texts represent low-formalized sources of information. Most methods aimed at CNER are based on machine learning approaches, including conditional random fields and deep neural networks. In general, most machine learning approaches require either vector or sparse word representation of texts, which is produced using a fixed-size vocabulary from a corpus of texts. Chemical named entities (CNEs) constitute only a small fraction of the whole text, and the datasets used for training are highly imbalanced.

\parttitle{Methods and results} %if any
We propose a new method for extracting CNEs from texts based on the naïve Bayes classifier. In contrast to the earlier developed CNER methods, our approach uses the representation of the data as a set of fragments of text (FoTs) with the subsequent preparation of a set of multi-n-grams (sequences from one to n symbols) for each FoT. Therefore, it does not require the usage of a predefined vocabulary. As a result, our approach may provide the recognition of novel CNEs. The average values of invariant accuracy (IA) range from 0.95 to 0.99 depending on the context window and the size values of n of the multi-n-grams. We applied the developed algorithm to the extracted CNEs of potential Severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) main protease (Mpro) inhibitors. A set of CNEs corresponding to the chemical substances evaluated in the biochemical assays used for the discovery of Mpro inhibitors was retrieved. Manual analysis of the appropriate texts showed that CNEs of potential SARS-CoV-2 Mpro inhibitors were successfully identified by our method.
\parttitle{Conclusion} %if any
The obtained results show that the proposed method can be used for filtering out words that are not related to CNEs; therefore, it can be successfully applied to the extraction of CNEs for the purposes of cheminformatics and medicinal chemistry.
\end{abstract}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                          %%
%% The keywords begin here                  %%
%%                                          %%
%% Put each keyword in separate \kwd{}.     %%
%%                                          %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{keyword}
\kwd{chemical named entity recognition}
\kwd {CNE}
\kwd{CNER}
\kwd {naïve Bayes classifier}
\kwd {antivirals}
\end{keyword}

% MSC classifications codes, if any
%\begin{keyword}[class=AMS]
%\kwd[Primary ]{}
%\kwd{}
%\kwd[; secondary ]{}
%\end{keyword}

\end{abstractbox}

%\end{fmbox} %uncomment this for twcolumn layout

\end{frontmatter}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                          %%
%% The Main Body begins here                %%
%%                                          %%
%% Please refer to the instructions for     %%
%% authors on:                              %%
%% http://www.biomedcentral.com/info/authors%%
%% and include the section headings         %%
%% accordingly for your article type.       %%
%%                                          %%
%% See the Results and Discussion section   %%
%% for details on how to create sub-sections%%
%%                                          %%
%% use \cite{...} to cite references        %%
%%  \cite{koon} and                         %%
%%  \cite{oreg,khar,zvai,xjon,schn,pond}    %%
%%  \nocite{smith,marg,hunn,advi,koha,mouse}%%
%%                                          %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%% start of article main body
% <put your article body there>

%%%%%%%%%%%%%%%%
%% Background %%
%%
%\section*{Content}
%Text and results for this section, as per the individual journal's instructions for authors. %\cite{koon,oreg,khar,zvai,xjon,schn,pond,smith,marg,hunn,advi,koha,mouse}

\section*{Introduction}
\begin{linenumbers}
\begin{doublespacing}
An analysis of texts is essential for extracting new knowledge about chemical compounds, drugs, targets, pathological processes and diseases; it allows determining various relationships including identification of molecular mechanisms, effects and toxicity of drug, pathophysiological processes and determining drug-target-disease relationship \cite{ yao_novel_2010, capuzzi_chemotext_2018}. Extraction of chemical named entities (CNEs) from scientific publications is an essential task since it allows using the obtained data for building chemical-target associations \cite{oprea_associating_2011}, leading to improvement of the data curation \cite{dura_mining_2014, piir_best_2018, tarasova_data_2019}. Chemical named entity recognition (CNER) algorithms can help create large sets of named entities of chemical compounds associated with physical and chemical properties or biological activities \cite{oprea_associating_2011, piir_best_2018}. Therefore, such algorithms allow the identification of CNEs and the collection of big data on chemicals and their properties \cite{krallinger_information_2017, corbett_chemlistem_2018, akhondi_recognition_2015, eltyeb_chemical_2014, zhang_chemical_2016, liu_entity_2017, colon-ruiz_comparing_2020, hemati_lstmvoter_2019,vazquez_text_2011}. Both dictionary-based and machine learning approaches used to reveal CNEs have limitations due to the peculiarities of text structure. Since scientific publications are low-formalized sources of information and CNEs make up only a small part of the whole text, the datasets used for training are highly imbalanced. The extraction of CNEs is restricted by the incompleteness of the representation of chemical names in the texts. For instance, they might be provided for the scaffolds but not for whole chemical compounds. Another restriction is associated with the variability of the chemical names, where various punctuation marks can be found, including dots, commas, hyphens, etc. In this case, the accuracy of the named entity recognition approach would be very sensitive to the specific method of tokenization, i.e., breaking up the input lines into pieces such as keywords, phrases, symbols, etc.~\cite{krallinger_information_2017}. 

An obvious disadvantage of the rule-based and dictionary-based methods is a limited number of CNEs that can be recognized due to the fixed size of dictionaries or rule numbers. Machine learning or artificial intelligence approaches~\cite{biziukova_automated_2020, krallinger_chemdner_2015} mainly include support vector machines \cite{Wu-Y-C-2006} and artificial neural networks \cite{corbett_chemlistem_2018, zhang_chemical_2016, hemati_lstmvoter_2019}. Typically, these methods can reach an accuracy of approximately 85-95 percent \cite{corbett_chemlistem_2018, zhang_chemical_2016, hemati_lstmvoter_2019, vazquez_text_2011}. Most methods are sensitive to imbalanced data \cite{tarasova_computational_2018}. Long-short term memory networks (LSTM) \cite{liu_entity_2017, colon-ruiz_comparing_2020, hemati_lstmvoter_2019, li_application_2021, cho_combinatorial_2020, chen_named_2019, gajendran_character_2020} or conditional random fields (CRF) \cite{biziukova_automated_2020, bundschus_extraction_2008} are efficiently used in the task of named entity extraction. The architecture of neural networks should be fitted to the particular task and therefore should be modified according to the particular task of CNER \cite{shu_sensitivity_2019, li_analyzing_2021, baskin_renaissance_2016}. The use of neural networks is characterized by overfitting~\cite{li_analyzing_2021, baskin_renaissance_2016}. 

Computational machine learning approaches require text preprocessing followed by the generation of vector-based or sparse word text representation (one-hot encoding). A set of vectors is generated based on the fixed-size vocabulary created using the text corpus. Therefore, the accuracy of CNER is strictly dependent on the completeness of the corpus that was used to create the set of vectors and its relevance to a particular task (i.e., chemical named recognition, biological named recognition, the search of chemical-biological associations, etc.). 

Because of these issues, it was concluded that the existing models do not provide reasonable accuracy for the successful extraction of CNEs \cite{krallinger_information_2017, vazquez_text_2011}, in particular, the recognition “of new and unseen entity types in biomedical literature” \cite{biziukova_automated_2020}. Therefore, the development of novel approaches aimed at highly accurate and fast CNER is in high demand. 

Our study represents the new approach for CNER in the texts of scientific publications based on the naïve Bayes classifier (NBC). We previously evaluated the applicability of an in-house developed NBC for predicting the biological activities of chemical compounds and estimating viral drug resistance \cite{tarasova_pass-based_2017}. Originally developed multilevel neighbourhoods of atoms (MNA) descriptors were used for the representation of chemical structures. However, further development of the method allows us to use short peptide and nucleotide sequences (represented by a sequence of symbols) in our algorithm \cite{tarasova_pass-based_2017}. These results demonstrated the applicability of the NBC approach to the classification of sequences according to a certain task. We demonstrated that our approach can be applied for prediction even in the case of highly imbalanced datasets \cite{tarasova_pass-based_2017, tarasova_hiv_2018}. 

A newly developed approach based on NBC is aimed at the recognition of CNEs and their classification into types (trivial, systematic, etc.) in the abstracts of scientific publications based on the set of n-grams of length from one to n symbols (the so-called multi-n-grams), generated for each symbol of a text. We have built an application that can perform colouring of the text fragments that were recognized as belonging to CNEs and various types. We evaluated the accuracy of CNER on the large, labelled corpus of CNEs freely available via the internet (CNEMDNER). Additionally, we tested our method in an application for CNER of potential anti-SARS-CoV-2 agents. We used a collection of texts relevant to SARS-CoV-2 main protease (Mpro) inhibitors. CNEs were extracted from the texts, and the accuracy of extraction was verified using automated and manual analysis. Based on the CNE extraction procedure, we were able to identify a set of entities related to the chemical compounds assayed against SARS-CoV-2 Mpro inhibition, and for some of them, inhibitory activity against Mpro was confirmed. 

\section*{Material ad Methods}
\subsection*{Text corpus}
To perform CNER, we used the freely available corpus CHEMDNER \cite{krallinger_chemdner_2015}. CHEMDNER contains 10,000 abstracts. CNEs are labelled by an expert for each abstract. CHEMDNER consists of over 80,000 labelled named entities of chemical compounds for over 19,000 unique named entities \cite{krallinger_chemdner_2015}. CHEMDNER contains a set of texts compiled based on NCBI PubMed \cite{pubmed} abstracts, in which CNEs are represented by the position of the first and the last symbol in the text. In our study, we used annotation for the labelled texts that assigns the chemical named entities to one of the following types: “Abbreviation” (mainly abbreviations and acronyms), “Systematic” (IUPAC names of chemicals), “Formula” (the formula in the text that is associated with the CNE), “Family” (family of chemicals), and “Trivial” (trivial names of chemicals and trademark names)~\cite{krallinger_chemdner_2015}. The “non-CNE” type was not arranged to any CNE and represented any other fragment of text (FoT). Additionally, we merged all CNEs belonging to different types into one, chemical named entity (“CNE”). Examples of the CNEs of each type are provided in Table~\ref{tab1}.

%%  ~\ref{tab1}  ссылка на объект, здесь на таблицу.  tab1 - это key, задается при описании в \label{tab1}. Также можно ссылать на рисунки и формулы. Знак тильды "~" = неразрывный пробел (в тексте не отображается).   

%\\
%\subparagraph
% {Table 1. Examples of chemical named entities belonging to particular types.\\
% \\}

\section*{Tables}
\begin{table}[h!]
	\caption{Examples of chemical named entities belonging to particular types.}
	\label{tab1}
	\begin{tabular}{cc}
		\hline
		Type   & An example of a chemical named entity \\ \hline
		Abbreviation  & Mtx\\
		Systematic  & anthracene, phenylenediamine\\
		Formula  & $H_2O$\\
		Family & flavonoids \\
		Trivial & haloperidol \\
		Chemical named enity (CNE) & anthracene, phenylenediamine, haloperidol \\       
		Non-CNE & quarantine \\
	\end{tabular}
\end{table}


CHEMDNER was tokenized. We used the Python NLTK WordPunkt tokenizer~\cite{NLTK}. All the types denoted above were arranged into four FoT variants of FoT by the context window: the central token (the so-called target token) and the FoTs obtained by concatenating one, two, or three tokens before and after the target token (see Figure 1, a). We built the set of descriptors by shifting target tokens one by one. If the obtained FoT does not belong to any type, it is assigned to the "non-CNE" type. Then, for each set of tokens belonging to a particular type, we generated a set of n-grams (the so-called multi-n-grams), which are continuous sequences of one to n symbols from a token. We used five types of n-grams with n values from one to five (see Figure 1, b).

\begin{figure}[h!]
	\caption{(a) The types are arranged for each variant: target token and a set of tokens before and after the target token; (b) an example of a set of multi-n-grams with $n=5$ generations}
\end{figure}

\subsection*{The algorithm of named entity recognition}
The CNER algorithm is based on the NBC approach implemented in the Prediction of Activity Spectra for Substances (PASS) software~\cite{Filimonov-book}. The standard usual NBC is a linear classifier: 
$$
\text{if } a'x > b \text{ then } Class \; 1 \text{ else } Class \; 2
$$

%\subparagraph
%{if $a'x > b$ then $Class 1$ else $Class 2$}

where a are the coefficients, $x_i=1$ or $x_i=0$ for the i-th feature (descriptor) of the classified object, and b is the threshold value. Unlike linear regression or any other similar methods, the NBC coefficients are not the result of optimization, but they are calculated directly based on the training dataset. According to the naïve Bayes approach, the a posteriori probability $P(C|F)$ that the FoT $F$, which is represented by the set ${g_1,...,g_m}$ of $m$  descriptors, the n-grams $g_i$, belongs to type $C$ satisfies the equation: 
$$
ln \left[ \frac{P(C|F)}{1-P(C|F)} \right]  \cong ln  \left[\frac{P(C)}{1-P(C)} \right]  + \sum_{i=1}^m \left\{ ln[\frac{P(C|g_i)}{1-P(C|g_i}]-ln[\frac{P(C)}{1-P(C)}] \right\},
$$
where $P(C)$ is the a priori probability of type $C$ and 
$P(C|g_i)$ is the conditional probability of type C for a particular descriptor, n-gram 
$g_i$. 
The explanation of this expression is quite clear: the logarithm of the {\it a posteriori} likelihood ratio is the sum of the logarithm of the {\it a priori} likelihood ratio and the sum of individual descriptor contributions. If the type of FoTs is not dependent on the n-gram $g_i$, then $P(C|g_i)=P(C)$, and the contribution of the n-gram $g_i$ to the sum is zero. The expression in the curly brackets is the value of coefficient $a_i$ in the standard NBC. 
However, this simple result of the usual naive Bayes approach has a significant well-known disadvantage: the contribution of some descriptors, for which the conditional probability of activity is too close to 0 or 1, is too large and suppresses all other terms of the sum. The PASS algorithm uses the so-called arcsine Fischer transform instead of $ln[p/(1-p)]$. The shape of $ArcSin(2p-1)$ coincides with the shape of $ln[p/(1-p)]$ for almost all values of $p$, but the 
$ArcSin(2p-1)$ values are bounded by the values $\pi/2$. The accuracy of the PASS prediction also improved after changing the sum by the average value. The {\it a priori} likelihood ratio is constant, does not contain information about a specific recognized FoT, and can be omitted. 

The PASS algorithm is based on the specific B-statistics, which are calculated according to the following expressions:  
\[
P(C_k) = \frac{N_k}{N}; \quad P(C_k | g_i) = \frac{N_{ik}}{N_i}; \quad S_0 k = 2P(C_k)-1;   
\]

\[
S_k=Sin\left[ \sum_{i=1}^m(ArcSin(2(C_k|g_i)-1)) \right]  ;
\]

\[B_k=\frac{S_k-S_0k}{1-S_k \cdot S_0k},
\]

where  $N$ is the number of FoTs (tokens) in the training set and $N_k$ is the number of FoTs belonging to the type $C_k$.  

We evaluate the recognition accuracy based on the leave-one-out cross-validation (LOO CV) and fivefold cross-validation (5-F CV) procedures using the invariant accuracy (IA) estimates \cite{Filimonov-book}. During the execution of the LOO CV procedure, polynomial estimates of the distributions of B-statistics for the CNE and non-CNE classes are calculated, and on this basis, estimates of the probability $P_c$ of belonging and $P_{nc}$ of not belonging to CNE are constructed as functions of B-statistics.

CNER was performed based on the values of $P_c$ and $P_{nc}$ after determining the threshold (for details, please see the “Results and Discussion” section). 

Automated validation of CNER was performed using a set of scripts (Python 3.7.4) that were built to perform automated queries to the PubChem and ChEMBL databases. The scripts are provided in the Supplementary Information. The values of accuracy are provided in the “Results and Discussion” section. 

The developed approach was tested on a CNER task using the CHEMDNER corpus and in retrieving CNEs of potential SARS-CoV-2 inhibitors. The values of balanced accuracy and F1-score for CHEMDNER were evaluated using 5-F CV. To test our approach on the task of CNER for potential anti-SARS-CoV-2 agents, we created a test set as described below. 

The text collection {\it SARS-CoV-2 Mpro set} was compiled based on the text query that included all synonyms of SARS-CoV-2 main protease (Mpro) and the term “inhibitors”. The synonyms of Mpro were retrieved from UniProt~\cite{uniprot}. The full text of the query is provided in the Supplementary Information. In total, we collected 1528 texts. The texts were processed using Python NLTK WordPunkt tokenizer yielding 484676 tokens. We used the model built on multi-n-grams with a maximum of five symbols and a context window of one, as it was characterized by the highest accuracy values. The performance of the model was estimated semiautomatically using an iterative multistage procedure. 

\section*{Results and Discussion}
\subsection*{Accuracy of naive-based chemical named entity recognition}
We evaluated the most suitable parameters for high accuracy of CNER using NBC based on IA values. The highest IA values were achieved with context windows one and two, i.e., one (two) token before and one (two) token after the target token (see Figure 2) depending on the class. For the systematic class, the highest IA values are obtained for context window one, multi-n-grams with n=5 (IA = 0.988), and context window two, multi-n-grams with n=7 (IA = 0.992), and the difference in accuracy values for these parameters is insignificant. For the class Trivial, the highest IA value was achieved for the following parameters: context window one, multi-n-grams with n=7 (IA = 0.984). Figure 2 shows that the values of IA increase along with an increment of the maximal context window up to two tokens before and two after a target token for the class Systematic; however, this is not the case for the class Trivial, for which the highest IA values were obtained for context one. The highest average IA values can be achieved for the following parameters: context window one and multi-n-grams with n=5 (IA = 0.986); almost similar values of IA can be obtained with context window two and n=7 (IA = 0.988). Therefore, the IA values do not grow dramatically with an increase in the context window of more than one token and multi-n-grams of more than five symbols. These observations allow us to conclude that a combination of a context window, one token before and after a target token, and maximum multi-n-grams of five can be used to achieve the highest accuracy of CNER based on the naïve-Bayes approach, and it provides reasonable computational complexity. 

The IA values and balanced accuracy (BA) of CNER for various classes obtained in leave-one-out-cross-validation are given in Table~\ref{tab2}. The IA, sensitivity (recall), precision, specificity, and BA values for various thresholds of B-statistics are provided in the Supplementary Information. 

We surmise that the decrease in accuracy for n-grams of seven or more symbols may be associated with the high uniqueness of such long n-grams in the training set. %\\

%\subparagraph
% {Fig. 2 The relationship between length of an n-gram, context window, and accuracy of CNER: (a) for class “Systematic”, (b) for class “Trivial”, and (c) average IA for all classes.\\
% \\}


\begin{figure}[h!]
	\centering
	\caption{The relationship between length of an n-gram, context window, and accuracy of CNER: (a) for class “Systematic”, (b) for class “Trivial”, and (c) average IA for all classes}\label{fig:fig2}
\end{figure}

These results may also be associated with the peculiarities of the text fragment formation: the higher number of tokens arranged to the type may lead to difficulties in recognizing the features of the target token. At the same time, a minimal context of one token before and after the target token can help consider whole words or the parts of terms that can point to a chemical named entity, such as “inhibitor”, “drug”, “chemical”, and “substance”.

%\\
%\subparagraph
% {Table 2. Examples of chemical named entities belonging to particular types.\\
% \\}

%%%%%%  Таблица 2
%%%%  \begin{table}[h!]   --- [h!]  описывает положение таблицы [h] ="[хочу здесь]", [h!] ="[Очень хочу здесь]" , [t] --- сверху страницы
%%%% \caption == название таблицы
%%%%  {cccc} -- это количество столбцов (количество букв с) и выравнивание в них (с-по центру). Например,  {clr} - 3 столбца, 1-й по центру, 2-ой по левому краю, 3-й по правому краю
%%%%

% {Table 2. Examples of chemical named entities belonging to particular types.\\
\begin{table}[h!]     
	\caption{Accuracy of chemical named entity recognition using the PASS approach based on the representation of texts using n-grams equal to five symbols and a context window of one token before and after analysis.}
	\label{tab2}    
	\begin{tabular}{cccc}
		\hline
		Type  & N*   & R* & IA***(LOO CV) \\ \hline
		Abbreviation & 12506 & 118 & 0.99 \\
		
		Formula & 13466 & 110 & 0.99 \\
		
		Family & 19017 & 78 & 0.97 \\
		
		Systematic & 32510 & 46 & 0.99 \\
		
		Trivial & 25140 & 59 & 0.98 \\
		
		CNE & 102639 & 14 & 0.98 \\
		
		Non-CNE & 1480509 & 1.01 & 0.98 \\ 
		\multicolumn{4}{l}{} \\
		\multicolumn{4}{l}{* - N is the number of fragments of texts used for training.} \\
		\multicolumn{4}{l}{** - R is the ratio of the number of all tokens to the number of tokens }\\
		\multicolumn{4}{l}{belonging to a certain type, indicating a measure of dataset imbalance }\\
		\multicolumn{4}{l}{*** - IA invariant accuracy }
	\end{tabular}
\end{table}

We should emphasize that the number of tokens of the “NON-CNE” type is approximately 50 times higher than the number of tokens of types “Systematic” and “Trivial”. The results of Table 2 show that the data imbalance does not influence the values of accuracy IA. Similar results we obtained earlier for the Bayes-based approach applied to the prediction of HIV resistance~\cite{tarasova_computational_2018}. Based on the interpretation of accuracy for “CNE” and single, complex substance NEs, we can propose that CNEs can be extracted from the texts of abstracts for further analysis using the prediction results. 

Utilizing PASS estimates for chemical named entities, we investigated the relationship between recall (sensitivity), precision, specificity, and balanced accuracy for the context window of one and multi-n-grams with an n value of one to five for the CHEMDNER corpus. 

Figure 3 shows the relationships between the values of accuracy metrics (precision, recall, specificity, BA) and B-statistics for the “Systematic” and “Trivial” types (the most represented classes in the training set), CNE, and non-CNE type. The relationship between the accuracy metrics and B-statistics for all other types is provided in the Supplementary Materials.
 
\begin{figure}[h!]
	\caption{The relationships between the values of accuracy and B-statistics for the types: (a) “Systematic”; (b) “Trivial”; (c) “CNE”; (d) “non-CNE”.}\label{fig:fig1}
\end{figure}

As shown in Figure 3, the recall and BA values have similar patterns of curve growth and decline, while the patterns of recall and precision curves are different. In particular, the precision curve increases while the recall curve decreases, and vice versa. It is obvious and occurs because the number of false-positives decreases while the number of false-negatives increases. A small number of positive samples (Systematic and Trivial types in Figure 3, a, b) in the training set may explain the more flattened pattern of the precision curve. Comparison of the curve growth and decline patterns reveals that they are not related to any chemical named entity and provides the opportunity to compare accuracy metrics. For instance, for Trivial and Systematic types, the precision curve character changes significantly depending on the threshold, while for the non-CNE type, the situation is different. It allows making a conclusion that the precision is rather sensitive to the imbalance of the data, while sensitivity (recall), specificity, and balanced accuracy are not sensitive to the data imbalance. Another feature of precision is its sensitivity to the threshold choice (see Figure 3). When a method is designed to extract information on chemical named entities from texts, the values of specificity and sensitivity (recall) are essential for validation because they help estimate the proportion of false-positives. A method with high specificity and sensitivity (recall) values provides the possibility to extract the correct chemical named entity based on the estimates of probabilities that indicate belonging to CNE and non-CNE as a consensus result.
Our CNER algorithm also allows evaluating each symbol in an FoT. A set of n-grams including a particular position in the FoT is used. In Figure 4, for the letter "o" in the token "cyclohexane", the set of n-grams {O, LO, OH, CLO, LOH, OHE, YCLO, CLOH, LOHE, OHEX, CYCLO, YCLOH, CLOHE, LOHEX, OHEXA} with n=5 is used for estimation. The values $P_c=0.915$ and $P_{nc}=0.002$ are calculated for the letter "o" in the token "cyclohexane" for class "SYSTEMATIC". On such bases in our PASS software, the colouring of FoTs is used. The colour of the letter corresponds to light green for $P_c=1$ ($P_{nc}=0$), light red for $P_{nc}=1$ ($P_c=0$), and blue when $P_c$ and $P_{nc}$ are both close to zero.

\begin{figure}[h!]
	\caption{An example of chemical named entity extraction based on PASS estimations.}
\end{figure}

Chemical named entities can be extracted after tokenization of texts and making a prediction for each token based on the values of $P_c$ and $P_{nc}$. Extraction of a chemical named entity can be performed by concatenating the tokens predicted to belong to a CNE class.
\subsection*{Validation of the PASS-based approach in the task of extracting chemical named entities}
\subsubsection*{Extracting chemical named entities based on the CHEMDNER corpus }
 

We checked the applicability of our approach for extracting chemical named entities and tested it in a case study of CNER extraction using CHEMDNER. 

To extract chemical named entities, we ought to determine the best strategy for extracting chemical named entities by a naïve Bayes-based approach. 

First, we evaluated the threshold for extracting chemical named entities based on the prediction results. We calculated a set of values ($P_c$ - $P_{nc}$) that corresponds to the highest accuracy of distinguishing tokens that belong and do not belong to CNE. The value of the threshold was obtained empirically based on the maximum normalized by standard deviation values of sensitivity (recall), precision, specificity, and balanced accuracy (Figure 5). The threshold value of 0.30 was chosen for CNER.

\begin{figure}[h!]
	\caption{Threshold selection for recognition of tokens that belong to chemical named entities based on probability $P_c$-$P_{nc}$.}
\end{figure}

Then, we extracted named entities as the concatenated sequence of tokens with ($P_c$-$P_{nc}$) above the T value. To improve the extraction procedure, we applied some filters aimed at exclusion of tokens that obtain high values of ($P_c$-$P_{nc}$) because they are overrepresented in the training set (for instance, numerical values, single brackets, etc.). In addition, the named entities with incorrect encoding were removed from the set of extracted CNEs, disregarding the prediction results. The full set of filters is provided in the Supplementary Information. 

The values of precision, sensitivity (recall), specificity, and balanced accuracy for CHEMDNER were evaluated using five-fold cross-validation. For the CHEMDNER dataset, the sensitivity (recall) was 0.95, precision was 0.74, specificity was 0.88, and balanced accuracy was 0.92. These values of accuracy represent the approximate performance of recognition for the whole chemical named entities, not their parts.

\subsubsection*{Extracting named entities of potential anti-SARS-CoV-2 agents}
To evaluate the applicability of our approach for solving practical tasks that may have a high clinical and biological impact, we investigated the possibility of extracting named entities of chemicals that can inhibit SARS-CoV-2 main protease (SARS-CoV-2 Mpro) and slow down COVID-19 progression. We chose to extract inhibitors of SARS-CoV-2/COVID-19 as a case study because of the availability of large collections of texts relevant to SARS-CoV-2 studies. 

We extracted a total number of 8071 named entities corresponding to 2615 unique CNEs. The extracted CNEs are provided in the Supplementary Information. Then, we calculated the precision and recall values for the extracted examples. 

First, we performed automated queries of the PubChem \cite{pubchem} and ChEMBL \cite{chembl} databases. Such queries allowed us to estimate the number of true-positive samples automatically. The results of automated queries were then manually checked. In total, 4374 named entities were found in the databases correctly (1201 CNEs without duplicates). Manual examination of retrieved CNEs allowed us to identify 1407 NEs extracted correctly (507 CNEs without duplicates). The number of false-negatives was obtained based on the manual analysis of the test set. Based on the results of manual and automated validation, we calculated precision, recall, and F1-score for the {\it SARSCoV-2 Mpro set}. For the set, sensitivity (recall) is 0.94, precision is 0.72, specificity is 0.87, and balanced accuracy is 0.92. 

During a manual inspection of the entities recognized as belonging to CNEs according to PASS prediction, we noticed that some entities were identified correctly but were not found in the PubChem and ChEMBL databases. Some of them (1\%) were identified as CNE by the PASS algorithm, but they were not found in the databases because of misprints (for instance, such named entities include "hydroxybenzoagte" (the correct name: hydroxybenzoate) and "dithiazone" (the correct name: dithizone). Another part consisting of 1\% found entities were codes of chemical compounds provided in the publication and therefore had the context indicating that the entity is CNE. Approximately 6\% were recognized but were not found in PubChem because they belong to chemical families. The PASS model was based on the merged class CNE, which includes chemical families; therefore, they were recognized by PASS but, naturally, were not found in PubChem. Examples of such named entities include “ginsenosides”, “flavonoids”, “triterpenoids”. Chemical named entities that are natural compounds have not been found via automated queries of the PubChem database. The names of bioactive peptides and incomplete chemical named entities as well as all other terms were regarded as false-positives. 

Manual analysis of the true-positive chemical named entity mentions allowed us to identify several names of chemical compounds that were evaluated for inhibition of SARS-CoV-2 (for instance, hydroxychloroquine, chloroquine, quercetin, rutin, curcumin, darunavir, saquinavir, and flavonoids). 

Although chloroquine and hydroxychloroquine are the most thoroughly investigated drugs and therefore appeared in the set of chemical named entities extracted from the texts collected by a query associated with SARS-CoV-2 Mpro, they were considered ineffective after a set of studies \cite{jama-clin}. Quercetin was experimentally tested for its activity against SARS-CoV-2 Mpro and demonstrated inhibitory activity \cite{abian_structural_2020}. Flavonoids represent a group of natural compounds (secondary plant metabolites) that are widely discussed in the scientific literature and are considered to have anti-inflammatory effects and the ability to modulate cytokines \cite{al-karmalawy_naturally_2021}. The inhibitory effect of some flavonoids (tangeretin, gardenin B) on SARS-CoV-2 was demonstrated \cite{al-karmalawy_naturally_2021}. The anti-inflammatory activity and inhibitory activity of dihydromyricetin on SARS-CoV-2 Mpro were evaluated in a FRET assay (fluorescence resonance energy transfer) \cite{xiao_effect_2021}. It was shown that the half-maximal inhibitory concentration of SARS-CoV-2 Mpro by dihydromyricetin reached 1.76 µM. Additionally, the authors \cite{tarasova_extraction_2021} confirmed the activity of dihydromyricetin on the proteins included in the TGF-$\beta$ 1/Smad pathway, which are responsible for the development of pulmonary fibrosis. 

These results demonstrate the applicability of the Bayes-based CNER approach to the extraction of CNEs in the text of abstracts relevant to a particular task and therefore allow the scientific community to enrich the knowledge about potential chemical compounds effective against particular targets and can be used for the treatment of specific diseases, including novel humanity threats such as COVID-19.

\subsubsection*{A place of the naïve-based CNER among other methods }
Texts of publications represent low-formalized data, and their classification may be difficult even for experts in the field. In contrast to approaches that take any semantical or grammatical features of a token, our method takes the text data as input without any additional processing into parts of speech and other grammatical or semantic features. 

Many various artificial intelligence (AI) approaches aimed at chemical and biological named entity recognition have been developed \cite{Wu-Y-C-2006, cho_combinatorial_2020, gajendran_character_2020}. Most approaches that have been under recent development for several years are based on the usage of neural networks with different variants of long-short term memory (LSTM) architecture or conditional random fields (CRF) \cite{biziukova_automated_2020, tarasova_extraction_2021}. Most AI-based approaches initially convert text into vectors or use sparse word text representation created with preprocessing of a text corpus and further creation of a fixed-size vocabulary that contains features only included in the corpus used for vector preparation (for instance, such approaches include word embedding preparation or the one-hot-encoding technique). Compared to the methods that are based on the vector-based or sparse word representation of texts, the proposed naïve-based CNER approach does not require the usage of a fixed-size vocabulary to produce text representation. The latter feature provides the versatility of our method in its application to very different text styles and language peculiarities. It should be noted that the performance of CNER using the naïve-based approach obtained in the test set is comparable with earlier published methods, including machine learning and deep neural network approaches \cite{biziukova_automated_2020, Wu-Y-C-2006, cho_combinatorial_2020, chen_named_2019, gajendran_character_2020}. It should be noted that we evaluated the accuracy of CNE extraction in addition to the accuracy of a particular token belonging to the specific class. Therefore, texts relevant to various queries can be processed efficiently using the developed naive-based approach.Extraction of novel chemical entities may be rather helpful for the purposes on novel drug design including both experimental studies and cheminformatics apporaches, virtual screening that represent a group of powerful approaches for exploring large chemical space \cite{kar_how_2013}. 

\section*{Conclusion}
We developed a new naïve Bayes classifier approach for extracting chemical named entities from texts of scientific publications. The features that we used included the sequential tokens merged by three: a “target token”, one token displaced in the text before and one token after the target token. Text strings collected from merged tokens are represented as a set of multi-n-grams, consisting of one to five symbols. The algorithm provides an estimation of the probability for each token belonging to the following classes: “Abbreviation”, “Family”, “Formula”, “Systematic”, “Trivial”, “CNE” (an integrated class that includes the aforementioned classes), and “non-CNE”. Our approach allows the prediction of a token belonging to the classes with an invariant accuracy of 0.96-0.99. 

The extraction of CNEs is based on the prediction of each token to belong to the class CNE, the selection of tokens belonging to CNE based on the predefined threshold of probability values, and the further concatenation of selected tokens. We tested our approach on a task of retrieving chemical named entities of potential inhibitors of SARS-CoV-2 Mpro as compounds that can slow down COVID-19 progression. As a result, we extracted 2615 unique chemical named entities and thoroughly evaluated the correctness of chemical named entity recognition. We thoroughly analysed extracted named entities, and for some of them, the experimental confirmation of their SARS-CoV-2 Mpro inhibition was found, and their role as anti-SARS-CoV-2/COVID-19 agents was discussed.
\end{doublespacing}
\end{linenumbers}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                          %%
%% Backmatter begins here                   %%
%%                                          %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{backmatter}

\section*{Competing interests}
  The authors declare that they have no competing interests.

\section*{Author's contributions}
    O.T. Conceptualization, chemical named entity recognition experiments, manuscript -- writing \& editing; N.B. -- data set preparation, manuscript -- editing;  D.F. conceptualization, software implementation, manuscript  -- review \& editing; V.P. Conceptualization,  manuscript  -- review \& editing. %\ldot ???
 \section*{Funding}
  The study was supported by the Russian Foundation for Basic Research grant No. 20-04-60285.

  
% if your bibliography is in bibtex format, use those commands:
\bibliographystyle{vancouver} % Style BST file (bmc-mathphys, vancouver, spbasic).
\bibliography{bmc_article}      % Bibliography file (usually '*.bib' )
% for author-year bibliography (bmc-mathphys or spbasic)
% a) write to bib file (bmc-mathphys only)
% @settings{label, options="nameyear"}
% b) uncomment next line
%\nocite{label}

% or include bibliography directly:
% \begin{thebibliography}
% \bibitem{b1}
% \end{thebibliography}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                               %%
%% Figures                       %%
%%                               %%
%% NB: this is for captions and  %%
%% Titles. All graphics must be  %%
%% submitted separately and NOT  %%
%% included in the Tex document  %%
%%                               %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%
%% Do not use \listoffigures as most will included as separate files

%\section*{Figures}
%  \begin{figure}[h!]
%  \caption{\csentence{Sample figure title.}
%      A short description of the figure content
%      should go here.}
 %     \end{figure}

%\begin{figure}[h!]
%  \caption{\csentence{Sample figure title.}
%      Figure legend text.}
%      \end{figure}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                               %%
%% Tables                        %%
%%                               %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Use of \listoftables is discouraged.
%%



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                               %%
%% Additional Files              %%
%%                               %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section*{Supplementary information}
  \subsection*{Additional file 1 --- An SDFfile with the CHEMDNER corpus}
  Can be viewed using Knime or any SDFviewer. Is provided in gzip format.

  \subsection*{Additional file 2 --- The set of text files extracted from NCBI PubMed and relevant to the inhibition of SARS-CoV-2 main protease (Mpro).}
    A set of text files provided in gzip format.
    \subsection*{Additional file 3 --- The set of chemical named entities extracted from the texts relevant to the inhibition of SARS-CoV-2 (Mpro); the filters for CNE filtration are included. }
 Is provided in MS Excel format.


\end{backmatter}
\end{document}
