make-06-00041-v2
make-06-00041-v2
knowledge extraction
Article
Enhancing Legal Sentiment Analysis: A Convolutional Neural
Network–Long Short-Term Memory Document-Level Model
Bolanle Abimbola 1, * , Enrique de La Cal Marin 1 and Qing Tan 2
Abstract: This research investigates the application of deep learning in sentiment analysis of Canadian
maritime case law. It offers a framework for improving maritime law and legal analytic policy-making
procedures. The automation of legal document extraction takes center stage, underscoring the vital
role sentiment analysis plays at the document level. Therefore, this study introduces a novel strategy
for sentiment analysis in Canadian maritime case law, combining sentiment case law approaches with
state-of-the-art deep learning techniques. The overarching goal is to systematically unearth hidden
biases within case law and investigate their impact on legal outcomes. Employing Convolutional
Neural Network (CNN)- and long short-term memory (LSTM)-based models, this research achieves
a remarkable accuracy of 98.05% for categorizing instances. In contrast, conventional machine
learning techniques such as support vector machine (SVM) yield an accuracy rate of 52.57%, naïve
Bayes at 57.44%, and logistic regression at 61.86%. The superior accuracy of the CNN and LSTM
model combination underscores its usefulness in legal sentiment analysis, offering promising future
applications in diverse fields like legal analytics and policy design. These findings mark a significant
choice for AI-powered legal tools, presenting more sophisticated and sentiment-aware options for
the legal profession.
Keywords: convolutional neural networks; deep neural networks; long short-term memory; sentimental
Citation: Abimbola, B.; de La Cal analysis; recurrent neural networks
Marin, E.; Tan, Q. Enhancing Legal
Sentiment Analysis: A Convolutional
Neural Network–Long Short-Term
Memory Document-Level Model.
1. Introduction
Mach. Learn. Knowl. Extr. 2024, 6,
877–897. https://doi.org/10.3390/
In today’s dynamic and interconnected world, the significance of information spans
make6020041
various critical domains, including legal, political, commercial, and individual perspectives,
and many more. Recognizing the pivotal role that opinions play in shaping decisions and
Academic Editor: Yoichi Hayashi
influencing outcomes, there is a growing need for automated tools to analyze sentiments
Received: 10 February 2024 effectively. Regarding this case, sentiment analysis emerges as a significant participant.
Revised: 6 April 2024 Sentiment mining, or sentiment analysis, is a comprehensive natural language processing
Accepted: 7 April 2024 approach that can identify and classify textual data’s emotional tone and subjective content.
Published: 19 April 2024 People are beginning to communicate their thoughts more quickly and in a shorter time,
making the manual processing of many viewpoints quite tricky. Therefore, sentiment
analysis has proven extremely useful in this field [1–3]. By employing the sentiment
analysis technique, stakeholders can also navigate the intricate layers of precedents and
Copyright: © 2024 by the authors. decisions, enhancing their capacity for nuanced interpretation and contributing to more
Licensee MDPI, Basel, Switzerland. informed decision making and policy formulation [2].
This article is an open access article
Recently, a significant amount of research has been conducted on opinion mining and
distributed under the terms and
sentiment analysis by applying machine learning and deep learning in various domains [4–6].
conditions of the Creative Commons
Opinion and sentiment analysis activities have been improved with the application of several
Attribution (CC BY) license (https://
neural networks, such as convolutional neural networks (CNNs), gated recurrent unit (GRU)
creativecommons.org/licenses/by/
or long short-term memory (LSTM), and recurrent neural networks (RNNs) [7]. Additionally,
4.0/).
machine learning and deep learning models excel in analyzing short texts, leveraging abun-
dant datasets from social networks to identify opinions quickly. However, tackling longer
documents presents a more intricate challenge, given the higher word count and complex
semantic links between sentences. Researchers are increasingly invested in developing ad-
vanced analysis techniques to extract nuanced points of view on specific subjects from this
substantial data mass. Navigating through the intricacies of longer documents, they aim to
enhance sentiment analysis accuracy and gain deeper insights into complex topics, reflecting
the evolving landscape of text analysis. From a legal perspective, there is a discernible trend
toward integrating cutting-edge technologies such as machine learning and sentiment analysis
to enhance the analytical capabilities of legal practitioners. Rhanoui, et al. [8] utilized the CNN-
BiLSTM model to analyze press articles and blog posts and reported almost 90.66% accuracy.
Similarly, Tripathy, et al. [9] employed a hybrid machine model to classify document-level
sentiment and claim positive feedback. Hence, this technological infusion holds particular
promise in Canadian maritime case law, where the complexities of legal texts and the need for
precise forecasting of court decisions pose significant challenges [10].
2. Research Significance
Thus, this study aimed to use a novel combination of deep learning techniques, namely
convolutional neural networks (CNNs) and long short-term memory (LSTM) networks,
to glean emotional insights from Canadian maritime case law papers. To the best of the
authors’ knowledge, there is a wealth of research on sentiment analysis using deep learning
but not much on the combined impact of CNN and LSTM techniques. This technique fills a
gap in the literature by providing a novel strategy for using sentiment analysis in the law,
and it does so by focusing on the application of deep learning to the study of Canadian
maritime case law [11]. Legal sentiment analysis has the potential to completely alter how
lawyers and judges examine massive collections of case law. The document’s emotional
tone, judgments, and sentiment dynamics are insightful for attorneys, judges, politicians,
and academics. This study introduces deep learning models for examining Canadian
maritime case law, which may pick up on subtleties of feeling that more conventional
approaches would otherwise miss. Explored were the potential effects of these cutting-edge
computational methods on legal analytics, policy formation, and the creation of AI-powered
legal instruments.
This paper begins with presenting case law, followed by an emotional evaluation of
the findings. An extensive literature review explores the topic of sentimental analysis and
its relevance to the legal profession. Then, the process involved gathering data to develop
an ML model and analyze experiment outcomes aligning with prior research [12].
Figure 1.
Figure 1. Sentiment
Sentimentpolarity
polaritycategorization using
categorization machine
using learning
machine (above)
learning andand
(above) deepdeep
learning (be-
learning
low) [15].
(below) [15].
The following
While grappling arewith
some of the sentiment
computational analysisand
complexity aspects that deepfor
the necessity learning models
fine-tuned hy-
can handle: adjustment, deep learning models are remarkably effective tools in sentiment
perparameter
analysis
Feature within legalWord-to-word
Extraction domains. As underscored in reference
associations, [16], these
the sentiments modelsby
conveyed extract subtle
individual
insights,
words, andoffering a valuable
the overall conduit
context are alltothings
elevate legal
deep analytics.
learning Theircan
models nuanced
deducecapabilities
automati-
empower
cally. a more profound comprehension of sentiment within legal analytics and furnish
aContext
robust foundation
Understanding for refining policy choices.
is a comprehensive capability to capture the contextual details
essential for gaining a sense of emotion in complicated fields such as maritime law.
3.2.1. CNN
Sequential Information Modeling can efficiently generate sequential information, like
RNNs Convolutional
and LSTM models,neural networks (CNNs) are
which is essential forrobust computational
tasks requiring frameworks
text order capable
and sentiment.
of decoding
This complex
is of utmost patternsinwithin
significance visual and textual
legal documents, where thedata, particularly
structure in sentiment
and flow of infor-
analysis. These
mation are critical. networks leverage spatial hierarchies to uncover subtle nuances in data,
making
The scalability and complexity of Canadian maritime case law are well within thetextual
them ideal choices for extracting important characteristics and patterns from capa-
data.
bilitiesCNNs apply
of deep filtersmodels.
learning or kernels to input
These datacan
models segments
handle through strategic
vast datasets and convolutional
be trained for
layers, precisely
specialized tasks.detecting sentiment-related words or phrases. This systematic feature
extraction enables CNNs to uncover complex legal language.
AWhile grappling
pooling layer inwith
thecomputational
convolutional complexity and the
layer efficiently necessity
reduces inputfordimensionality,
fine-tuned hy-
perparameter adjustment, deep learning models are remarkably
capturing essential textual characteristics for sentiment analysis. By pinpointing effective tools incritical
senti-
ment analysis withinwords,
sentiment-associated legal domains.
max pooling As underscored in reference
selectively extracts [16],
pertinent these models
information. CNNsex-
tract subtle insights, offering a valuable conduit to elevate legal analytics.
leverage this interplay to create sentiment parameters through iterative training on labeled Their nuanced
capabilities empower
text–sentiment data and a more
bridgeprofound
the gap comprehension
between predictions of sentiment within
and accurate legal analytics
sentiment labels.
and furnish a robust foundation for refining policy choices.
Pretrained word embedding like Word2Vec and GloVe are employed to capture semantic
relationships to aid in interpreting legal contexts. For the best results when analyzing legal
3.2.1. for
texts CNNsentiment, it is important to adjust hyperparameters such as CNN architecture,
Convolutional neuraland
kernel size, filter number, networks
others (CNNs)
to achieveareoptimum
robust computational
results [17]. frameworks capa-
ble of decoding complex patterns within visual and textual data, particularly in sentiment
analysis. These networks leverage spatial hierarchies to uncover subtle nuances in data,
making them ideal choices for extracting important characteristics and patterns from tex-
tual data. CNNs apply filters or kernels to input data segments through strategic convo-
lutional layers, precisely detecting sentiment-related words or phrases. This systematic
feature extraction enables CNNs to uncover complex legal language.
Mach. Learn. Knowl. Extr. 2024, 6 881
3.2.2. RNN-LSTM
Recurrent neural networks (RNNs) with long short-term memory (LSTM) units are
powerhouse tools for processing sequential data, shining in areas like language translation,
speech recognition, and sentiment analysis [18]. Their secret weapon is the ability to tackle
the vanishing gradient problem, a hiccup that often plagues traditional neural networks,
which makes them particularly adept at parsing complex sequences found in texts, such as
legal documents [19]. LSTMs excel at understanding the nuances of language thanks to
their design, which captures long-distance dependencies within text [20]. This capability
is amplified by bidirectional LSTMs, which look at text from both directions, ensuring a
robust context grasp for accurate sentiment detection. These networks delve deeply into
the specialized vocabulary required for jobs requiring extensive text analysis by utilizing
pretrained word embedding.
Training these networks involves meticulously adjusting their architecture, includ-
ing the layers and units specific to LSTMs, optimizing them for tasks that demand an
understanding of extended sequences, which makes RNN-LSTMs particularly valuable for
projects like sentiment analysis in Canadian maritime case law, offering insights into the
shifting tones within legal documents over time.
3.2.3. RNN-BiLSTM
Bidirectional long short-term memory (BiLSTM) networks significantly advance recur-
rent neural networks, particularly in processing natural language [18]. Unlike traditional
LSTMs, BiLSTM incorporates two hidden layers, enabling the simultaneous processing of
data in both the forward and backward directions. This BiLSTM approach enhances the
network’s ability to capture context and dependencies in sequential data. This architecture
has demonstrated notable effectiveness in various natural language processing tasks, show-
casing its prowess in sentiment analysis, named entity recognition, and machine translation.
The bidirectional nature of BiLSTM allows it to capture nuanced patterns and relationships
within language structures, making it a valuable tool in the ever-evolving landscape of
deep learning applications for natural language understanding.
A powerful tool in natural language processing (NLP), BiLSTM combines the advan-
tages of LSTM with bidirectional processing [19]. Placing words in sentences within their
historical and prospective contexts helps clarify their meanings. However, the BiLSTM
network has many potential uses, including machine translation, text categorization, and
named entity identification. Integrating it into advanced designs like BERT achieves bench-
mark performance on NLP that is second to none. On the other hand, longer sequences
provide challenges for it because of the amount of computational work involved. Archi-
tectures based on transformers, such as BERT and GPT, are preferred in natural language
processing owing to their parallelism and scalability [20].
4. Related Works
4.1. Short Text Sentiment Analysis
Understanding the emotions conveyed in 140-character posts like tweets, product
reviews, comments, and status updates is the goal of the specialized discipline of short text
sentiment analysis. Since more and more of our digital communication consists of concise
sentences, this area has attracted a lot of studies. While lengthier papers with more context
may be analyzed using standard sentiment analysis techniques, brief texts with condensed
and constrained characters introduce new obstacles. Extracting and analyzing feelings
from brief writings, particularly in social media and online reviews, are crucial since they
provide vital information about the author’s emotional tone and viewpoints.
Difficulties arise when analyzing the tone of short texts due to factors such as the
absence of context, the use of informal language, background noise and abbreviations, and
an unequal distribution of social classes. Since words and phrases in text messages may
have multiple meanings, which can change depending on the context in which they are
used, context is essential for deciphering emotions. Slang, conversational phrases, and
emoticons/emojis provide unique challenges to emotion analysis because of their informal
nature. Since noise and abbreviations might impact sentiment analysis findings, they are
not ideal for brief text conversations [11].
Sentiment analysis models may be biased if there is a significant racial or ethnic mi-
nority in the population. Emoticon and emoji analysis, deep learning models like recurrent
neural networks and convolutional neural networks, and transfer learning approaches
are just a few specialized methods researchers and data scientists have created for brief
text sentiment analysis. These methods can be utilized in various contexts, such as social
media monitoring, customer service, and legislation, to gauge public opinion, consumer
satisfaction, and new trends.
CNN-LSTMfor
Figure2.2.CNN-LSTM
Figure fordocument-level
document-levelsentiment
sentimentanalysis
analysis[15].
[15].
Convolution layer: Although some complexities like time and space complexity are
Convolution layer: Although some complexities like time and space complexity are
associated with the size of the input image (or feature maps), the number of convolutional
associated with the size of the input image (or feature maps), the number of convolutional
layers, and the size of the filters with image processing, CNNs can also be effectively
trained for text analysis. Additionally, CNNs are highly efficient for processing grid-like
data such as images (see Figure 3).
In this context, CNNs are crucial in localizing receptive model captures of particular
segments and global feelings, aided by max-pooling layers to preserve excessive feature
loss. This approach benefits Canadian marine case law, providing a more accessible under-
standing of rulings and accommodating diverse perspectives. “LeNet” and “AlexNet,” two
prominent CNNs, share linear neuron model principles. CNNs, unlike traditional MLPs,
incorporate weight sharing and restricted connection in convolutional layers. Conv1D
Mach. Learn. Knowl. Extr. 2024, 6, FOR PEER REVIEW 8
layers, and the size of the filters with image processing, CNNs can also be effectively
Mach. Learn. Knowl. Extr. 2024, 6 trained for text analysis. Additionally, CNNs are highly efficient for processing grid-like
884
data such as images (see Figure 3).
Inputimage
Figure3.3.Input
Figure image processing
processing [15].
[15].
The 1D forward propagation (1D-FP) expressions in each CNN layer are as follows:
In this context, CNNs are crucial in localizing receptive model captures of particular
segments and global feelings, aidedNby l −1 max-pooling layers to preserve excessive feature
k ∑ marine
l l l −1 l −1
x
loss. This approach benefits Canadian
k = b conv1D (case
wik si )providing a more accessible un-
,law,
i =1
derstanding of rulings and accommodating diverse perspectives. “LeNet” and “AlexNet,”
two prominent
xkl presentsCNNs, share
the input, linear
whereas neuron the
bkl denotes model
bias ofprinciples. CNNs,
the kth neuron unlike
in layer traditional
l. Similarly,
l −1 incorporate weight sharing and restricted connection
MLPs, l −1 in convolutional layers.
si illustrates the output of the ith neuron at layer l-1, and wik exhibits the kernel from
Conv1D
the ith neuron at layer l-1 to the kth neuron at layer l.
The 1D forward propagation (1D-FP) expressions in each CNN layer are as follows:
ylk = f ( x lk and slk = ylk ↓ ss
=∑
p 2
E p = MSE𝑦 t p= L
, y𝑓(𝑥 L
. , yand
l ,..) NL 𝑠 =
L
𝑦 (y↓i −
𝑠𝑠ti )
i =1
With l = 1 as the input and l as the output, the back-propagation procedure begins at
E p ’s derivative by each network parameter may be calculated using the delta error,
the
k l = E ×layer.
MLP k l. ToThere are
be more NL distinct
precise, types
the chain rule of data in themay
of derivatives repository.
be used toInupdate
the output
not justlayer,
we represent the mean squared error (MSE) between an input vector p and its
the bias of the current neuron but also the weights of all of the neurons in the layer above. target and
outputCNNs
vectors,with𝑡 several , 𝑦 use
and [𝑦layers ], asboth back-propagation and forward propagation (see
Figure 4).
Through forward and reverse propagation, the last hidden CNN layer is linked to the
𝐸 = 𝑀𝑆𝐸 𝑡 , 𝑦 , … , 𝑦 = (𝑦 − 𝑡 )
first hidden MLP layer (see Figure 5)
(1) Initialize weights and biases (e.g., randomly, ~U(−0.1, 0.1)) of the network.
(2) 𝐸 For
’s derivative by eachDO:
each BP iteration, network parameter may be calculated using the delta error, k
l = E × k l. To be more precise, the chain rule of derivatives may be used to update not
a. For each PCG beat in the dataset, DO:
just the bias of the current neuron but also the weights of all of the neurons in the layer
FP: A layer’s neuron outputs may be found by forward propagation from the input
above.
layer to the output layer.
CNNs with several layers use both back-propagation and forward propagation (see
Figure 4). si l , ∀i ∈ [1, Nl ], and ∀l ∈ [1, L].
Mach. Learn. Knowl. Extr. 2024, 6 885
BP: Compute delta error at the output layer and back-propagate it to first hidden layer
to compute the delta errors.
Mach. Learn. Knowl. Extr. 2024, 6, FOR PEER REVIEW 9
∆k l , ∀k ∈ [1, Nl ], and ∀l ∈ [1, L].
Mach. Learn. Knowl. Extr. 2024, 6, FOR PEER REVIEW 9
PP: Postprocess to compute the weight and bias. Update: Update the weights and
biases by the (accumulation of) sensitivities scaled with the learning factor.
Through forward and reverse propagation, the last hidden CNN layer is linked to
Figure 4. CNN
Figureback-propagation
4. hidden and forwardforward
CNN back-propagation propagation [15].
the first MLP layer (seeand
Figure 5) propagation [15].
Through forward and reverse propagation, the last hidden CNN layer is linked to
the first hidden MLP layer (see Figure 5)
Figure 5. CNN
Figurelayer linked
5. CNN tolinked
layer the first
to hidden
the first MLP layer
hidden MLP [15].
layer [15].
These gates control the flow of information into and out of the cell state (C_t).
a. Cell State (C_t) :
The cell state represents the memory of the LSTM. It can be updated and modified
using the gates.
The cell state is updated using the forget gate, input gate, and a new candidate cell
state (C ∼ _t).
b. Hidden State (h_t):
The hidden state carries information about the current time step’s input and the
previous hidden state.
It is used to make predictions and updated using the output gate.
Forget Gate ( f _t):
This equation combines the old and new candidate cells based on forgetting and input
gates.
f. Output Gate (o_t) :
Regularization: Combining deep learning methods, like CNN with LSTM models
for sentiment analysis in Canadian marine case law, heavily employs regularization tech-
niques to counteract overfitting. The complexity of legal language patterns makes accurate
representation critical. An issue is overfitting, which occurs when a model performs excep-
tionally well on training data but poorly on new data. Regularization plays a crucial role in
sentiment analysis to ensure that the model can handle the vast range of legal text patterns
and the intricacies of the training data
6. Experimental Results
6.1. Dataset
Legal documents in Canada are organized into several types, with maritime law
legislation being just one example. Many techniques are employed for data classification,
including text mining, document clustering, and machine learning algorithms. CNN is
one of the models that is often used in the document classification process. The main tools
were used to predict a judge or jury’s decisions and examine previous cases and decisions.
However, in some instances, machine learning algorithms can make it easier to consider
releasing a suspect on bail. This study examined two thousand cases from the Federal High
Court’s website to find patterns in Canadian maritime law (see Table 2). The final decision
rendered in the case was categorized as either affirmed or reversed. An affirmed judgment
indicates that the higher court upheld the lower court’s decision, while a reversed judgment
signifies that the decision was overturned. The datasets were divided into training and
test sets to evaluate the model’s performance on unseen data. Additionally, the data were
collected manually, without using anonymization, from both the plaintiffs and defendants.
To enhance sentiment analysis within maritime law, this research strategically used the
filter tool available on the Federal High Court website. This tool facilitated the identification
of pertinent legislation and precedents from court rulings. However, by analyzing the
most-used words and key phrases in the input text, outputs were generated that maintained
relevance to the legal context while ensuring coherence and accuracy. Additionally, con-
sidering the input text’s length and structure, the generated outputs were tailored to meet
the specific requirements of legal professionals, judges, and other stakeholders within the
Canadian maritime law domain. A meticulous augmentation process was undertaken to
bolster the sentiment analysis model, generating an additional 98,000 new samples through
a random sample technique. This method deliberately addressed demographic disparities,
ensuring a more even distribution of examples across emotion categories. The resultant
effect was a marked improvement in the model’s precision and consistency. Notably, the
model’s accuracy in categorizing emotions was fortified by incorporating Canadian marine
case law. After collecting data and training completion, the model’s prediction was evalu-
ated using a held-out test set. Specificity, representing the actual negative rate, is calculated
by dividing the number of correctly identified negative sentiments by the total number of
negative sentiments.
In contrast, sensitivity, representing the true positive rate, is calculated by dividing the
number of correctly identified positive sentiments by the total number of actual positive
sentiments. These metrics provide insights into how well the model could distinguish
between positive and negative sentiments. Data augmentation and postprocessing methods
were also used to balance representation across different groups and adjust the model’s
performance. This deliberate and rigorous approach to data augmentation contributed
significantly to the overall trustworthiness and precision of the sentiment analysis method-
ology employed in this study [28].
6.2. Results
This study on case adjudication in Canadian maritime law revealed intriguing insights
into the outcomes of trials based on the number of judges involved. When a case was
Mach. Learn. Knowl. Extr. 2024, 6 889
assigned to a single judge, guilty judgment stood at 46%, while the likelihood of a not guilty
result was approximately 51%. Strikingly, this indicated a remarkably even distribution
of judgments, with approximately 3% of cases remaining undecided. Surprisingly, the
incidence of indecisive verdicts did not significantly change when three judges were
involved, as it increased marginally to 5%. These findings suggest that additional judges in
the trial process did not substantially alter the proportion of undecided cases, highlighting
a noteworthy consistency in judgment outcomes across varying judicial scenarios in the
realm of Canadian maritime law. Surprisingly, the incidence of indecisive verdicts did not
significantly shift when there were three judges.
Accuracy is the rate at which a model makes accurate predictions.
Correct Predictions
Accuracy =
Total Predictions
In Canadian maritime law, a significant shift occurred in citation practices, revealing
41% of citations in single-judge trials and 46% in multijudge cases. This evolving trend
underscores the dynamic nature of the legal landscape. We employed advanced techniques
for sentiment analysis of Canadian marine case law papers, including deep learning and
traditional machine learning models. This analytical approach extends beyond statistics,
offering valuable insights for informed decision making in judge selection and jury ver-
dicts [29]. Integrating technology into legal scholarship reflects a proactive response to
contemporary challenges, enhancing the adaptability of legal practices.
Figure 6 is a comprehensive visual representation of a bar chart, elucidating the dis-
tribution of judgments and statuses throughout the dataset. Each bar’s height succinctly
encapsulates the number of instances within its corresponding category, offering a clear and
insightful overview of the dataset’s composition. This visualization lays a robust foundation
Mach. Learn. Knowl. Extr. 2024, 6, FOR PEER REVIEW 14
for forthcoming legal sentiment analysis studies and provides vital insights into the dataset’s
composition, knowing the predominance of judgments in Canadian marine case law [30].
Figure 6.6.Dynamics
Figure Dynamicsof of
case adjudication.
case adjudication.
Inthe
In theinitial
initialstages
stages of of model
model assessment
assessment (see Figure
(see Figure 7a,b),
7a,b), the the dataset
dataset was carefully
was carefully
split into
split intotraining
trainingand and testtest
sets, with
sets, nonpredictive
with nonpredictivecolumns removed
columns from thefrom
removed feature
the feature
matrix X.X.The
matrix Thetarget variable
target y wasy appropriately
variable labeled “target”
was appropriately labeled for the subsequent
“target” bi-
for the subsequent
nary classification
binary classificationtask.task.
To ensure repeatability,
To ensure 30 percent
repeatability, of the dataset
30 percent was reserved
of the dataset for
was reserved for
thorough examination. Preceding sentiment analysis, the ‘Opinion’ text
thorough examination. Preceding sentiment analysis, the ‘Opinion’ text input underwentinput underwent
tokenization to achieve consistent sequence lengths in the CNN with LSTM model. The
tokenization to achieve consistent sequence lengths in the CNN with LSTM model. The
largest sequence in the dataset (max_len) was found, and the vocabulary size, which in-
largest sequence in the dataset (max_len) was found, and the vocabulary size, which
cluded all unique words in the ‘Opinion’ text data, was computed. These preprocessing
included all unique words in the ‘Opinion’ text data, was computed. These preprocessing
steps were vital for the success of sentiment analysis performed on Canadian marine case
law materials that required this preliminary processing [30].
a
In the initial stages of model assessment (see Figure 7a,b), the dataset was carefully
split into training and test sets, with nonpredictive columns removed from the feature
matrix X. The target variable y was appropriately labeled “target” for the subsequent bi-
nary classification task. To ensure repeatability, 30 percent of the dataset was reserved for
thorough examination. Preceding sentiment analysis, the ‘Opinion’ text input underwent
Mach. Learn. Knowl. Extr. 2024, 6 890
tokenization to achieve consistent sequence lengths in the CNN with LSTM model. The
largest sequence in the dataset (max_len) was found, and the vocabulary size, which in-
cluded all unique words in the ‘Opinion’ text data, was computed. These preprocessing
steps were
stepsvital
were forvital
the success
for theofsuccess
sentiment analysis performed
of sentiment analysison Canadian on
performed marine case marine case
Canadian
law materials that required this preliminary processing [30].
law materials that required this preliminary processing [30].
6.3. Comparison
6.3. Comparison
Thiscompares
This section section compares
CNN, LSTM, CNN, LSTM,
BiLSTM, andBiLSTM,
CNN-LSTM andtoCNN-LSTM
the CNN-BiLSTM to the CNN-BiLSTM
model. model.
This
This study study examined
examined the sentiment
the sentiment analysis ofanalysis
Canadianofmaritime
Canadiancasemaritime
law usingcase law using two
two machine
machinelearning models:
learning deep learning
models: (CNN + LSTM)
deep learning (CNNand more traditional
+ LSTM) and moremeth- traditional methods
ods (logistic regression,
(logistic multinomial
regression, naïve naïve
multinomial Bayes,Bayes,
linear support vector machine).
linear support This
vector machine). This study’s
study’s success
successisiscredited
creditedwith
withemploying
employing CNNCNN and LSTM
and LSTMmodels to collect
models sentiment
to collect sentiment information
information
fromfrom judicial
judicial documents.Gamage,
documents. Gamage, etet al.
al.[31]
[31]used
useddifferent machine
different machinelearning
learning models for
models for maritime surveillance to detect abnormal maritime vessels and reported 91%
maritime surveillance to detect abnormal maritime vessels and reported 91% accuracy
accuracy for the CNN model. Syed and Ahmed [32] conducted research employing CNN,
LSTM, BiLSTM, and CNN-LSTM models on marine surveillance, distinguishing between
normal and abnormal vessel movement patterns and claimed CNN-LSTM exhibited the
most accurate result (89%).
Mach. Learn. Knowl. Extr. 2024, 6 891
for the CNN model. Syed and Ahmed [32] conducted research employing CNN, LSTM,
BiLSTM, and CNN-LSTM models on marine surveillance, distinguishing between normal
and abnormal vessel movement patterns and claimed CNN-LSTM exhibited the most
accurate result (89%).
CNN and LSTM Model 1 achieved an impressive 98.01% test accuracy rate (see
Figure 8a), showcasing its dominance in sentiment categorization and understanding of the
intricacies of Canadian maritime case law texts. On the other hand, Model 2 (see Figure 8b),
a descendant
Mach. Learn. Knowl. Extr. 2024, 6, FOR PEER REVIEWof Model 1, highlighted the robustness of the CNN + LSTM architecture17 with
a test accuracy of 97.94%, proving its efficacy in extracting sentiment information from
dense legal texts.
(a) model 1
(b) model 2
(c) model 3
Figure 8. Loss and accuracy graphs of CNN + LSTM (a) Model 1, (b) Model 2, and (c) Model 3.
Figure 8. Loss and accuracy graphs of CNN + LSTM (a) Model 1, (b) Model 2, and (c) Model 3.
Similarly, Model 3 (see Figure 8c) achieved a test accuracy rate of 98.05%, and the
third model earned a test accuracy rate of 98.05%, demonstrating the approach’s resilience
in predicting sentiment dynamics within Canadian maritime case law despite the contin-
uously high accuracy rates of CNN and LSTM models.
Mach. Learn. Knowl. Extr. 2024, 6 893
Figure 9.
Figure Model performance
9. Model performance comparison
comparison for
for all
all models
models used.
used.
Multinomial naïve
Multinomial naïve Bayes
Bayes is
is practical
practical with
with text
text data,
data, whereas
whereas logistic
logistic regression
regression sheds
sheds
light on the effect of model complexity. In linear SVM, the emphasis is on parameteriza-
light on the effect of model complexity. In linear SVM, the emphasis is on parameteriza-
tion and
tion and dataset
dataset dimensionality.
dimensionality. These
These additional
additional data
data will
will help
help us
us select
select more
more suitable
suitable
policymaking and legal analytics models. With this new information, we can better
policymaking and legal analytics models. With this new information, we can better choose choose
appropriate models
appropriate models for
for legal
legal analytics
analytics and
and policy
policy development
development [37].
[37].
number of true positive predictions divided by the total number of actual positives (true
positives + false negatives).
Including these metrics addresses a critical aspect of model evaluation, especially in legal
sentiment analysis, where the cost of misclassification can significantly impact the interpretation
of legal documents and the subsequent legal analytics and policymaking processes.
The following table (Table 4) summarizes the precision and recall metrics for our
CNN-LSTM model across the identified sentiment categories:
6.4. Discussion
The CNN-BiLSTM with Doc2vec, a pretrained sentence/paragraph representation
model, stood out when we compared its performance to that of other deep learning models.
Doc2Vec word embedding models’ accuracy ratings when using several neural net-
work topologies, including convolutional neural networks (CNNs), long short-term mem-
ory (LSTM) networks, back-propagation neural networks (CNN-LSTMs), and convolutional
neural networks (CNN-BiLSTMs), are offered. Document classification using Doc2Vec
receives = d 90% on CNN, 88% on LSTM, 86.40% on BiLSTM, 91% on CNN-LSTM, and
93% on CNN-BiLSTM. Higher accuracy levels imply superior performance in sentiment
analysis and text categorization [38].
This research explored the integration of deep learning, specifically convolutional neural
network (CNN) and long short-term memory (LSTM) models, for analyzing public opinion
on maritime law in Canada. With a precision rate of 98%, this research highlights the revolu-
tionary influence of artificial intelligence in the legal domain, stressing the mechanization of
processes, interpretation of lengthy legal documents, and enhanced judgment.
The findings highlight both the benefits and drawbacks of these technologies, offering
crucial insights for future applications. Significantly, sentiment analysis emerges as a valu-
able tool in various legal activities, including researching the law, investigating potential
outcomes, preparing for court, interpreting precedent, and developing policies [39]. This
research is a foundational step toward enhanced AI integration in legal practices, paving
the way for further exploration and refinement in maritime law and beyond.
7. Conclusions
This study used advanced deep learning methods, including convolutional neural net-
works (CNNs) and long short-term memory (LSTM) architectures, to unearth the nuanced
feelings behind Canadian maritime case law. These results shed light on the subtleties of
Canadian marine case law and the complex interplay between public opinion and judicial
Mach. Learn. Knowl. Extr. 2024, 6 895
decisions. With an average accuracy of 98.05% across several examples, the CNN and
LSTM models proved their ability to identify nuanced emotions in legal writing. This
research shows that convolutional neural networks (CNNs) and long short-term memory
(LSTMs) networks are helpful for sentiment analysis of maritime law in Canada [40].
The models showed impressive accuracy ratings, with some reaching 98%. Con-
volutional neural networks (CNNs) effectively recognized local textual patterns, while
long short-term memory (LSTM) models captured long-range relationships and sequential
information. These models could provide valuable information for lawyers, enhancing
investigations, evaluations, policymaking, legal analysis, and court strategy. AI-driven
tools can provide fresh insights into complex issues and improve legal procedures [41].
This research highlighted the significance of parameter tuning and dataset dimensionality
by comparing deep learning outcomes with traditional machine learning models. It was
found that logistic regression achieved the highest accuracy (61.86%), multinomial naïve
Bayes showed 56.44% efficiency, and linear support vector machine depicted 52.5% efficiency.
This research explored deep learning methods. Its primary focus was on analyzing
sentiment in maritime case law in Canada, and it also applied deep learning techniques
to legal analytics and policy creation. This research highlights the importance of AI in
legal practice and policy development and compared various machine learning models.
The outcomes suggest that AI can produce a more complex and well-informed legal
environment, demonstrating its potential in legal practice [42].
Author Contributions: Conceptualization, B.A. and Q.T.; methodology, B.A.; validation, B.A., Q.T.
and E.d.L.C.M.; formal analysis, B.A.; investigation, B.A; resources, B.A. and Q.T.; writing—original
draft preparation, B.A.; writing—review and editing, B.A., Q.T. and E.d.L.C.M.; visualization, B.A.;
supervision, Q.T. and E.d.L.C.M.; project administration, B.A. All authors have read and agreed to
the published version of the manuscript.
Funding: This research received no external funding.
Data Availability Statement: Data available at https://doi.org/10.17632/s3r4thpy95.1 (accessed on
9 February 2024).
Acknowledgments: The authors thank Jose Villar for fruitful discussions and the anonymous review-
ers for their feedback. B.A. would like to thank Kola Abimbola and Qing Tan for their inspiration.
Conflicts of Interest: The authors declare no conflicts of interest.
List of Notations
C_t Cell state
h_t Hidden state
f _t Forget gate
σ Sigmoid activation function
i_t Input gate
C ∼ _t Candidate cell state
o_t Output gate
x_t Input at time step t
h_t − 1 Hidden state at time step t − 1
W_ f , W_i, W_c, W_o Weight matrices
b_ f , b_i, b_c, b_o Bias vectors
tanh Hyperbolic tangent activation function
xkl Input data
blk Bias of the kth neuron at layer l
sil −1 Output of the ith neuron at layer l-1
l −1
wik Kernel from the ith neuron at layer l-1 to the kth neuron at layer l
p Input vector
tp Target
ylk , yNL L Output vector
Mach. Learn. Knowl. Extr. 2024, 6 896
References
1. Liu, B. Sentiment Analysis And Opinion Mining; Springer Nature: Berlin/Heidelberg, Germany, 2022.
2. Nasukawa, T.; Yi, J. Sentiment analysis: Capturing favorability using natural language processing. In Proceedings of the 2nd
International Conference on Knowledge Capture, Sanibel Island, FL, USA, 23–25 October 2003; pp. 70–77.
3. Bai, X. Predicting consumer sentiments from online text. Decis. Support. Syst. 2011, 50, 732–742. [CrossRef]
4. Naseem, U.; Razzak, I.; Musial, K.; Imran, M. Transformer based Deep Intelligent Contextual Embedding for Twitter sentiment
analysis. Future Gener. Comput. Syst. 2020, 113, 58–69. [CrossRef]
5. Yusof, N.N.; Mohamed, A.; Abdul-Rahman, S. Context Enrichment Model Based Framework for Sentiment Analysis. In
Proceedings of the Soft Computing in Data Science: 5th International Conference, SCDS 2019, Iizuka, Japan, 28–29 August 2019;
Proceedings 5. Springer: Berlin/Heidelberg, Germany, 2019; pp. 325–335.
6. Vijayaragavan, P.; Ponnusamy, R.; Aramudhan, M. An optimal support vector machine based classification model for sentimental
analysis of online product reviews. Future Gener. Comput. Syst. 2020, 111, 234–240. [CrossRef]
7. Mikolov, T.; Karafiát, M.; Burget, L.; Cernocký, J.; Khudanpur, S. Recurrent neural network based language model. Interspeech
2010, 2, 1045–1048.
8. Rhanoui, M.; Mikram, M.; Yousfi, S.; Barzali, S. A CNN-BiLSTM model for document-level sentiment analysis. Mach. Learn.
Knowl. Extr. 2019, 1, 832–847. [CrossRef]
9. Tripathy, A.; Anand, A.; Rath, S.K. Document-level sentiment classification using hybrid machine learning approach. Knowl. Inf.
Syst. 2017, 53, 805–831. [CrossRef]
10. Newmyer, K.; Zaccagnino, M. Connecticut Law Review Volume 52, February 2021, Number 4, 2021. Available online:
https://heinonline.org/ (accessed on 8 February 2024).
11. Christodoulou, A.; Echebarria Fernández, J. Maritime Governance and International Maritime Organization instruments focused
on sustainability in the light of United Nations’ sustainable development goals. In Sustainability in the Maritime Domain: Towards
Ocean Governance and Beyond; Springer: Berlin/Heidelberg, Germany, 2021; pp. 415–461.
12. Gavrilov, V.; Dremliuga, R.; Nurimbetov, R. Article 234 of the 1982 United Nations Convention on the law of the sea and reduction
of ice cover in the Arctic Ocean. Mar. Policy 2019, 106, 103518. [CrossRef]
13. Undavia, S.; Meyers, A.; Ortega, J.E. A comparative study of classifying legal documents with neural networks. In Proceedings of
the 2018 Federated Conference on Computer Science and Information Systems (FedCSIS), Poznan, Poland, 9–12 September 2018;
pp. 515–522.
14. Abimbola, B.; Tan, Q.; Villar, J.R. Introducing Intelligence to the Semantic Analysis of Canadian Maritime Case Law: Case Based
Reasoning Approach. In Proceedings of the International Workshop on Soft Computing Models in Industrial and Environmental
Applications, Salamanca, Spain, 5–7 September 2022; Springer: Berlin/Heidelberg, Germany, 2022; pp. 587–595.
15. Abimbola, B.; Marin, E.D.L.C.; Tan, Q. Enhancing Legal Sentiment Analysis: A CNN-LSTM Document-Level Model. Preprints
2024. [CrossRef]
16. Ghorbani, M.; Bahaghighat, M.; Xin, Q.; Özen, F. ConvLSTMConv network: A deep learning approach for sentiment analysis in
cloud computing. J. Cloud Comput. 2020, 9, 1–12. [CrossRef]
17. Jin, Z.; Yang, Y.; Liu, Y. Stock closing price prediction based on sentiment analysis and LSTM. Neural Comput. Appl. 2020, 32,
9713–9729. [CrossRef]
18. Schuster, M.; Paliwal, K.K. Bidirectional recurrent neural networks. IEEE Trans. Signal Process. 1997, 45, 2673–2681. [CrossRef]
19. Tai, K.S.; Socher, R.; Manning, C.D. Improved semantic representations from tree-structured long short-term memory networks.
arXiv 2015, arXiv:1503.00075.
20. Sadia, A.; Khan, F.; Bashir, F. An overview of lexicon-based approach for sentiment analysis. In Proceedings of the 2018 3rd
International Electrical Engineering Conference (IEEC 2018), Karachi, Pakistan, 9–10 February 2018; pp. 1–6.
21. Godbole, N.; Srinivasaiah, M.; Skiena, S. Large-Scale Sentiment Analysis for News and Blogs. Icwsm 2007, 7, 219–222.
22. Baccianella, S.; Esuli, A.; Sebastiani, F. Sentiwordnet 3.0: An enhanced lexical resource for sentiment analysis and opinion mining.
In Proceedings of the Lrec, Valletta, Malta, 17–23 May 2010; pp. 2200–2204.
23. Denecke, K. Are SentiWordNet scores suited for multi-domain sentiment classification? In Proceedings of the 2009 Fourth
International Conference on Digital Information Management, Ann Arbor, MI, USA, 1–4 November 2009; pp. 1–6.
24. Yeskuatov, E.; Chua, S.-L.; Foo, L.K. Leveraging reddit for suicidal ideation detection: A review of machine learning and natural
language processing techniques. Int. J. Environ. Res. Public Health 2022, 19, 10347. [CrossRef] [PubMed]
25. Tahseen, T.; Kabir, M.M.J. A comparative study of deep learning neural networks in sentiment classification from texts. In Machine
Learning and Autonomous Systems: Proceedings of ICMLAS 2021; Springer: Berlin/Heidelberg, Germany, 2022; pp. 289–305.
26. Sahoo, C.; Wankhade, M.; Singh, B.K. Sentiment analysis using deep learning techniques: A comprehensive review. Int. J.
Multimed. Inf. Retr. 2023, 12, 41. [CrossRef]
27. Alghazzawi, D.; Bamasag, O.; Albeshri, A.; Sana, I.; Ullah, H.; Asghar, M.Z. Efficient prediction of court judgments using an
LSTM+ CNN neural network model with an optimal feature set. Mathematics 2022, 10, 683. [CrossRef]
28. Bramantoro, A.; Virdyna, I. Classification of divorce causes during the COVID-19 pandemic using convolutional neural networks.
PeerJ Comput. Sci. 2022, 8, e998. [CrossRef] [PubMed]
29. Watson, J.; Aglionby, G.; March, S. Using machine learning to create a repository of judgments concerning a new practice area: A
case study in animal protection law. Artif. Intell. Law 2023, 31, 293–324. [CrossRef]
Mach. Learn. Knowl. Extr. 2024, 6 897
30. Da Silva, N.C.; Braz, F.; De Campos, T.; Gusmao, D.; Chaves, F.; Mendes, D.; Bezerra, D.; Ziegler, G.; Horinouchi, L.; Ferreira,
M. Document type classification for Brazil’s supreme court using a convolutional neural network. In Proceedings of the 10th
International Conference on Forensic Computer Science and Cyber Law (ICoFCS), Sao Paulo, Brazil, 29–30 October 2018;
pp. 29–30.
31. Gamage, C.; Dinalankara, R.; Samarabandu, J.; Subasinghe, A. A comprehensive survey on the applications of machine learning
techniques on maritime surveillance to detect abnormal maritime vessel behaviors. WMU J. Marit. Aff. 2023, 22, 447–477.
[CrossRef]
32. Syed, M.A.B.; Ahmed, I. A CNN-LSTM architecture for marine vessel track association using automatic identification system
(AIS) data. Sensors 2023, 23, 6400. [CrossRef] [PubMed]
33. Pillai, V.G.; Chandran, L.R. Verdict prediction for indian courts using bag of words and convolutional neural network. In
Proceedings of the 2020 Third International Conference on Smart Systems and Inventive Technology (ICSSIT), Tirunelveli, India,
20–22 August 2020; pp. 676–683.
34. Chen, D.L.; Eagel, J. Can machine learning help predict the outcome of asylum adjudications? In Proceedings of the 16th Edition
of the International Conference on Articial Intelligence and Law, London, UK, 12–16 June 2017; pp. 237–240.
35. Lum, K. Limitations of mitigating judicial bias with machine learning. Nat. Hum. Behav. 2017, 1, 0141. [CrossRef]
36. Feizollah, A.; Ainin, S.; Anuar, N.B.; Abdullah, N.A.B.; Hazim, M. Halal products on Twitter: Data extraction and sentiment
analysis using stack of deep learning algorithms. IEEE Access 2019, 7, 83354–83362. [CrossRef]
37. Tasdelen, A.; Sen, B. A hybrid CNN-LSTM model for pre-miRNA classification. Sci. Rep. 2021, 11, 14125. [CrossRef]
38. Muhlenbach, F.; Phuoc, L.N.; Sayn, I. Predicting Court Decisions for Alimony: Avoiding Extra-legal Factors in Decision made by
Judges and Not Understandable AI Models. arXiv 2020, arXiv:2007.04824.
39. Alsayat, A. Improving sentiment analysis for social media applications using an ensemble deep learning language model. Arab. J.
Sci. Eng. 2022, 47, 2499–2511. [CrossRef] [PubMed]
40. Lam, J.T.; Liang, D.; Dahan, S.; Zulkernine, F.H. The Gap between Deep Learning and Law: Predicting Employment Notice. In
Proceedings of the NLLP@ KDD, San Diego, CA, USA, 24 August 2020; pp. 52–56.
41. Abimbola, B. Sentiment Analysis of Canadian Maritime Case Law: A Sentiment Case Law and Deep Learning Approach, Version 1;
Mendeley Data: Amsterdam, The Netherlands, 2023. [CrossRef]
42. Alzahrani, M.E.; Aldhyani, T.H.; Alsubari, S.N.; Althobaiti, M.M.; Fahad, A. Developing an intelligent system with deep learning
algorithms for sentiment analysis of E-commerce product reviews. Comput. Intell. Neurosci. 2022, 2022, 3840071. [CrossRef]
[PubMed]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual
author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to
people or property resulting from any ideas, methods, instructions or products referred to in the content.