Skip to content
Publications

Article · Вестник КазАТК · August 31, 2026

A COMPUTATIONAL FRAMEWORK FOR COMPARATIVE AND HISTORICAL ANALYSIS OF THE LEGAL CODES OF THE REPUBLIC OF KAZAKHSTAN

Mukhsimbayev Bobur, Alexandr Pak, Kuralbayev Aibek

Abstract

Analysing a country's body of law by computer is harder than it first looks. The texts sit in a deep hierarchy, point at each other constantly, change often, and come with few tools tuned to the local language. This paper puts together an open pipeline of NLP and machine-learning parts and runs it on the five main codes of Kazakhstan: the Criminal Code, the Code of Administrative Offenses, the Civil Code, the Labor Code, and the Tax Code. In its current-version form the corpus holds 3,062 articles and 631,280 tokens. A second, historical corpus of 563 versions from 1996 to 2025 lets us watch the law change over time. The pipeline cleans text with spaCy, builds TF-IDF features, and trains four supervised classifiers. It also fits LDA topic models, counts bigrams, embeds every article with a multilingual sentence model (E5-base, 768 dimensions), projects those vectors with UMAP, and groups them with HDBSCAN. A grammar-aware parser reads penalty values out of the text, even when the numbers are written as Russian words, and a version-by-version diff tags what happened to each article. A linear SVM over TF-IDF separates the five codes with 98.48 % accuracy; a Random Forest reaches 94.92 % on the three-way penalty-type task. HDBSCAN finds 12 coherent clusters at 91.5 % average purity, and parallel provisions in the Criminal and Administrative codes come out as close as 0.99 by cosine similarity. The citation graph has 6,436 edges, and 92.0 % of them stay inside a single code, so whatever ties the codes together is not written into the text itself. Penalty parsing returns 4,524 records from the current codes and 685 transitions from the historical ones, and the two pull in opposite directions: prison terms and corporate fines grow harsher while penalties aimed at ordinary citizens’ ease. Of the 8,225 edits we looked at, 86 % are cosmetic or minor. The code, the notebooks, and the intermediate files are all public, and the same pipeline should carry over to other hierarchical corpora that use structured citations.

Artificial Intelligence in LawComputational and Text Analysis MethodsTopic Modelingcriminal codecivil codelabour code

More by Bobur Mukhsimbayev