昔の訳 (むかしのわけ、ではない)

なんだかすっかり忘れ去られていたが、実はSqueak 3.8以前、というかBabel以前には別種の翻訳機構があって、スワヒリ語とかノルウェー語とかスウェーデン語とかが入っていた。
それらをは200語句くらいの訳しかなく、4000語句とかを必要とする今のシステムではそのままは使えないのだが、いちおう取っ掛かりでもあると継続してくれる人が出るかもしれないので、LanguageEditorにロードできるファイルを作成。

Workspaceプログラミングだけど、こんな感じです。add...のメソッドをfileOutしておいて、中を配列の配列にEmacsで書き換えておき、以下を実行します。

f _ FileStream readOnlyFileNamed:  'C:\squeak\Squeak3.6\EToyVocabulary-templateForLanguageTranslation.st'.
f converter: UTF8TextConverter new.

template _ Compiler evaluate: f contentsOfEntireFile.
f close.

f _ FileStream readOnlyFileNamed:  'C:\squeak\Squeak3.6\EToyVocabulary-addSwedishVocabulary.st'.
f converter: UTF8TextConverter new.

swedish _ Compiler evaluate: f contentsOfEntireFile.
f close.

templateDict _ Dictionary new.
templateHelpDict _ Dictionary new.
template do: [:list |
	list do: [:triplet |
		templateDict at: triplet first put: triplet second.
		templateHelpDict at: triplet first put: triplet third.
]].

results _ Dictionary new.
kiswahili do: [:list |
	list do: [:triplet |
		results at: (templateDict at: triplet first) asString put: (triplet second) asString.
		results at: (templateHelpDict at: triplet first) asString put: (triplet third) asString.
	].
].

n _ NaturalLanguageTranslator isoLanguage: 'sv'.
results associationsDo: [:pair | n phrase: pair key translation: pair value].
n saveToFileNamed: 'sv.translation'.