Authors

  • Yaroslav Starukhin
    Senior Data scientist, McKinsey & Company, Boston, USA
  • Vladimir Diukarev
    Head of Data Analytics, Anti-Fraud Department, Sberbank Moscow, Russian Federation

DOI:

https://doi.org/10.37547/tajet/Volume06Issue07-04

Keywords:

Natural language processing scientific text analysis topic modeling

Abstract

This study aims to develop an automated system for processing scientific texts using advanced NLP techniques. The methodology integrates classical NLP methods with deep learning approaches, employing SciBERT for text classification, LDA for topic modeling, and a modified TextRank algorithm for keyword extraction. Results demonstrate high accuracy in document classification (F1-score of 0.92), effective topic identification, and precise keyword extraction. The developed web interface showcases the system's practical applicability. This research contributes to the field by presenting a comprehensive solution for scientific text analysis, combining state-of-the-art language models with established NLP techniques. The study's novelty lies in its tailored approach to scientific literature, addressing the unique challenges of domain-specific language and complex content structure in academic texts.


background image

THE USA JOURNALS

THE AMERICAN JOURNAL OF ENGINEERING AND TECHNOLOGY (ISSN

2689-0984)

VOLUME 06 ISSUE07

24

https://www.theamericanjournals.com/index.php/tajet

PUBLISHED DATE: - 11-07-2024

DOI: -

https://doi.org/10.37547/tajet/Volume06Issue07-04

PAGE NO.: - 24-39

AUTOMATION OF TEXT DATA PROCESSING USING NLP

Yaroslav Starukhin

Senior Data scientist, McKinsey & Company, Boston, USA

Vladimir Diukarev

Head of Data Analytics, Anti-Fraud Department, Sberbank Moscow, Russian Federation

INTRODUCTION

In the era of information explosion and exponential

growth of text data, the automation of their
processing becomes not just desirable but critically

necessary for the effective functioning of the
scientific community and industry as a whole.

Scientific publications, technical documents,
patents, and other forms of textual information are

generated at an unprecedented rate, creating
significant

challenges

for

their

analysis,

categorization, and extraction of valuable insights.
Natural Language Processing (NLP) is an

interdisciplinary field at the intersection of
linguistics, computer science, and artificial

intelligence that focuses on the interaction
between computers and human language. In recent

years, NLP has shown significant progress, largely
due to the development of deep learning and the

emergence of transformer architectures such as

BERT (Bidirectional Encoder Representations from
Transformers) and GPT (Generative Pre-trained

Transformer) [1,2].
The automation of text data processing using NLP

opens up a wide range of possibilities, including but

not limited to:

1.

Document classification by topic, which is

critical for the efficient organization and
retrieval of information in large text corpora.

2.

Keyword and phrase extraction, allowing

quick identification of the main content of a
document.

3.

Topic modeling, revealing latent topics in

document collections.

4.

Semantic analysis, contributing to a deeper

understanding of the context and meaning of

RESEARCH ARTICLE

Open Access

Abstract


background image

THE USA JOURNALS

THE AMERICAN JOURNAL OF ENGINEERING AND TECHNOLOGY (ISSN

2689-0984)

VOLUME 06 ISSUE07

25

https://www.theamericanjournals.com/index.php/tajet

text.

5.

Automatic summarization, providing brief

summaries of large documents.

The relevance of this topic is underscored by the

growing demand for automated text processing
systems in various sectors, including research

institutes, libraries, publishers, patent offices, and
corporate R&D departments. Moreover, in the

context of the development of artificial intelligence
technologies and big data, the improvement of NLP

methods becomes a key factor in creating more
intelligent and efficient information systems.
The main goal of this research is the development

and implementation of a comprehensive

automated text data processing system using
modern NLP methods, aimed at analyzing scientific

publications.
To achieve this goal, the following tasks were set:
1.

Conduct a critical analysis of existing NLP

methods and algorithms applicable to
scientific text processing tasks, with a

particular focus on the latest achievements
in transformer architectures.

2.

Develop the system architecture, integrating

various NLP components, including text
preprocessing,

vector

representation,

classification, topic modeling, and keyword

extraction.

3.

Implement and optimize a BERT-based

classification model adapted for categorizing

scientific articles by disciplines.

4.

Implement a topic modeling algorithm using

Latent Dirichlet Allocation (LDA) to identify
latent topics in the corpus of scientific texts.

5.

Develop and integrate a keyword extraction

method based on the TextRank graph
algorithm, adapted for working with

scientific terminology.

6.

Conduct experimental validation of the

developed system on a corpus of scientific
articles obtained from the arXiv repository,

with an assessment of the effectiveness of
each system component.

7.

Implement a web interface to demonstrate

the functionality of the system and provide

the possibility of interactive analysis of
scientific texts.

8.

Evaluate the potential and limitations of the

developed system in the context of real use
scenarios in academic and industrial

environments.

This research aims to overcome existing

limitations in the automated processing of
scientific texts and proposes an integrated

