<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.apertium.org/w/index.php?action=history&amp;feed=atom&amp;title=Adding_orthography_conversion_to_a_language_module</id>
	<title>Adding orthography conversion to a language module - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.apertium.org/w/index.php?action=history&amp;feed=atom&amp;title=Adding_orthography_conversion_to_a_language_module"/>
	<link rel="alternate" type="text/html" href="https://wiki.apertium.org/w/index.php?title=Adding_orthography_conversion_to_a_language_module&amp;action=history"/>
	<updated>2026-04-16T02:37:33Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>https://wiki.apertium.org/w/index.php?title=Adding_orthography_conversion_to_a_language_module&amp;diff=74153&amp;oldid=prev</id>
		<title>Firespeaker: Created page with &quot;  == One approach ==  This accomplishes the following goal: * Analysis of two orthographies (by default) * Generation in orthography of choice (defaults to transducer orthogra...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.apertium.org/w/index.php?title=Adding_orthography_conversion_to_a_language_module&amp;diff=74153&amp;oldid=prev"/>
		<updated>2023-01-12T15:40:36Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;  == One approach ==  This accomplishes the following goal: * Analysis of two orthographies (by default) * Generation in orthography of choice (defaults to transducer orthogra...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
== One approach ==&lt;br /&gt;
&lt;br /&gt;
This accomplishes the following goal:&lt;br /&gt;
* Analysis of two orthographies (by default)&lt;br /&gt;
* Generation in orthography of choice (defaults to transducer orthography)&lt;br /&gt;
* Conversion from orthography 1 to orthography 2&lt;br /&gt;
&lt;br /&gt;
What&amp;#039;s missing/broken:&lt;br /&gt;
* Explicit conversion of orthography 2 to orthography 1&lt;br /&gt;
** Will work in some simple cases.  Other cases will need explicit orthography conversion &amp;lt;code&amp;gt;lexd&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;twol&amp;lt;/code&amp;gt; from orthography 2 to orthography 1&lt;br /&gt;
* Orthography-specific spellrelax&lt;br /&gt;
** See [https://github.com/apertium/apertium-krc/blob/master/Makefile.am apertium-krc&amp;#039;s Makefile] for an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
=== A diff ===&lt;br /&gt;
&lt;br /&gt;
* Replace &amp;lt;code&amp;gt;abc&amp;lt;/code&amp;gt; with language code&lt;br /&gt;
* Replace &amp;lt;code&amp;gt;ORTH1&amp;lt;/code&amp;gt; with abbreviation for orthography 1&lt;br /&gt;
* Replace &amp;lt;code&amp;gt;ORTH2&amp;lt;/code&amp;gt; with abbreviation for orthography 2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
diff --git a/Makefile.am b/Makefile.am&lt;br /&gt;
index 3537fd7..86d9751 100644&lt;br /&gt;
--- a/Makefile.am&lt;br /&gt;
+++ b/Makefile.am&lt;br /&gt;
@@ -3,6 +3,10 @@&lt;br /&gt;
 ###############################################################################&lt;br /&gt;
 &lt;br /&gt;
 LANG1=abc&lt;br /&gt;
+SCRIPT1=ORTH1&lt;br /&gt;
+SCRIPT2=ORTH2&lt;br /&gt;
+LANG1SCRIPT1=$(LANG1)@$(SCRIPT1)&lt;br /&gt;
+LANG1SCRIPT2=$(LANG1)@$(SCRIPT2)&lt;br /&gt;
 BASENAME=apertium-$(LANG1)&lt;br /&gt;
 &lt;br /&gt;
 TARGETS_COMMON =			\&lt;br /&gt;
@@ -14,6 +18,12 @@ TARGETS_COMMON =			\&lt;br /&gt;
 	$(LANG1).autogen.att.gz		\&lt;br /&gt;
 	$(LANG1).autopgen.bin		\&lt;br /&gt;
 	$(LANG1).rlx.bin            \&lt;br /&gt;
+	$(LANG1SCRIPT1).autogen.hfst \&lt;br /&gt;
+	$(LANG1SCRIPT2).autogen.hfst \&lt;br /&gt;
+	$(LANG1SCRIPT1).autogen.bin \&lt;br /&gt;
+	$(LANG1SCRIPT2).autogen.bin \&lt;br /&gt;
+	$(LANG1).$(SCRIPT1)-$(SCRIPT2).hfst \&lt;br /&gt;
+	$(LANG1).$(SCRIPT2)-$(SCRIPT1).hfst&lt;br /&gt;
 	$(LANG1).zhfst&lt;br /&gt;
 &lt;br /&gt;
 # This include defines goals for install-modes, .deps/.d, autobil.prefixes and .mode files:&lt;br /&gt;
@@ -49,14 +59,73 @@ TARGETS_COMMON =			\&lt;br /&gt;
 .deps/$(LANG1).LR.hfst: .deps/$(LANG1).LR.lexd.hfst .deps/$(LANG1).twol.hfst&lt;br /&gt;
 	hfst-compose-intersect -1 .deps/$(LANG1).LR.lexd.hfst -2 .deps/$(LANG1).twol.hfst -o $@&lt;br /&gt;
 &lt;br /&gt;
-$(LANG1).autogen.hfst: .deps/$(LANG1).RL.hfst&lt;br /&gt;
+# Default autogen is SCRIPT1&lt;br /&gt;
+&lt;br /&gt;
+$(LANG1SCRIPT1).autogen.hfst: .deps/$(LANG1).RL.hfst&lt;br /&gt;
 	hfst-fst2fst -O $&amp;lt; -o $@&lt;br /&gt;
 &lt;br /&gt;
+$(LANG1).autogen.hfst: $(LANG1SCRIPT1).autogen.hfst&lt;br /&gt;
+	cp $&amp;lt; $@&lt;br /&gt;
+&lt;br /&gt;
 .deps/$(LANG1).spellrelax.hfst: $(BASENAME).$(LANG1).spellrelax .deps/.d&lt;br /&gt;
 	hfst-regexp2fst -S -o $@ $&amp;lt;&lt;br /&gt;
 &lt;br /&gt;
-$(LANG1).automorf.hfst: .deps/$(LANG1).LR.hfst .deps/$(LANG1).spellrelax.hfst&lt;br /&gt;
-	hfst-compose -1 $&amp;lt; -2 .deps/$(LANG1).spellrelax.hfst | hfst-invert | hfst-fst2fst -O -o $@&lt;br /&gt;
+# SCRIPT2 autogen&lt;br /&gt;
+$(LANG1SCRIPT2).autogen.hfst: .deps/$(LANG1SCRIPT1)-$(LANG1SCRIPT2).hfst .deps/$(LANG1).RL.hfst .deps/.d&lt;br /&gt;
+	hfst-compose -1 `echo $(word 2,$^)` -2 $&amp;lt; | hfst-fst2fst -w -o $@&lt;br /&gt;
+&lt;br /&gt;
+# Base orthographic converter&lt;br /&gt;
+&lt;br /&gt;
+# SCRIPT1 automorf&lt;br /&gt;
+.deps/$(LANG1SCRIPT1).automorf.hfst: .deps/$(LANG1).LR.hfst .deps/$(LANG1).spellrelax.hfst .deps/.d&lt;br /&gt;
+	hfst-compose-intersect -1 $&amp;lt; -2 .deps/$(LANG1).spellrelax.hfst | hfst-invert -o $@&lt;br /&gt;
+&lt;br /&gt;
+# SCRIPT2 automorf&lt;br /&gt;
+.deps/$(LANG1SCRIPT2).automorf.hfst: .deps/$(LANG1SCRIPT1)-$(LANG1SCRIPT2).hfst .deps/$(LANG1).LR.hfst .deps/$(LANG1).spellrelax.hfst .deps/.d&lt;br /&gt;
+	hfst-compose -1 `echo $(word 2,$^)` -2 $&amp;lt; | hfst-compose-intersect -1 - -2 `echo $(word 3,$^)` | hfst-invert -o $@&lt;br /&gt;
+&lt;br /&gt;
+# automorf that analyses SCRIPT1 and SCRIPT2&lt;br /&gt;
+$(LANG1).automorf.hfst: .deps/$(LANG1SCRIPT1).automorf.hfst .deps/$(LANG1SCRIPT2).automorf.hfst&lt;br /&gt;
+	hfst-invert $&amp;lt; -o .deps/$(LANG1SCRIPT1).REVautomorf.hfst&lt;br /&gt;
+	hfst-invert `echo $(word 2,$^)` -o .deps/$(LANG1SCRIPT2).REVautomorf.hfst&lt;br /&gt;
+	hfst-union -1 .deps/$(LANG1SCRIPT1).REVautomorf.hfst -2 .deps/$(LANG1SCRIPT2).REVautomorf.hfst | hfst-invert | hfst-minimise | hfst-fst2fst -w -o $@&lt;br /&gt;
+&lt;br /&gt;
+# SCRIPT1 to SCRIPT2 transducer&lt;br /&gt;
+.deps/$(LANG1SCRIPT1)-$(LANG1SCRIPT2).hfst: .deps/$(LANG1SCRIPT1)-$(LANG1SCRIPT2).lexd.hfst .deps/$(LANG1SCRIPT1)-$(LANG1SCRIPT2).twol.hfst .deps/.d&lt;br /&gt;
+	hfst-compose-intersect -1 $&amp;lt; -2 .deps/$(LANG1SCRIPT1)-$(LANG1SCRIPT2).twol.hfst -o $@&lt;br /&gt;
+&lt;br /&gt;
+# compile the first stage of the SCRIPT1-SCRIPT2 transliteration transducer&lt;br /&gt;
+.deps/$(LANG1SCRIPT1)-$(LANG1SCRIPT2).lexd.hfst: $(BASENAME).$(SCRIPT1)-$(SCRIPT2).lexd .deps/.d&lt;br /&gt;
+	lexd $&amp;lt; .deps/$(LANG1SCRIPT1)-$(LANG1SCRIPT2).lexd.att&lt;br /&gt;
+	hfst-txt2fst .deps/$(LANG1SCRIPT1)-$(LANG1SCRIPT2).lexd.att -o $@&lt;br /&gt;
+&lt;br /&gt;
+# compile the second stage of the SCRIPT1-SCRIPT2 transliteration transducer&lt;br /&gt;
+.deps/$(LANG1SCRIPT1)-$(LANG1SCRIPT2).twol.hfst: $(BASENAME).$(SCRIPT1)-$(SCRIPT2).twol&lt;br /&gt;
+	hfst-twolc $&amp;lt; -o $@&lt;br /&gt;
+&lt;br /&gt;
+# SCRIPT1 to SCRIPT2 orthographic converter&lt;br /&gt;
+&lt;br /&gt;
+$(LANG1).$(SCRIPT1)-$(SCRIPT2).hfst: .deps/$(LANG1SCRIPT1)-$(LANG1SCRIPT2).hfst .deps/.d&lt;br /&gt;
+	hfst-fst2fst $&amp;lt; -Oo $@&lt;br /&gt;
+&lt;br /&gt;
+.deps/$(LANG1SCRIPT1)-$(LANG1SCRIPT2).att: .deps/$(LANG1SCRIPT1)-$(LANG1SCRIPT2).hfst .deps/.d&lt;br /&gt;
+	hfst-fst2txt $&amp;lt; -o $@&lt;br /&gt;
+&lt;br /&gt;
+$(LANG1).$(SCRIPT1)-$(SCRIPT2).bin: .deps/$(LANG1SCRIPT1)-$(LANG1SCRIPT2).att .deps/.d&lt;br /&gt;
+	lt-comp -H lr $&amp;lt; $@&lt;br /&gt;
+&lt;br /&gt;
+# SCRIPT2 to SCRIPT1 orthographic converter&lt;br /&gt;
+&lt;br /&gt;
+$(LANG1).$(SCRIPT2)-$(SCRIPT1).hfst: .deps/$(LANG1SCRIPT1)-$(LANG1SCRIPT2).hfst .deps/.d&lt;br /&gt;
+	hfst-invert $&amp;lt; | hfst-fst2fst -Oo $@&lt;br /&gt;
+&lt;br /&gt;
+.deps/$(LANG1SCRIPT2)-$(LANG1SCRIPT1).att: .deps/$(LANG1SCRIPT1)-$(LANG1SCRIPT2).hfst .deps/.d&lt;br /&gt;
+	hfst-invert | hfst-fst2txt -o $@&lt;br /&gt;
+&lt;br /&gt;
+$(LANG1).$(SCRIPT2)-$(SCRIPT1).bin: .deps/$(LANG1SCRIPT2)-$(LANG1SCRIPT1).att .deps/.d&lt;br /&gt;
+	lt-comp -H lr $&amp;lt; $@&lt;br /&gt;
+&lt;br /&gt;
+# bin files of automorfs and autogens&lt;br /&gt;
 &lt;br /&gt;
 $(LANG1).autogen.att.gz: $(LANG1).autogen.hfst&lt;br /&gt;
 	hfst-fst2txt $&amp;lt; | gzip -9 -c -n &amp;gt; $@&lt;br /&gt;
@@ -64,10 +133,13 @@ $(LANG1).autogen.att.gz: $(LANG1).autogen.hfst&lt;br /&gt;
 $(LANG1).automorf.att.gz: $(LANG1).automorf.hfst&lt;br /&gt;
 	hfst-fst2txt $&amp;lt; | gzip -9 -c -n &amp;gt; $@&lt;br /&gt;
 &lt;br /&gt;
-$(LANG1).autogen.bin: $(LANG1).autogen.att.gz .deps/.d&lt;br /&gt;
+$(LANG1SCRIPT1).autogen.bin: $(LANG1).autogen.att.gz .deps/.d&lt;br /&gt;
 	zcat &amp;lt; $&amp;lt; &amp;gt; .deps/$(LANG1).autogen.att&lt;br /&gt;
 	lt-comp lr .deps/$(LANG1).autogen.att $@&lt;br /&gt;
 &lt;br /&gt;
+$(LANG1).autogen.bin: $(LANG1SCRIPT1).autogen.bin&lt;br /&gt;
+	cp $&amp;lt; $@&lt;br /&gt;
+&lt;br /&gt;
 $(LANG1).automorf.bin: $(LANG1).automorf.att.gz .deps/.d&lt;br /&gt;
 	zcat &amp;lt; $&amp;lt; &amp;gt; .deps/$(LANG1).automorf.att&lt;br /&gt;
 	lt-comp lr .deps/$(LANG1).automorf.att $@&lt;br /&gt;
@@ -75,6 +147,14 @@ $(LANG1).automorf.bin: $(LANG1).automorf.att.gz .deps/.d&lt;br /&gt;
 $(LANG1).autopgen.bin: $(BASENAME).post-$(LANG1).dix&lt;br /&gt;
 	lt-comp lr $&amp;lt; $@&lt;br /&gt;
 &lt;br /&gt;
+$(LANG1SCRIPT2).autogen.att.gz: $(LANG1SCRIPT2).autogen.hfst&lt;br /&gt;
+	hfst-fst2txt $&amp;lt; | gzip -9 -c -n &amp;gt; $@&lt;br /&gt;
+&lt;br /&gt;
+$(LANG1SCRIPT2).autogen.bin: $(LANG1SCRIPT2).autogen.att.gz .deps/.d&lt;br /&gt;
+	zcat &amp;lt; $&amp;lt; &amp;gt; .deps/$(LANG1SCRIPT2).autogen.att&lt;br /&gt;
+	lt-comp lr .deps/$(LANG1SCRIPT2).autogen.att $@&lt;br /&gt;
+&lt;br /&gt;
+&lt;br /&gt;
 ###############################################################################&lt;br /&gt;
 ## Debugging transducers (for testvoc)&lt;br /&gt;
 ###############################################################################&lt;br /&gt;
diff --git a/modes.xml b/modes.xml&lt;br /&gt;
index 49740ed..1e152f9 100644&lt;br /&gt;
--- a/modes.xml&lt;br /&gt;
+++ b/modes.xml&lt;br /&gt;
@@ -36,6 +36,38 @@&lt;br /&gt;
     &amp;lt;/pipeline&amp;gt;&lt;br /&gt;
   &amp;lt;/mode&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
+  &amp;lt;mode name=&amp;quot;abc_ORTH1-gener&amp;quot; install=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
+    &amp;lt;pipeline&amp;gt;&lt;br /&gt;
+      &amp;lt;program name=&amp;quot;lt-proc -g&amp;quot;&amp;gt;&lt;br /&gt;
+        &amp;lt;file name=&amp;quot;abc@ORTH1.autogen.bin&amp;quot;/&amp;gt;&lt;br /&gt;
+      &amp;lt;/program&amp;gt;&lt;br /&gt;
+    &amp;lt;/pipeline&amp;gt;&lt;br /&gt;
+  &amp;lt;/mode&amp;gt;&lt;br /&gt;
+&lt;br /&gt;
+  &amp;lt;mode name=&amp;quot;abc_ORTH2-gener&amp;quot; install=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
+    &amp;lt;pipeline&amp;gt;&lt;br /&gt;
+      &amp;lt;program name=&amp;quot;lt-proc -g&amp;quot;&amp;gt;&lt;br /&gt;
+        &amp;lt;file name=&amp;quot;abc@ORTH2.autogen.bin&amp;quot;/&amp;gt;&lt;br /&gt;
+      &amp;lt;/program&amp;gt;&lt;br /&gt;
+    &amp;lt;/pipeline&amp;gt;&lt;br /&gt;
+  &amp;lt;/mode&amp;gt;&lt;br /&gt;
+&lt;br /&gt;
+  &amp;lt;mode name=&amp;quot;abc_ORTH1-abc_ORTH2&amp;quot; install=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
+    &amp;lt;pipeline&amp;gt;&lt;br /&gt;
+      &amp;lt;program name=&amp;quot;hfst-proc&amp;quot;&amp;gt;&lt;br /&gt;
+        &amp;lt;file name=&amp;quot;abc.ORTH1-ORTH2.hfst&amp;quot;/&amp;gt;&lt;br /&gt;
+      &amp;lt;/program&amp;gt;&lt;br /&gt;
+    &amp;lt;/pipeline&amp;gt;&lt;br /&gt;
+  &amp;lt;/mode&amp;gt;&lt;br /&gt;
+&lt;br /&gt;
+  &amp;lt;mode name=&amp;quot;abc_ORTH2-abc_ORTH1&amp;quot; install=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
+    &amp;lt;pipeline&amp;gt;&lt;br /&gt;
+      &amp;lt;program name=&amp;quot;hfst-proc&amp;quot;&amp;gt;&lt;br /&gt;
+        &amp;lt;file name=&amp;quot;abc.ORTH2-ORTH1.hfst&amp;quot;/&amp;gt;&lt;br /&gt;
+      &amp;lt;/program&amp;gt;&lt;br /&gt;
+    &amp;lt;/pipeline&amp;gt;&lt;br /&gt;
+  &amp;lt;/mode&amp;gt;&lt;br /&gt;
+&lt;br /&gt;
   &amp;lt;mode name=&amp;quot;abc-tagger&amp;quot; install=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;pipeline&amp;gt;&lt;br /&gt;
       &amp;lt;program name=&amp;quot;lt-proc -w&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Firespeaker</name></author>
		
	</entry>
</feed>