Associative modeling of Chinese character stroke sequences combining transformer and geometric constraints
摘要
This research introduces a combined deep learning framework for classifying Chinese stroke sequences using multi-scale spatial encoding, hierarchical attention modeling, and geometric constraint learning. Unlike previous Swin Transformer-based stroke classification models, this study presents a novel hybrid framework that combines U-Net’s multi-scale spatial encoding with Swin Transformer’s hierarchical attention, explicitly capturing both local and global dependencies in handwritten stroke sequences. Each stroke sample is encoded into a 2D trajectory-density feature map, rather than raw coordinate sequences, to retain spatial continuity, temporal progression, and fine-grained geometric structure. This approach ensures the joint learning of spatial–temporal patterns while preserving stroke continuity and geometric fidelity, providing a clearer representation for the model to classify stroke sequences accurately. The U-Net framework enables the extraction of multi-resolution spatial features, while the Swin Transformer captures long-range contextual dependencies with shifted-window self-attention. A geometric constraint loss term is included to capture curvature smoothness, directionality consistency, and structural fidelity, addressing the challenges of visual similarity and significant variability of handwritten strokes. Experiments conducted with four main stroke classes—heng, shu, pie, and na—demonstrated strong classification performance with 98.57% accuracy, an average precision of over 0.994, and an AUC of over 0.995. Experiments conducted with the Handwritten Chinese Stroke 2021 dataset demonstrated strong classification performance with 98.57% accuracy, surpassing state-of-the-art methods such as Swin Transformer-based stroke classification models and CNN-based models for Chinese character recognition. Evaluations with the confusion matrix, ROC curves, precision–recall curves, and error rate (FPR/FNR) metrics each establish the robustness and generalizability of the model across different handwriting styles. These findings indicate that the framework effectively captures stroke-level spatial–temporal patterns and provides a robust basis for downstream applications, including character reconstruction, handwriting analysis, digital calligraphy, and intelligent writing-education systems.