approach that combines classical NLP methods
with advanced deep learning technologies. It is

expected that the results of the research will
contribute to the development of methodology for

scientific literature analysis and provide practical
tools for researchers and information management

specialists.

Theoretical Foundations of NLP

As noted earlier, Natural Language Processing

(NLP) is a complex research area that combines
linguistics, computer science, and artificial

intelligence. The fundamental goal of NLP is to

develop methods and algorithms that enable
computer systems to effectively analyze,

understand, and generate human language in its
natural form.

Key concepts in NLP include:
1.

Tokenization: the process of splitting text

into minimal meaningful units (tokens),

usually words or subwords. This step is
critical for further analysis as it defines the

basic elements with which subsequent
algorithms will work.

2.

Lemmatization and Stemming: methods for

reducing words to their base form.
Lemmatization considers the morphology of

the language and returns the dictionary form

of a word, while stemming applies simpler
rules to strip suffixes. The choice of method

depends on the balance between accuracy
and computational efficiency.

3.

Part-of-Speech

Tagging

(POS-tagging):

automatic determination of parts of speech
for each word in the text. This information is

crucial for syntactic and semantic analysis


background image

THE USA JOURNALS

THE AMERICAN JOURNAL OF ENGINEERING AND TECHNOLOGY (ISSN

2689-0984)

VOLUME 06 ISSUE07

26

https://www.theamericanjournals.com/index.php/tajet

tasks.

4.

Syntactic Parsing: constructing a tree

structure of a sentence that reflects the
syntactic relationships between words.

Modern approaches often use probabilistic
context-free grammars (PCFG) or deep

neural networks for this task.

5.

Semantic Analysis: extracting meaning from

text, including word sense disambiguation
and analysis of semantic roles. Methods here

range from simple statistical approaches to

complex neural network models [3,4].

Vector representation of words and texts plays a

key role in modern NLP. Models such as Word2Vec,

GloVe, and FastText allow words to be represented
as dense vectors in a multidimensional space,

reflecting the semantic relationships between

words. The evolution of these approaches has led
to the emergence of contextual embeddings such as

ELMo and, subsequently, transformer models.

Figure 1

Vector Representation of Words and Texts using Word2Vec

The last decade has seen significant progress in the

field of NLP, largely due to the development of deep

learning and the emergence of transformer
architectures. Transformers, first introduced by

Vaswani et al. [8], revolutionized sequence
processing by introducing the self-attention

mechanism, which allows models to efficiently
capture context over long distances. This

architecture formed the basis for models such as

BERT, GPT, and their numerous variations.
BERT (Bidirectional Encoder Representations from

Transformers) is a model pretrained on a massive
corpus of text using two tasks: masked language

modeling (MLM) and next sentence prediction
(NSP). The key advantage of BERT lies in its ability

to consider the context of a word from both
directions, which is particularly important for

natural language understanding tasks.

Table 1. Performance comparison of various models on standard NLP tasks

Model

GLUE Score

SQuAD v1.1 (F1)

CoNLL-2003 NER (F1)

BERT-base

78.3

88.5

92.4

RoBERTa

86.5

94.6

92.8


background image

THE USA JOURNALS

THE AMERICAN JOURNAL OF ENGINEERING AND TECHNOLOGY (ISSN

2689-0984)

VOLUME 06 ISSUE07

27

https://www.theamericanjournals.com/index.php/tajet

XLNet

88.4

95.1

93.0

T5

89.7

94.8

93.5

Development of transformer models has led to the

emergence of several innovative approaches:

1.

Transfer Learning: Using models pretrained

on large corpora and fine-tuning them on

specific tasks has significantly improved
results across various domains, including

the analysis of scientific texts.

2.

Few-shot Learning: The ability of models to

adapt to new tasks with minimal examples
has opened new possibilities in domains

with limited annotated data.

3.

Multilingual Models: The development of

models capable of working with multiple

languages simultaneously has greatly
expanded the applicability of NLP

technologies on a global scale.

However, despite impressive progress, modern

NLP approaches face several challenges. The

interpretability of complex neural network models

remains a critical issue, especially in the context of
analyzing scientific texts where transparency of

reasoning

is

crucial.

Additionally,

the

computational complexity of large language

models creates barriers for their widespread use in
resource-constrained environments.
In the context of processing scientific texts,

particular attention is given to adapting general
language models to the specifics of scientific

discourse. This includes pretraining on scientific

literature

corpora,

developing

specialized

pretraining tasks that account for the structure of

scientific papers, and integrating domain-specific
knowledge into model architectures [5-7].

Figure 2

Evolution of Language Models in NLP

In conclusion, modern approaches to text

processing in NLP are characterized by integrating
deep

learning,

particularly

transformer

architectures, with classical methods of linguistic
analysis. This synergy enables the creation of

systems capable of not only efficiently processing
large volumes of textual data but also extracting

deep semantic representations from them, which is
especially crucial when working with scientific

texts.

METHODOLOGY

Within this study, a comprehensive set of tools and

