Was reading kanbun a parser running in my head? Return marks through the lens of NLP and compilers
Here is what this post covers:
- Introduction
- The short answer
- Mapping to NLP and CS terms
- What happens in your head
- Research treats it as a reordering problem too
- Unmarked-text exam questions are parser drills
- My take on abolishing it
- Wrapping up
- References
Introduction
Kanbun is classical Chinese text read as Japanese. Japanese students learn it in high school, together with kobun (classical Japanese). “Classical Japanese and kanbun are useless, so drop them and teach programming and math instead” is an argument that has come up again and again in Japan since the Meiji era.
In my previous post, What did I get, as a software engineer, out of choosing a general high school?, I listed kanbun as one of the subjects that turned out useful. Reading it means reordering the words, and that feels similar to tracing string processing in my head. But I also wrote that this was just my own impression and might be bias.
Honestly, kanbun has rarely helped me directly at work. Still, as an engineer, reading kanbun looks a lot like syntactic parsing. In this post I try to unpack that impression using NLP and compiler terms.
The short answer
Reading kanbun (kundoku) can be seen as a syntactic operation that converts an SVO string into SOV Japanese word order by fixed rules.
Kanbun has SVO word order, like English, while Japanese is SOV. It helps to think of the return marks (kaeriten) and the okurigana, the kana added to show inflections and particles, as a notation system that lets a human carry out that conversion.
Mapping to NLP and CS terms
| Reading kanbun | Corresponding NLP / CS concept |
|---|---|
| Reading the unmarked text from the start | Scanning a token sequence (like lexical analysis) |
| Finding the subject, predicate, and object | Part-of-speech tagging, dependency parsing |
| Adding return marks | Reordering words (SVO → SOV) |
| “Going back” with re-ten or ichi-ni marks | Pushing to and popping from a stack |
| Adding okurigana and particles | A generation phase that fills in inflections and function words |
What happens in your head
There are two basic rules for reading kanbun with return marks. Read from the top, and when a character has a return mark, skip it for now and come back to it when a mark tells you to.
Let’s look at a concrete example. 我欲レ読レ書 is read in Japanese as 我書を読まんと欲す, which means “I want to read books.” The characters are 我 (I), 欲 (want), 読 (read), and 書 (books), in the same order as the English sentence. Japanese needs the order “books, read, want,” and the re-ten marks (レ) are what tell the reader to reorder.
欲 and 読 carry re-ten marks, so they are read later. Once you reach 書, you go back to 読 just before it, and then back again to 欲.
Remembering the skipped characters and later going back to them, newest first, is exactly what a stack does in programming. A stack is a container where the last thing you put in is the first thing you take out, like a pile of books you take from the top. Processing the same sentence with a stack looks like this.
In step 3, 読 is pushed on top of 欲, and in steps 5 and 6, 読 comes off first because it is on top. The reading rule “go back to the most recently skipped character first” is precisely how a stack behaves.
Written as code, the flow looks like this. It is pseudocode meant only to show the idea: has_return_mark() means “does this character carry a return mark?” and can_resolve() means “has the signal to go back arrived?”
def kundoku(tokens):
stack = []
output = []
for tok in tokens:
if tok.has_return_mark(): # has a return mark -> hold it
stack.append(tok)
else:
output.append(tok)
while stack and stack[-1].can_resolve(output):
output.append(stack.pop()) # pop it back in at the return point
return add_okurigana(output) # generate a Japanese sentence with okurigana
Real return marks nest, with ichi-ni marks, jō-ge marks and so on, so the actual process is more complicated.
My own view is that what goes on in your head has four steps.
- Telling characters from marks (is it a kanji or a control mark?)
- Holding skipped characters in working memory (push)
- Taking them back out at the return point and merging them into SOV order (pop)
- Interpreting the meaning
In the previous post I called it “tracing,” but to be more precise, you are running a parser and a transpiler in your own head.
Research treats it as a reordering problem too
This view is not just my own idea. One study formulated adding return marks to unmarked text as a rank-based sorting problem solved with a BERT-style model (Association for Natural Language Processing, 2023).
Another attempt adds brackets to return marks to give the syntax a structure, extending the notation from “reading order” to “syntactic structure.” In effect, that is building a parse tree. There is also research on parsing kanbun with Lisp and generating return-mark information.
Unmarked-text exam questions are parser drills
The exercise of adding return marks yourself to unmarked text (hakubun) goes like this.
- Look for kanji and set phrases that act as landmarks
- Work out where the subject, predicate, and object are
- Decide the reading order
What you are doing here is analyzing the structure of a given string in your own head. Hakubun questions are practice in running a parser by hand.
My take on abolishing it
I agree that it has too high a status as a required subject. On the other hand, if “you never use it in real life, so it’s pointless” is the only test, the same logic would cut subjects we want to keep, such as calculus.
Realistically, I think the middle ground is not abolition but making it an elective instead of a requirement, and expanding computer science classes.
Wrapping up
Seen as head training for syntactic parsing, kanbun has value in the age of AI as groundwork for paying attention to the structure of language. In the previous post I wrote that now that AI writes code, the ability to decide things in words and the ability to judge what comes out have both become more important. I think the kanbun habit of following sentence structure mechanically connects, a little, to both.
Rather than a yes-or-no question of “useful or not,” I think the education debate needs people to put into words what a subject actually trains.