Preform and automatic verb inflection in Inform 7

I’m currently developing a Japanese translation of Inform as a proof of concept / personal project, and I’d like to implement verb inflection like Inform already has for English. Basically, if possible, I would like to be able to concisely define verbs, and have Inform silently generate the “to say [verb]” phrase and everything that entails.

However, my understanding is that this functionality resides in the Syntax.preform file, which is currently incomprehensible to me. I browsed around a bit on this forum and found some helpful replies from @Natrium729 on the matter, but unfortunately am no closer to understanding where to start.

If someone could point me in the right direction, it would be greatly appreciated.


In fact, you can’t use the Syntax.preform file yet. You have to include bits of Preform in the extension directly, like this:

Include (-
language Japanese

[Your Preform here.]

-) in the Preform grammar.

Your best bet it to look at another translation (French, Spanish or Italian) and “port” them to Japanese. This document also describes how Preform works and what all its sections do. (But not all the Preform described in it works when directly included in an extension. It’s best to only use the parts that are used in the linked extensions.)

An other important thing you have to know is that the adaptive verbs do not work in the latest version of Inform (6M62) because of a bug and only work in 6L38. The Spanish and Italian extensions have removed this functionnality so that they work on 6M62, but I prefered to stay in 6L38 for French.

If you decide that you want your translation to work with 6M62, you’ll have to manually write standard text substitutions for each verb used by the responses and at every tense and viewpoint.

Something else : using Preform for verbs with Japanese may not work at all because I don’t think Inform supports Unicode in the source (only in the texts), so you won’t be able to write Japanese characters in text substitutions. It may therefore be better to go with manually writing substitutions for the verbs.

(There may be more issues in some other Inform 7 features regarding Unicode, especially in the Inform 6 inclusions, but workaround should exist.)

It’s quite a lot if information, I agree, especially since it’s a part of Inform that’s not that documented. Don’t hesitate to ask more question, I’ll gladly help. I’m always happy when someone tries to translate Inform in another language!

1 Like

Yeah, unfortunately current Inform really doesn’t like non-Latin writing systems. But, there are workarounds! For example, you can write all your source code in roumaji (so everything’s in an alphabet Inform can cope with), then apply a transform on the input and output that’ll convert to kana.

Once that’s working, you can potentially include kanji too, by making the I/O transform a bit more complex (perhaps sequences in angle brackets look up the kanji in a table, so yama gives やま but <yama> gives 山).

On the downside, this means writing the transformation, which will be annoying. On the upside, you can use all of Inform/Preform’s text features without worrying about kana, and it’ll be rewritten for you automatically (so you don’t have to reinvent the wheel for tenses etc).

Wow, that is super helpful and pretty much exactly what I was looking for. Thanks so much!

As for Unicode, my priority was getting it working essentially as a proof of concept and not something that other people would necessarily use. Accordingly, I had planned to use romaji for input and in the source text itself, while using printed names and text substitutions so that the story printed exclusively in kana/kanji. I had done a fair amount of work under this assumption, and it worked quite well. Up until now, the biggest challenge I could foresee with this system was parsing irregular readings of numbers and other concepts that Inform directly understands, since any object the author creates can just be named appropriately.

With that in mind, is there any support, at all, for Unicode in Preform? I don’t care if I have to translate things into hex codes or something, since I don’t expect to have to write TOO much Unicode - Japanese verbs actually inflect quite regularly with very few exceptions. Here is an example of some work that I did in I7, to give you an idea of what would be happening:

To decide which text is the past participle of (V - a verb):
	if there is a verb of V in the Table of Verb Kanji:
		let k be the kanji corresponding to a verb of V in the Table of Verb Kanji;
		let n be the number of characters in k;
		if the ichidan corresponding to a verb of V in the Table of Verb Kanji is true: [i.e. if it is an ichidan verb]
			replace character number n in k with "た";
		otherwise: [godan verb]
			if character number n in k exactly matches the text "う|つ|る":
				replace character number n in k with "った";
			otherwise if character number n in k exactly matches the text "ぶ|む|ぬ":
				replace character number n in k with "んだ";
			otherwise if character number n in k exactly matches the text "す":
				replace character number n in k with "した";
			otherwise if character number n in k exactly matches the text "く":
				replace character number n in k with "いた";
			otherwise if character number n in k exactly matches the text "ぐ":
				replace character number n in k with "いだ";
		decide on k.

Table of Verb Kanji
verb	kanji	ichidan
the verb miru	"見る"	true
the verb matsu	"待つ"	false

I don’t know if Preform supports Unicode, but the problem would be that the Inform text substitutions generated by Preform would contain non-latin characters, and Inform 7 wouldn’t like it.

A thought on your phrase: I maybe wouldn’t use text replacement if possible because if I’m not mistaken, text manipulation is quite slow in Inform (but if used sparingly, it should not be noticeable). Someone knowing better the inner working of Inform can confirm or infirm.

@Natrium729, is there an updated link for the documentation for Preform?

Ah yes, sorry, after BitBucket decided not to support Mercurial anymore, we migrated to GitLab. Here’s the link to the repo. I recommend downloading the whole repo and opening the PDF from your computer instead of clicking on the PDF in GitLab’s UI, because it that case the whole PDF will show in the webpage, slowing down the browser.

However, I do think there should be a better home to this document than the French extension repository. At the time 6L02 was released, this document was supposed to be “confidential” and only available for translators, but we still put it in the repo for convenience. So normally we ought to remove it, but I don’t know if the document is available somewhere else.

And since we haven’t got news from Graham Nelson regarding the translation of Inform, I don’t really know what’s the current situation.