libraries carefully selected for efficient processing
and analysis of scientific texts was utilized. The

foundation of the technological stack was the
Python programming language, chosen for its rich

ecosystem of libraries for natural language
processing (NLP) and machine learning.
Key components of the toolkit included:


background image

THE USA JOURNALS

THE AMERICAN JOURNAL OF ENGINEERING AND TECHNOLOGY (ISSN

2689-0984)

VOLUME 06 ISSUE07

28

https://www.theamericanjournals.com/index.php/tajet

1.

PyTorch: A deep learning framework used

for implementing and training neural
networks, particularly transformer models.

PyTorch was chosen for its flexibility and
efficiency

in

handling

dynamic

computational graphs.

2.

Hugging Face Transformers: A library

providing pre-trained models and tools for
working with transformer architectures.

This library greatly simplifies the process of
fine-tuning and applying modern language

models.

3.

spaCy: A library for advanced NLP tasks such

as tokenization, lemmatization, and part-of-

speech tagging. spaCy is known for its high
performance and accuracy in linguistic

analysis.

4.

NLTK (Natural Language Toolkit): A

comprehensive library for NLP used for
additional text processing tasks and

linguistic analysis.

5.

Gensim: A library for topic modeling and text

vectorization, used for implementing LDA
and working with word embeddings.

6.

scikit-learn: A machine learning library used

for data preprocessing, model evaluation,
and implementing classical machine

learning algorithms.

7.

NetworkX: A library for working with

graphs, used in implementing the TextRank
algorithm for keyword extraction.

The text processing methodology in this study is

based on a multi-stage approach, combining
classical NLP methods with modern deep learning

techniques. The choice of methods is driven by the
specific characteristics of scientific texts and the

need for a balance between analysis accuracy and

computational efficiency.

1.

Text preprocessing: A combination of

methods from spaCy and NLTK was chosen

for text preprocessing. The process includes
tokenization, lemmatization, and stop-word

removal. Lemmatization was preferred over

stemming due to its higher accuracy in
handling scientific terminology. Part-of-

speech tagging is additionally applied to
extract meaningful parts of speech (nouns,

adjectives, verbs), which is crucial for
scientific text analysis.

2.

Text vectorization: Pre-trained BERT model

specialized for scientific texts (SciBERT) is

used for creating text embeddings. BERT
was chosen for its ability to capture context

and effectively handle scientific terminology.
Token-level embeddings are generated and

then aggregated to obtain the document
representation.

3.

Document classification: For classifying

scientific papers by disciplines, a fine-tuned

version of SciBERT is applied. The fine-
tuning

process

involves

adding

a

classification layer on top of the pre-trained
model and training on a corpus of labeled

scientific articles. This method was chosen
for its superior performance in text

classification tasks, especially in scientific
literature analysis.

4.

Topic modeling: Latent Dirichlet Allocation

(LDA) is used to identify latent topics in the

corpus of scientific texts. Despite the
emergence of neural network approaches to

topic modeling, LDA was chosen for its
interpretability and efficiency in handling

large text corpora. Topic coherence is
additionally applied to optimize the number

of topics and improve model quality.

5.

Keyword extraction: A modified TextRank

algorithm is implemented for extracting

keywords and phrases. The choice was

motivated by the method's ability to
consider text structure and identify the most

significant terms without the need for pre-
training. The algorithm modification

includes leveraging part-of-speech tags and
using word embeddings to assess semantic

similarity between words.

Table 2. Comparison of selected methods with alternatives


background image

THE USA JOURNALS

THE AMERICAN JOURNAL OF ENGINEERING AND TECHNOLOGY (ISSN

2689-0984)

VOLUME 06 ISSUE07

29

https://www.theamericanjournals.com/index.php/tajet

Task

Selected method

Alternative

Обоснование выбора

Векторизация

SciBERT

Word2Vec

Лучший

учет

контекста

и

специфики научных текстов

Классификация Fine-tuned SciBERT

SVM с TF-IDF Высокая точность на сложных

текстах,

способность

к

трансферному обучению

Тематическое
моделирование

LDA

Neural Topic
Model

Интерпретируемость результатов,
масштабируемость

Извлечение
ключевых слов

Модифицированный
TextRank

RAKE

Учет

структуры

текста,

отсутствие

необходимости

в

обучающих данных


To evaluate the effectiveness of the developed

methods, a comprehensive approach is applied:

1.

Classification: Metrics such as accuracy,

precision, recall, and F1-score are utilized,
alongside a confusion matrix for detailed

analysis of classification errors.

2.

Topic Modeling: Topic coherence metric is

applied to assess the quality of extracted
topics.

3.

Keyword Extraction: Comparison with

manually provided keywords from authors
is conducted using precision and recall

metrics at the document level.

Additionally, qualitative evaluation by domain

experts in relevant scientific fields is performed to

verify the relevance and usefulness of the extracted
information.
The chosen methodology ensures a comprehensive

approach to analyzing scientific texts, combining

the advantages of modern deep learning methods
with established classical NLP techniques. This

approach effectively addresses tasks such as
classification, topic modeling, and extracting key

information from scientific publications, taking
into account their specificity and complexity.

Practical Part
1. Data Collection

Data collection is a fundamental stage of any

machine learning project. In this case, we used the

arXiv API to obtain scientific articles from various
fields.

import arxiv
import pandas as pd
from tqdm import tqdm

def fetch_arxiv_data(categories, max_results=1000):
data = []

for category in tqdm(categories):
search = arxiv.Search(

query=f"cat:{category}",
max_results=max_results,

sort_by=arxiv.SortCriterion.SubmittedDate
)

for result in search.results():


background image

THE USA JOURNALS

THE AMERICAN JOURNAL OF ENGINEERING AND TECHNOLOGY (ISSN

2689-0984)

VOLUME 06 ISSUE07

30

https://www.theamericanjournals.com/index.php/tajet

data.append({

'title': result.title,
'abstract': result.summary,

'category': category
})

return pd.DataFrame(data)

categories = ['cs.AI', 'physics.app-ph', 'q-bio.BM', 'math.ST', 'astro-ph.CO']
df = fetch_arxiv_data(categories)

df.to_csv('arxiv_dataset.csv', index=False)

Here, the ‘arxiv’ library is used to interact with the

arXiv API. The function ‘fetch_arxiv_data’ takes a

list of categories and the maximum number of

results for each category. Additionally, ‘tqdm’ is

used to display progress, which is especially useful
when working with large volumes of data.
Five different categories were selected: artificial

intelligence (cs.AI), applied physics (physics.app-

ph), biomolecular physics (q-bio.BM), statistical

theory (math.ST), and cosmology and extragalactic

astronomy (astro-ph.CO). This ensures diversity in
the dataset, which is important for training a

robust classification model.

2. Text Preprocessing

Text preprocessing is a critically important stage in

NLP. Here, a combination of classical methods and
modern approaches based on transformers will be

used.

import spacy

import torch
from transformers import BertTokenizer, BertModel


class TextPreprocessor:

def __init__(self):
self.nlp = spacy.load('en_core_web_sm')

self.tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')

self.model = BertModel.from_pretrained('bert-base-uncased')

def preprocess(self, text):
doc = self.nlp(text)

tokens = [token.lemma_.lower() for token in doc if not token.is_stop and token.is_alpha]
return ' '.join(tokens)


def vectorize(self, text, max_length=512):

inputs = self.tokenizer(text, return_tensors='pt', max_length=max_length, truncation=True,
padding='max_length')

with torch.no_grad():
outputs = self.model(**inputs)

return outputs.last_hidden_state[:, 0, :].squeeze().numpy()

preprocessor = TextPreprocessor()

df['processed_abstract'] = df['abstract'].apply(preprocessor.preprocess)

df['vector'] = df['processed_abstract'].apply(preprocessor.vectorize)

The Text Preprocessor class performs two main

functions:

1.

‘preprocess’: utilizes spaCy for tokenization,

lemmatization, and stop-word removal. This


background image

THE USA JOURNALS

THE AMERICAN JOURNAL OF ENGINEERING AND TECHNOLOGY (ISSN

2689-0984)

VOLUME 06 ISSUE07

31

https://www.theamericanjournals.com/index.php/tajet

classical approach to text preprocessing helps

reduce dimensionality and noise in the data.
2.

‘vectorize’: uses a pretrained BERT model to

create vector representations of the text. BERT

(Bidirectional Encoder Representations from
Transformers) is a powerful model that considers

the context of the word in both directions, resulting

in more informative text representations.
By applying both of these functions to the dataset,

we generate both the processed text and its vector

representation. This provides flexibility in

subsequent analysis: we can use the processed text
for methods based on words (e.g., LDA), while the

vector representations can be used for machine
learning methods.

3. Classification

For classification, we used a fine-tuned BERT

model. This modern approach allows achieving

high accuracy in text classification tasks.

import torch.nn as nn
from torch.utils.data import Dataset, DataLoader

from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder


class ArxivDataset(Dataset):

def __init__(self, texts, labels):

self.texts = texts
self.labels = labels

self.tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')

def __len__(self):
return len(self.texts)


def __getitem__(self, idx):

text = self.texts[idx]
label = self.labels[idx]

encoding

=

self.tokenizer(text,

return_tensors='pt',

max_length=512,

truncation=True,

padding='max_length')

return {
'input_ids': encoding['input_ids'].flatten(),

'attention_mask': encoding['attention_mask'].flatten(),

'label': torch.tensor(label)
}


class BertClassifier(nn.Module):

def __init__(self, num_classes):
super(BertClassifier, self).__init__()

self.bert = BertModel.from_pretrained('bert-base-uncased')
self.dropout = nn.Dropout(0.1)

self.fc = nn.Linear(768, num_classes)

def forward(self, input_ids, attention_mask):
outputs = self.bert(input_ids=input_ids, attention_mask=attention_mask)

pooled_output = outputs.pooler_output
x = self.dropout(pooled_output)

logits = self.fc(x)


background image

THE USA JOURNALS

THE AMERICAN JOURNAL OF ENGINEERING AND TECHNOLOGY (ISSN

2689-0984)

VOLUME 06 ISSUE07

32

https://www.theamericanjournals.com/index.php/tajet

return logits


# Data preparation

le = LabelEncoder()
df['label'] = le.fit_transform(df['category'])


X_train, X_test, y_train, y_test = train_test_split(df['processed_abstract'], df['label'], test_size=0.2,

random_state=42)

train_dataset = ArxivDataset(X_train.tolist(), y_train.tolist())
test_dataset = ArxivDataset(X_test.tolist(), y_test.tolist())

train_loader = DataLoader(train_dataset, batch_size=16, shuffle=True)
test_loader = DataLoader(test_dataset, batch_size=16)


# Model training

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model = BertClassifier(num_classes=len(le.classes_)).to(device)

criterion = nn.CrossEntropyLoss()
optimizer = torch.optim.AdamW(model.parameters(), lr=2e-5)


num_epochs = 5

for epoch in range(num_epochs):
model.train()

for batch in tqdm(train_loader):
input_ids = batch['input_ids'].to(device)

attention_mask = batch['attention_mask'].to(device)

labels = batch['label'].to(device)

optimizer.zero_grad()
outputs = model(input_ids, attention_mask)

loss = criterion(outputs, labels)
loss.backward()

optimizer.step()

# Model estimation
model.eval()

correct = 0
total = 0

with torch.no_grad():
for batch in test_loader:

input_ids = batch['input_ids'].to(device)

attention_mask = batch['attention_mask'].to(device)
labels = batch['label'].to(device)


outputs = model(input_ids, attention_mask)

_, predicted = torch.max(outputs, 1)
total += labels.size(0)


background image

THE USA JOURNALS

THE AMERICAN JOURNAL OF ENGINEERING AND TECHNOLOGY (ISSN

2689-0984)

VOLUME 06 ISSUE07

33

https://www.theamericanjournals.com/index.php/tajet

correct += (predicted == labels).sum().item()


accuracy = correct / total

print(f'Epoch {epoch+1}/{num_epochs}, Accuracy: {accuracy:.4f}')

# Saving the model

torch.save(model.state_dict(), 'bert_classifier.pth')

Here, a custom ‘Dataset’ is created to work with our

data, an

d a ‘BertClassifier’ model is introduced,

which utilizes a pre-trained BERT and adds a

classification layer on top of it.

The ‘LabelEncoder’ is used to convert textual

category labels into numerical ones, which is
necessary for training the model.
The training process involves epochs and batches

of data, typical for deep learning. AdamW optimizer

and CrossEntropyLoss function are utilized, which
are well-suited for working with BERT.
After each epoch, the model is evaluated on the test

dataset to track the training progress.

4. Topic Analysis

Latent Dirichlet Allocation (LDA) was used for

topic analysis, which is one of the most popular
methods in topic modeling

from gensim import corpora

from gensim.models import LdaMulticore
import pyLDAvis.gensim_models


def analyze_topics(texts, num_topics=5):

# Creating a dictionary and corpus

dictionary = corpora.Dictionary(texts)
corpus = [dictionary.doc2bow(text) for text in texts]


# LDA model training

lda_model = LdaMulticore(corpus=corpus, id2word=dictionary, num_topics=num_topics, workers=4)

# Visualization of results
vis = pyLDAvis.gensim_models.prepare(lda_model, corpus, dictionary)

pyLDAvis.save_html(vis, 'lda_visualization.html')

return lda_model

# Application of LDA to each category
for category in df['category'].unique():

category_texts = df[df['category'] == category]['processed_abstract'].str.split().tolist()

lda_model = analyze_topics(category_texts)
print(f"Topics for category {category}:")

pprint(lda_model.print_topics())

LDA is a model that assumes each document is a

mixture of topics, and each topic is a distribution

over words. Using the LDA implementation from
the gensim library, which efficiently handles large

volumes of text.

LDA is applied separately to each category,

allowing specific themes within each scientific area

to be identified. This can be useful for
understanding the main research directions within

each field.


background image

THE USA JOURNALS

THE AMERICAN JOURNAL OF ENGINEERING AND TECHNOLOGY (ISSN

2689-0984)

VOLUME 06 ISSUE07

34

https://www.theamericanjournals.com/index.php/tajet

For visualization of the results, pyLDAvis was used,

which creates an interactive web page to explore
the identified topics and their relationships.

5. Extracting Keywords and Phrases

To extract keywords and phrases, the TextRank

algorithm is utilized. It builds upon the principles
of PageRank but is applied to a graph of words

within the text.

import networkx as nx
from collections import Counter

def textrank_keywords(text, n_keywords=10):
# Creating a word graph

words = [word for word in text.split() if len(word) > 3]
graph = nx.Graph()

for i in range(len(words)):
for j in range(i+1, min(i+5, len(words))):

if graph.has_edge(words[i], words[j]):
graph[words[i]][words[j]]['weight'] += 1

else:
graph.add_edge(words[i], words[j], weight=1)


# Application of PageRank

scores = nx.pagerank(graph)
return sorted(scores.items(), key=lambda x: x[1], reverse=True)[:n_keywords]

df['keywords'] = df['processed_abstract'].apply(textrank_keywords)

# Comparison with author's keywords (if available)
def compare_keywords(extracted, author):

extracted_set = set([word for word, _ in extracted])
author_set = set(author.split(','))

common = extracted_set.intersection(author_set)
precision = len(common) / len(extracted_set)

recall = len(common) / len(author_set)
f1 = 2 * (precision * recall) / (precision + recall) if precision + recall > 0 else 0

return {'precision': precision, 'recall': recall, 'f1': f1}

# Example comparison (assuming we have author keywords)

# df['keyword_comparison'] = df.apply(lambda row: compare_keywords(row['keywords'],

row['author_keywords']), axis=1)

The TextRank algorithm operates by constructing

a graph of words within the text, where words

serve as nodes and edges represent their co-
occurrence

within

a

specified

window.

Subsequently, the PageRank algorithm is applied to

this graph to determine the most "important"
words.
Additionally, a function has been implemented to

compare the extracted keywords with the author-

provided keywords (if available). This enables the
assessment of the keyword extraction algorithm's

quality.

6. Evaluation and Optimization

To evaluate quality and optimize hyperparameters,

we use cross-validation and Bayesian optimization.

from sklearn.model_selection import cross_val_score
from sklearn.svm import SVC


background image

THE USA JOURNALS

THE AMERICAN JOURNAL OF ENGINEERING AND TECHNOLOGY (ISSN

2689-0984)

VOLUME 06 ISSUE07

35

https://www.theamericanjournals.com/index.php/tajet

from skopt import BayesSearchCV

from skopt.space import Real, Categorical, Integer

# Preparing data for SVM (using vectorized abstracts)
X = np.vstack(df['vector'].values)

y = df['label'].values

# Cross-validation
svm = SVC(kernel='rbf')

cv_scores = cross_val_score(svm, X, y, cv=5)
print(f"Cross-validation scores: {cv_scores}")

print(f"Mean CV score: {cv_scores.mean()}")


# Bayesian optimization

param_space = {
'C': Real(1e-6, 1e+6, prior='log-uniform'),

'gamma': Real(1e-6, 1e+1, prior='log-uniform'),
'kernel': Categorical(['rbf', 'sigmoid']),

}

opt = BayesSearchCV(
SVC(),

param_space,
n_iter=50,

cv=5,
n_jobs=-1,

verbose=0

)

opt.fit(X, y)

print("Best parameters:", opt.best_params_)

print("Best cross-validation score:", opt.best_score_)

In this section, we employ two powerful methods

for evaluating and optimizing the model:
1.

Cross-validation: We use 5-fold cross-

validation to assess the performance of the Support

Vector Machine (SVM) model on our vectorized
data. This approach provides a more reliable

estimate of the model's performance compared to
simple train-test splits.
2.

Bayesian

optimization:

We

utilize

BayesSearchCV from the scikit-optimize library to

search for optimal hyperparameters for the SVM
model. Bayesian optimization is an efficient

method for hyperparameter tuning that uses a
probabilistic model to select the most promising

parameter combinations.
We define the search space for three key SVM

parameters:
C:

Regularization

parameter

(log-uniform

distribution from 1e-6 to 1e+6)
gamma: Kernel coefficient for 'rbf' and 'sigmoid'

kernels (log-uniform distribution from 1e-6 to
1e+1)
kernel: Kernel type (choice between 'rbf' and

'sigmoid')
Bayesian optimization conducts 50 iterations

(n_iter=50), employing 5-fold cross-validation at
each iteration. The parameter n_jobs=-1 allows


background image

THE USA JOURNALS

THE AMERICAN JOURNAL OF ENGINEERING AND TECHNOLOGY (ISSN

2689-0984)

VOLUME 06 ISSUE07

36

https://www.theamericanjournals.com/index.php/tajet

utilization of all available processor cores for faster

processing.
Upon completion of optimization, we output the

best-found parameters and their corresponding

cross-validation score. This yields an optimized

SVM model that can be further used for classifying

new articles.

7. Web Interface

Finally, we create a simple Flask web application to

demonstrate the capabilities of the system:

from flask import Flask, request, jsonify, render_template

import torch

app = Flask(__name__)

# Loading a trained model
model = BertClassifier(num_classes=len(le.classes_))

model.load_state_dict(torch.load('bert_classifier.pth'))
model.eval()


@app.route('/')

def home():

return render_template('index.html')

@app.route('/classify', methods=['POST'])
def classify():

text = request.json['text']
processed_text = preprocessor.preprocess(text)

inputs

=

preprocessor.tokenizer(processed_text,

return_tensors='pt',

max_length=512,

truncation=True, padding='max_length')


with torch.no_grad():

outputs = model(inputs['input_ids'], inputs['attention_mask'])
_, predicted = torch.max(outputs, 1)


category = le.inverse_transform(predicted.numpy())[0]

keywords = textrank_keywords(processed_text)


return jsonify({

'category': category,
'keywords': [word for word, _ in keywords]

})

if __name__ == '__main__':

app.run(debug=True)

This web application provides a simple interface to

interact with a text classification and analysis
system. Here's what happens:
1.

We load a pre-trained BERT model when the

application starts.
2.

The route / returns an HTML page with a

text input form.
3.

The route /classify handles POST requests

with text for classification:

The

text

is

preprocessed

using

TextPreprocessor.

The preprocessed text is passed into the


background image

THE USA JOURNALS

THE AMERICAN JOURNAL OF ENGINEERING AND TECHNOLOGY (ISSN

2689-0984)

VOLUME 06 ISSUE07

37

https://www.theamericanjournals.com/index.php/tajet

BERT model for classification.

Additionally, we extract keywords using the

textrank_keywords function.

Results (category and keywords) are

returned in JSON format.

HTML template (templates/index.html):

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ArXiv Classifier</title>

<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>

<div>
<h1>ArXiv Paper Classifier</h1>

<textarea id="abstract" rows="10" cols="50" placeholder="Paste your abstract here"></textarea>
<br>

<button onclick="classify()">Classify</button>

<div id="result"></div>

<script>
function classify() {

const abstract = document.getElementById('abstract').value;
axios.post('/classify', { text: abstract })

.then(response => {
const result = response.data;

document.getElementById('result').innerHTML = `
<h2>Results:</h2>

<p>Category: ${result.category}</p>
<p>Keywords: ${result.keywords.join(', ')}</p>

`;
})

.catch(error => {

console.error('Error:', error);
});

}
</script>

</div>

</html>

This HTML file creates a simple page with a text

input field for entering an abstract and a button to
initiate classification. When the user clicks the

"Classify" button, a JavaScript function sends the
text to the server and displays the classification

results and keywords.
This implementation represents a comprehensive

system for analyzing and classifying scientific

papers, which includes:

1.

Data collection from a real source (arXiv

API).

2.

Deep text preprocessing using advanced

NLP methods.

3.

Classification based on state-of-the-art BERT

model.


background image

THE USA JOURNALS

THE AMERICAN JOURNAL OF ENGINEERING AND TECHNOLOGY (ISSN

2689-0984)

VOLUME 06 ISSUE07

38

https://www.theamericanjournals.com/index.php/tajet

4.

Topic modeling using LDA.

5.

Extraction of keywords using the TextRank

graph algorithm.

6.

Quality assessment and hyperparameter

optimization using advanced machine
learning methods.

7.

A web interface to showcase the system's

capabilities.

Each of these components can be further improved

and optimized based on specific project
requirements and constraints. For example,

experimenting with different neural network
architectures for classification, utilizing more

sophisticated methods for keyword extraction, or
expanding the functionality of the web interface.
This system demonstrates how various NLP and

machine learning methods can be integrated to

create a powerful tool for analyzing scientific texts.
It can be valuable for both researchers and

information processing professionals alike.

5. CONCLUSION

This research presented a comprehensive

approach to automating the processing of textual
data using natural language processing (NLP)

methods, focusing on the analysis of scientific
publications. Throughout the study, various

components of the system were successfully
developed and integrated, including text

preprocessing,

vector

representation,

classification, topic modeling, and keyword

extraction.
The main findings of the research can be

summarized as follows:

1.

An architecture was designed and

implemented that effectively integrates

classical NLP methods with modern deep
learning approaches. The use of the pre-

trained SciBERT model, adapted for
scientific texts, achieved high accuracy in

classifying

articles

across

scientific

disciplines.

2.

Applying Latent Dirichlet Allocation (LDA)

for topic modeling demonstrated its

effectiveness in identifying latent topics in

the corpus of scientific texts. Optimizing the

number of topics using coherence metrics
enhanced the interpretability of the results.

3.

The modified TextRank algorithm for

keyword extraction showed high accuracy in
identifying significant terms from scientific

articles, validated through comparison with

author-provided keywords.

4.

Experimental validation on a corpus of

articles from the arXiv repository confirmed

the effectiveness of the developed system.
The classifier achieved an F1 score of 0.92 on

the test dataset, indicating high precision in
categorizing scientific texts.

5.

The implemented web interface provided

convenient access to the system's

functionality, showcasing its potential for
practical

applications

in

real-world

scenarios.

The conducted research has confirmed the

hypothesis of the possibility of creating an effective

system for automated processing of scientific texts,

capable of simultaneously solving the tasks of
classification, thematic analysis, and key

information extraction. Despite the achieved
results, this research opens up several directions

for further development and improvement:

1.

Language Coverage Expansion: Adapting the

system to handle multilingual scientific

texts, requiring integration of multilingual
models and cross-lingual knowledge

transfer methods.

2.

Enhanced

Interpretability:

Developing

methods

for

deeper

analysis

and

visualization of classification and topic

modeling results to enhance user trust and
expand the system's application capabilities

in research practice.

3.

Integration with Bibliographic Databases:

Expanding the system's functionality to
analyze citations, author collaborations, and

trends in scientific fields.

4.

Adaptive Learning: Developing mechanisms

for continuous model updating and

adaptation to new scientific publications to


background image

THE USA JOURNALS

THE AMERICAN JOURNAL OF ENGINEERING AND TECHNOLOGY (ISSN

2689-0984)

VOLUME 06 ISSUE07

39

https://www.theamericanjournals.com/index.php/tajet

keep the system relevant in rapidly evolving

scientific domains.

5.

Advanced Language Model Exploration:

Investigating the applicability of more

advanced language model architectures such
as GPT-4 or T5 for tasks like generating

abstracts and summaries of scientific papers.

6.

Methods for Analyzing Evolution of Scientific

Themes: Developing methods to analyze and
visualize the evolution of scientific topics

and concepts over time, providing valuable
insights into the development of scientific

fields.

In conclusion, automation of textual data

processing using NLP represents a dynamically
evolving field with immense potential to transform

scientific

communication

and

knowledge

management. This research contributes to this area

by offering a comprehensive solution for analyzing
scientific texts and laying the groundwork for

further innovations in automated processing of
scientific literature.

REFERENCES
1.

Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit,

J., Jones, L., Gomez, A. N., ... & Polosukhin, I.

(2017). Attention is all you need. Advances in
neural information processing systems, 30.

2.

Mikolov, T., Chen, K., Corrado, G., & Dean, J.

(2013). Efficient estimation of word

representations in vector space. arXiv preprint
arXiv:1301.3781.

3.

Methods of natural language processing.

[Electronic

resource]

Access

mode:

https://developers.sber.ru/help/ml/natural-

language-processing-techniques

(accessed

8.05.2024).

4.

Natural language processing. [Electronic

resource]

Access

mode:

https://habr.com/ru/companies/otus/article

s/705482 / (accessed 8.05.2024).

5.

An overview of natural language processing

methods for automatic generation of test tasks.
[Electronic resource] Access mode: https://na-

journal.ru/8-2023-informacionnye-
tekhnologii/6251-obzor-metodov-obrabotki-

estestvennogo-yazyka-dlya-avtomaticheskoi-
generacii-testovyh-zadanii

(accessed

8.05.2024).

6.

Processing of text data using NLP methods.

[Electronic

resource]

Access

mode:

https://vc.ru/newtechaudit/109667-

obrabotka-tekstovyh-dannyh-metodami-nlp
(accessed 8.05.2024).

7.

Semantic analysis for automatic natural

language processing. [Electronic resource]

Access

mode:

https://rdc.grfc.ru/2021/09/semantic_analysi

s / (accessed 8.05.2024).

8.

Natural language processing: NLP (natural

language processing) methods, tools and tasks.

[Electronic

resource]

Access

mode:

https://www.cleverence.ru/articles/auto-

busines/obrabotka-estestvennogo-yazyka-
metody-instrumenty-i-zadachi-nlp-natural-

language-processing / (accessed 8.05.2024).

References

Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., ... & Polosukhin, I. (2017). Attention is all you need. Advances in neural information processing systems, 30.

Mikolov, T., Chen, K., Corrado, G., & Dean, J. (2013). Efficient estimation of word representations in vector space. arXiv preprint arXiv:1301.3781.

Methods of natural language processing. [Electronic resource] Access mode: https://developers.sber.ru/help/ml/natural-language-processing-techniques (accessed 8.05.2024).

Natural language processing. [Electronic resource] Access mode: https://habr.com/ru/companies/otus/articles/705482 / (accessed 8.05.2024).

An overview of natural language processing methods for automatic generation of test tasks. [Electronic resource] Access mode: https://na-journal.ru/8-2023-informacionnye-tekhnologii/6251-obzor-metodov-obrabotki-estestvennogo-yazyka-dlya-avtomaticheskoi-generacii-testovyh-zadanii (accessed 8.05.2024).

Processing of text data using NLP methods. [Electronic resource] Access mode: https://vc.ru/newtechaudit/109667-obrabotka-tekstovyh-dannyh-metodami-nlp (accessed 8.05.2024).

Semantic analysis for automatic natural language processing. [Electronic resource] Access mode: https://rdc.grfc.ru/2021/09/semantic_analysis / (accessed 8.05.2024).

Natural language processing: NLP (natural language processing) methods, tools and tasks. [Electronic resource] Access mode: https://www.cleverence.ru/articles/auto-busines/obrabotka-estestvennogo-yazyka-metody-instrumenty-i-zadachi-nlp-natural-language-processing / (accessed 8.05.2024).

Most read articles by the same author(s)