galat****@lists*****
galat****@lists*****
2006年 10月 22日 (日) 14:42:02 JST
Index: chaone/accent.xsl diff -u chaone/accent.xsl:1.1.1.1 chaone/accent.xsl:1.2 --- chaone/accent.xsl:1.1.1.1 Thu Sep 14 14:45:38 2006 +++ chaone/accent.xsl Sun Oct 22 14:42:02 2006 @@ -3,8 +3,9 @@ <!-- XSLT stylesheet for ChaOne --> <!-- for msxml and exslt --> <!-- (3) Accent Combination --> -<!-- ver. 1.2.0b6 --> -<!-- 2006-07-25 by Studio ARC --> +<!-- ver. 1.3.0a1 --> +<!-- for UniDic 1.2.0 --> +<!-- 2006-10-12 by Studio ARC --> <!-- Copyright (c) 2004-2006 Studio ARC --> <xsl:stylesheet @@ -29,6 +30,13 @@ <xsl:apply-templates /> </xsl:template> + <xsl:template match="*"> + <xsl:copy> + <xsl:copy-of select="@*"/> + <xsl:apply-templates/> + </xsl:copy> + </xsl:template> + <xsl:template match="S"> <xsl:variable name="ws"> <xsl:apply-templates mode="preap"/> @@ -385,9 +393,9 @@ <xsl:attribute name="silence"> <xsl:variable name="spos" select="$ap/*[1]/@pos"/> <xsl:choose> - <xsl:when test="($spos = '»Ì¼-Ç_') or ($spos = '»Ì¼-ÊJ') or ($spos = '»Ì¼-ÊÂ') or ((self::SILENCE) + <xsl:when test="($spos = 'âL-Ç_') or ($spos = 'âL-ÊJ') or ($spos = 'âL-ÊÂ') or ((self::SILENCE) and ($term = 'after'))">PAU</xsl:when> - <xsl:when test="$spos = '»Ì¼-å_'">SILE</xsl:when> + <xsl:when test="$spos = 'âL-å_'">SILE</xsl:when> <xsl:otherwise>NON</xsl:otherwise> </xsl:choose> </xsl:attribute> Index: chaone/ap_rule.xml diff -u chaone/ap_rule.xml:1.1.1.1 chaone/ap_rule.xml:1.2 --- chaone/ap_rule.xml:1.1.1.1 Thu Sep 14 14:44:13 2006 +++ chaone/ap_rule.xml Sun Oct 22 14:42:02 2006 @@ -2,8 +2,9 @@ <!-- ANZgåK¥ --> <!-- used in ChaOne --> -<!-- 2005-03-24 by Studio ARC --> -<!-- Copyright (c) 2005 Studio ARC --> +<!-- for UniDic 1.2.0 --> +<!-- 2006-10-18 by Studio ARC --> +<!-- Copyright (c) 2005-2006 Studio ARC --> <ap_rule> @@ -24,14 +25,6 @@ <!-- £·éK¥ª Á½êÍA --> <!-- XgãÅæÉo»µ½à̪Dæ³êé --> -<!-- tB[ÍPÆÌANZgåÉ --> -<rule id="0" priority="1"> - <cond> - <current pos="´®-tB["/> - </cond> - <then ap="alone"/> -</rule> - <!-- 'H' ÌOÍÊÌANZgåÉ --> <rule id="1" priority="50"> <cond> @@ -54,8 +47,8 @@ <rule id="3-1" priority="48"> <cond> <or> - <current pos="»Ì¼-å_"/> - <current pos="»Ì¼-Ç_"/> + <current pos="âL-å_"/> + <current pos="âL-Ç_"/> </or> </cond> <then ap="alone"/> @@ -65,20 +58,62 @@ <rule id="3-2" priority="48"> <cond> <or> - <current pos="»Ì¼-ÊJ"/> - <current pos="»Ì¼-ÊÂ"/> + <current pos="âL-ÊJ"/> + <current pos="âL-ÊÂ"/> </or> </cond> <then ap="alone"/> </rule> -<!-- ®-ñ©§ (¢éAÈÇ) A`e-ñ©§ÍOÉÁ¯é --> -<rule id="4" priority="46"> +<!-- ®-ñ©§Í®ÌAp`CTÏÂ\¼CÚ±uÄvuÅvÉÚ±·éêÉOÉÁ¯é --> +<rule id="4-1" priority="46"> <cond> - <or> + <and> <current pos="®-ñ©§Â\"/> + <or> + <and> + <pre pos="®"/> + <pre cForm="Ap`"/> + </and> + <pre pos="¼-ʼ-TÏÂ\"/> + <and> + <pre pos="-Ú±"/> + <pre orth="Ä"/> + </and> + <and> + <pre pos="-Ú±"/> + <pre orth="Å"/> + </and> + </or> + </and> + </cond> + <then ap="cont"/> +</rule> + +<!-- `e-ñ©§Í®ÌAp`âÚ±uÄvuÅvÉÚ±·éêÉOÉÁ¯é --> +<rule id="4-2" priority="46"> + <cond> + <and> <current pos="`e-ñ©§Â\"/> - </or> + <or> + <and> + <pre pos="®"/> + <pre cForm="Ap`"/> + </and> + <and> + <pre pos="`e"/> + <pre cForm="Ap`"/> + </and> + <and> + <pre pos="-Ú±"/> + <pre orth="Ä"/> + </and> + <and> + <pre pos="-Ú±"/> + <pre orth="Å"/> + </and> + </or> + </and> </cond> <then ap="cont"/> </rule> Index: chaone/chaone_t_main.xsl diff -u chaone/chaone_t_main.xsl:1.1.1.1 chaone/chaone_t_main.xsl:1.2 --- chaone/chaone_t_main.xsl:1.1.1.1 Thu Sep 14 14:44:58 2006 +++ chaone/chaone_t_main.xsl Sun Oct 22 14:42:02 2006 @@ -2,14 +2,15 @@ <!-- XSLT stylesheet for ChaOne --> <!-- for msxml and exslt --> -<!-- ver. 1.2.0b5 --> +<!-- ver. 1.3.0a1 --> +<!-- for UniDic 1.2.0 --> <!-- ChaOne consists of the followings; --> <!-- (0) preprocessing --> <!-- (1) ChaSen Chunker --> <!-- (2) Phonetic Alternation --> <!-- (3) Accent Combination --> -<!-- 2005-07-09 by Studio ARC --> -<!-- Copyright (c) 2004-2005 Studio ARC --> +<!-- 2006-10-12 by Studio ARC --> +<!-- Copyright (c) 2004-2006 Studio ARC --> <!-- This program is based on the product --> <!-- developed in IPA project 1999-2002 --> @@ -47,8 +48,10 @@ <xsl:variable name="ea_symbol_table" select="document('ea_symbol_table.xml')/ea_symbol_table"/> <xsl:variable name="chunk_rules" select="document('chunk_rules.xml')/chunk_rules"/> - <xsl:variable name="IPAForm_table" select="document('IPAForm.xml')/IPAForm_table"/> - <xsl:variable name="FPAForm_table" select="document('FPAForm.xml')/FPAForm_table"/> + <xsl:variable name="IPA_table" select="document('IPAfn.xml')"/> + <xsl:variable name="FPA_table" select="document('FPAfn.xml')"/> + <xsl:key name="IPAfn" match="ifn" use="concat(@iType, @iForm, @iConType)"/> + <xsl:key name="FPAfn" match="ffn" use="concat(@fType, @fForm, @fConType)"/> <xsl:variable name="pos_list" select="document('grammar.xml')"/> <xsl:variable name="pa_word_list" select="document('pa_word.xml')"/> <xsl:key name="pos" match="pos" use="@ipadic"/> @@ -65,7 +68,14 @@ <xsl:apply-templates select="." mode="text"/> </xsl:message> </xsl:if> - <xsl:apply-templates select="S"/> + <xsl:apply-templates/> + </xsl:template> + + <xsl:template match="*"> + <xsl:copy> + <xsl:copy-of select="@*"/> + <xsl:apply-templates/> + </xsl:copy> </xsl:template> <xsl:template match="S"> Index: chaone/chunk_rules.xml diff -u chaone/chunk_rules.xml:1.1.1.1 chaone/chunk_rules.xml:1.2 --- chaone/chunk_rules.xml:1.1.1.1 Thu Sep 14 14:41:42 2006 +++ chaone/chunk_rules.xml Sun Oct 22 14:42:02 2006 @@ -1,14 +1,20 @@ <?xml version="1.0" encoding="Shift_JIS"?> +<!-- `J[K¥ --> +<!-- used in ChaOne --> +<!-- for UniDic 1.2.0 --> +<!-- 2006-10-11 by Studio ARC --> +<!-- Copyright (c) 2005-2006 Studio ARC --> + <chunk_rules> <rule id="1"> - <!-- ¼-ʼ-êÊ ::= (Úª«-¼Ú±-.*)? (¼-.*)* ¼-ʼ-êÊ --> + <!-- ¼-ʼ-êÊ ::= (Úª«)? (¼-.*)* ¼-ʼ-êÊ --> <lhs> <W2 pos="¼-ʼ-êÊ"/> </lhs> <rhs> <optional> - <W1 pos="Úª«-¼Ú±-"/> + <W1 pos="Úª«"/> </optional> <zeroOrMore> <W1 pos="¼-"/> @@ -17,13 +23,13 @@ </rhs> </rule> <rule id="2"> - <!-- ¼-ʼ-êÊ ::= (Úª«-¼Ú±-.*)? (¼-.*|®-.*|`e-.*)* (®)* (Úö«-¼I-.*)* Úö«-¼I-êÊ --> + <!-- ¼-ʼ-êÊ ::= (Úª«)? (¼-.*|®-.*|`e-.*)* (®)* (Úö«-¼I-.*)* Úö«-¼I-êÊ --> <lhs> <W2 pos="¼-ʼ-êÊ"/> </lhs> <rhs> <optional> - <W1 pos="Úª«-¼Ú±-"/> + <W1 pos="Úª«"/> </optional> <zeroOrMore> <choice> @@ -42,13 +48,13 @@ </rhs> </rule> <rule id="3"> - <!-- ¼-ʼ-TÏÂ\ ::= (Úª«-¼Ú±-.*)? (¼-.*)* ¼-ʼ-TÏÂ\ --> + <!-- ¼-ʼ-TÏÂ\ ::= (Úª«)? (¼-.*)* ¼-ʼ-TÏÂ\ --> <lhs> <W2 pos="¼-ʼ-TÏÂ\"/> </lhs> <rhs> <optional> - <W1 pos="Úª«-¼Ú±-"/> + <W1 pos="Úª«"/> </optional> <zeroOrMore> <W1 pos="¼-"/> @@ -57,13 +63,13 @@ </rhs> </rule> <rule id="4"> - <!-- ¼-ʼ-TÏÂ\ ::= (Úª«-¼Ú±-.*)? (¼-.*|®-.*|`e-.*)* (®)* (Úö«-¼I-.*)* Úö«-¼I-TÏÂ\ --> + <!-- ¼-ʼ-TÏÂ\ ::= (Úª«)? (¼-.*|®-.*|`e-.*)* (®)* (Úö«-¼I-.*)* Úö«-¼I-TÏÂ\ --> <lhs> <W2 pos="¼-ʼ-TÏÂ\"/> </lhs> <rhs> <optional> - <W1 pos="Úª«-¼Ú±-"/> + <W1 pos="Úª«"/> </optional> <zeroOrMore> <choice> @@ -82,28 +88,28 @@ </rhs> </rule> <rule id="5"> - <!-- ¼-ʼ-`óÂ\ ::= (Úª«-¼Ú±-.*)? (¼-.*)* ¼-ʼ-`óÂ\ --> + <!-- ¼-ʼ-`óÂ\ ::= (Úª«)? (¼-.*)* ¼-ʼ-`óÂ\ --> <lhs> <W2 pos="¼-ʼ-`óÂ\"/> </lhs> <rhs> <optional> - <W1 pos="Úª«-¼Ú±-"/> + <W1 pos="Úª«"/> </optional> <zeroOrMore> <W1 pos="¼-"/> </zeroOrMore> - <W1 pos="¼-ʼ-`óÂ\" zzz="1"/> + <W1 pos="¼-ʼ-`óÂ\"/> </rhs> </rule> <rule id="6"> - <!-- ¼-ʼ-`óÂ\ ::= (Úª«-¼Ú±-.*)? (¼-.*|®-.*|`e-.*)* (®)* (Úö«-¼I-.*)* Úö«-¼I-`óÂ\ --> + <!-- ¼-ʼ-`óÂ\ ::= (Úª«)? (¼-.*|®-.*|`e-.*)* (®)* (Úö«-¼I-.*)* Úö«-¼I-`óÂ\ --> <lhs> <W2 pos="¼-ʼ-`óÂ\"/> </lhs> <rhs> <optional> - <W1 pos="Úª«-¼Ú±-"/> + <W1 pos="Úª«"/> </optional> <zeroOrMore> <choice> @@ -122,34 +128,31 @@ </rhs> </rule> <rule id="7"> - <!-- ¼-ʼ-Â\ ::= (Úª«-¼Ú±-.*)? (¼--êÊ)+ (¼-- )? (Úö«-¼I-)* --> + <!-- ¼-ʼ-Â\ ::= (Úª«)? (¼-)+ (Úö«-¼I-)* --> <lhs> <W2 pos="¼-ʼ-Â\"/> </lhs> <rhs> <optional> - <W1 pos="Úª«-¼Ú±-"/> + <W1 pos="Úª«"/> </optional> - <W1 pos="¼--êÊ"/> + <W1 pos="¼-"/> <zeroOrMore> - <W1 pos="¼--êÊ"/> + <W1 pos="¼-"/> </zeroOrMore> - <optional> - <W1 pos="¼-- "/> - </optional> <zeroOrMore> <W1 pos="Úö«-¼I-"/> </zeroOrMore> </rhs> </rule> <rule id="8"> - <!-- ¼-ʼ-Â\ ::= (Úª«-¼Ú±-.*)? (¼-.*)* ¼-ʼ-Â\ --> + <!-- ¼-ʼ-Â\ ::= (Úª«)? (¼-.*)* ¼-ʼ-Â\ --> <lhs> <W2 pos="¼-ʼ-Â\"/> </lhs> <rhs> <optional> - <W1 pos="Úª«-¼Ú±-"/> + <W1 pos="Úª«"/> </optional> <zeroOrMore> <W1 pos="¼-"/> @@ -158,13 +161,13 @@ </rhs> </rule> <rule id="9"> - <!-- ¼-ʼ-Â\ ::= (Úª«-¼Ú±-.*)? (¼-.*|®-.*|`e-.*)* (®)* (Úö«-¼I-.*)* Úö«-¼I-Â\ --> + <!-- ¼-ʼ-Â\ ::= (Úª«)? (¼-.*|®-.*|`e-.*)* (®)* (Úö«-¼I-.*)* Úö«-¼I-Â\ --> <lhs> <W2 pos="¼-ʼ-Â\"/> </lhs> <rhs> <optional> - <W1 pos="Úª«-¼Ú±-"/> + <W1 pos="Úª«"/> </optional> <zeroOrMore> <choice> @@ -192,19 +195,19 @@ </rhs> </rule> <rule id="11"> - <!-- ¼-ÅL¼-l¼-êÊ ::= ¼-ÅL¼-l¼êÊ (Úö«-¼I-l¼)H --> + <!-- ¼-ÅL¼-l¼-êÊ ::= ¼-ÅL¼-l¼êÊ (Úö«-¼I-*)H --> <lhs> <W2 pos="¼-ÅL¼-l¼-êÊ"/> </lhs> <rhs> <W1 pos="¼-ÅL¼-l¼êÊ"/> <optional> - <W1 pos="Úö«-¼I-l¼"/> + <W1 pos="Úö«-¼I-*"/> </optional> </rhs> </rule> <rule id="12"> - <!-- ¼-ÅL¼-l¼-êÊ ::= (¼-ÅL¼-l¼-©)H ¼-ÅL¼-l¼-¼ (Úö«-¼I-l¼)H --> + <!-- ¼-ÅL¼-l¼-êÊ ::= (¼-ÅL¼-l¼-©)H ¼-ÅL¼-l¼-¼ (Úö«-¼I-*)H --> <lhs> <W2 pos="¼-ÅL¼-l¼-êÊ"/> </lhs> @@ -214,12 +217,12 @@ </optional> <W1 pos="¼-ÅL¼-l¼-¼"/> <optional> - <W1 pos="Úö«-¼I-l¼"/> + <W1 pos="Úö«-¼I-*"/> </optional> </rhs> </rule> <rule id="13"> - <!-- ¼-ÅL¼-l¼-êÊ ::= (¼-ÅL¼-l¼-¼)H ¼-ÅL¼-l¼-© (Úö«-¼I-l¼)H --> + <!-- ¼-ÅL¼-l¼-êÊ ::= (¼-ÅL¼-l¼-¼)H ¼-ÅL¼-l¼-© (Úö«-¼I-*)H --> <lhs> <W2 pos="¼-ÅL¼-l¼-êÊ"/> </lhs> @@ -229,19 +232,19 @@ </optional> <W1 pos="¼-ÅL¼-l¼-©"/> <optional> - <W1 pos="Úö«-¼I-l¼"/> + <W1 pos="Úö«-¼I-*"/> </optional> </rhs> </rule> <rule id="14"> - <!-- ¼-ÅL¼-n¼-êÊ ::= ¼-ÅL¼-n¼-êÊ (Úö«-¼I-n¼)? --> + <!-- ¼-ÅL¼-n¼-êÊ ::= ¼-ÅL¼-n¼-êÊ (Úö«-¼I-*)? --> <lhs> <W2 pos="¼-ÅL¼-n¼-êÊ"/> </lhs> <rhs> <W1 pos="¼-ÅL¼-n¼-êÊ"/> <optional> - <W1 pos="Úö«-¼I-n¼"/> + <W1 pos="Úö«-¼I-*"/> </optional> </rhs> </rule> @@ -255,7 +258,7 @@ </rhs> </rule> <rule id="16"> - <!-- ¼-ÅL¼-gD¼ ::= (¼-.*)* ¼-ÅL¼-gD¼ (¼-.*)* (Úö«-¼I-gD¼)? --> + <!-- ¼-ÅL¼-gD¼ ::= (¼-.*)* ¼-ÅL¼-gD¼ (¼-.*)* (Úö«-¼I-*)? --> <lhs> <W2 pos="¼-ÅL¼-gD¼"/> </lhs> @@ -268,7 +271,7 @@ <W1 pos="¼-"/> </zeroOrMore> <optional> - <W1 pos="Úö«-¼I-gD¼"/> + <W1 pos="Úö«-¼I-*"/> </optional> </rhs> </rule> Index: chaone/chunker.xsl diff -u chaone/chunker.xsl:1.1.1.1 chaone/chunker.xsl:1.2 --- chaone/chunker.xsl:1.1.1.1 Thu Sep 14 14:44:58 2006 +++ chaone/chunker.xsl Sun Oct 22 14:42:02 2006 @@ -2,10 +2,10 @@ <!-- XSLT stylesheet for ChaOne --> <!-- for msxml and exslt --> -<!-- ver. 1.2.0b4 --> +<!-- ver. 1.3.0a1 --> <!-- (1) ChaSen Chunker --> -<!-- 2005-03-25 by Studio ARC --> -<!-- Copyright (c) 2004-2005 Studio ARC --> +<!-- 2006-10-18 by Studio ARC --> +<!-- Copyright (c) 2004-2006 Studio ARC --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" @@ -21,7 +21,14 @@ <xsl:variable name="chunk_rules" select="document('chunk_rules.xml')/chunk_rules"/> <xsl:template match="/"> - <xsl:apply-templates select="S"/> + <xsl:apply-templates/> + </xsl:template> + + <xsl:template match="*"> + <xsl:copy> + <xsl:copy-of select="@*"/> + <xsl:apply-templates/> + </xsl:copy> </xsl:template> <xsl:template match="S"> @@ -851,7 +858,8 @@ <xsl:choose> <xsl:when test="$target[name() = 'W1']"> <W2> - <xsl:copy-of select="@*[(name() = 'orth') or (name() = 'pron') or (name() = 'pos')]"/> + <!-- xsl:copy-of select="@*[(name() = 'orth') or (name() = 'pron') or (name() = 'pos')]"/ --> + <xsl:copy-of select="@*[(name() = 'orth') or (name() = 'pos') or (name() = 'cType') or (name() = 'cForm')]"/> <xsl:copy-of select="$target"/> </W2> </xsl:when> Index: chaone/phonetic.xsl diff -u chaone/phonetic.xsl:1.1.1.1 chaone/phonetic.xsl:1.2 --- chaone/phonetic.xsl:1.1.1.1 Thu Sep 14 14:44:58 2006 +++ chaone/phonetic.xsl Sun Oct 22 14:42:02 2006 @@ -2,11 +2,12 @@ <!-- XSLT stylesheet for ChaOne --> <!-- for msxml and exslt --> -<!-- ver. 1.2.0b4 --> +<!-- ver. 1.3.0a1 --> +<!-- for UniDic 1.2.0 --> <!-- ChaOne consists of the followings; --> <!-- (2) Phonetic Alternation --> -<!-- 2005-03-25 by Studio ARC --> -<!-- Copyright (c) 2004-2005 Studio ARC --> +<!-- 2006-10-12 by Studio ARC --> +<!-- Copyright (c) 2004-2006 Studio ARC --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" @@ -19,11 +20,20 @@ <xsl:output method="xml" encoding="Shift_JIS" omit-xml-declaration="yes" indent="yes"/> - <xsl:variable name="IPAForm_table" select="document('IPAForm.xml')/IPAForm_table"/> - <xsl:variable name="FPAForm_table" select="document('FPAForm.xml')/FPAForm_table"/> + <xsl:variable name="IPA_table" select="document('IPAfn.xml')"/> + <xsl:variable name="FPA_table" select="document('FPAfn.xml')"/> + <xsl:key name="IPAfn" match="ifn" use="concat(@iType, @iForm, @iConType)"/> + <xsl:key name="FPAfn" match="ffn" use="concat(@fType, @fForm, @fConType)"/> <xsl:template match="/"> - <xsl:apply-templates select="S"/> + <xsl:apply-templates/> + </xsl:template> + + <xsl:template match="*"> + <xsl:copy> + <xsl:copy-of select="@*"/> + <xsl:apply-templates/> + </xsl:copy> </xsl:template> <xsl:template match="S"> @@ -57,142 +67,290 @@ <!-- ChaOne inside W2 --> <xsl:template match="W1" mode="alt"> - <xsl:variable name="ipaForm"> - <xsl:if test="@ipaType"> - <xsl:call-template name="calc-ipaForm"/> + <xsl:variable name="iForm_position"> + <xsl:if test="@iType"> + <xsl:call-template name="calc-iForm_position"/> </xsl:if> </xsl:variable> - <xsl:variable name="fpaForm"> - <xsl:if test="@fpaType"> - <xsl:call-template name="calc-fpaForm"/> + <xsl:variable name="fForm_position"> + <xsl:if test="@fType"> + <xsl:call-template name="calc-fForm_position"/> </xsl:if> </xsl:variable> - <xsl:variable name="pron"> - <xsl:call-template name="calc-pron"> - <xsl:with-param name="ipaForm" select="$ipaForm"/> - <xsl:with-param name="fpaForm" select="$fpaForm"/> - </xsl:call-template> + <xsl:variable name="position"> + <xsl:choose> + <xsl:when test="$iForm_position > 0"> + <xsl:value-of select="$iForm_position"/> + </xsl:when> + <xsl:when test="$fForm_position > 0"> + <xsl:value-of select="$fForm_position"/> + </xsl:when> + <xsl:otherwise> + <!-- select î{` (here ???) --> + + <xsl:value-of select="1"/> + + </xsl:otherwise> + </xsl:choose> </xsl:variable> <xsl:copy> - <xsl:copy-of select="@*"/> - <xsl:if test="string($ipaForm)"> - <xsl:attribute name="ipaForm"> - <xsl:value-of select="$ipaForm"/> - </xsl:attribute> - </xsl:if> - <xsl:if test="string($fpaForm)"> - <xsl:attribute name="fpaForm"> - <xsl:value-of select="$fpaForm"/> - </xsl:attribute> - </xsl:if> - <xsl:if test="string($pron)"> - <xsl:attribute name="pron"> - <xsl:value-of select="$pron"/> - </xsl:attribute> - </xsl:if> + <xsl:for-each select="@*"> + <xsl:call-template name="nth_attr"> + <xsl:with-param name="position" select="$position"/> + </xsl:call-template> + </xsl:for-each> </xsl:copy> </xsl:template> - <xsl:template name="calc-ipaForm"> - <!-- current() = W1 --> - <!-- returns value of ipaForm or nothing --> - <xsl:variable name="ipaConType" select="preceding-sibling::W1[1]/@ipaConType"/> - <xsl:variable name="ipaType" select="@ipaType"/> - <xsl:if test="string($ipaConType)"> - <xsl:value-of select="$IPAForm_table/IPAFormDefs[@IPAType = $ipaType]/IPAFormDef[@IPAConType = $ipaConType]/@IPAForm"/> - </xsl:if> - </xsl:template> - - <xsl:template name="calc-fpaForm"> - <!-- current() = W1 --> - <!-- returns value of fpaForm or nothing --> - <xsl:variable name="fpaConTypes" select="following-sibling::W1[1]/@fpaConType"/> - <xsl:variable name="fpaType" select="@fpaType"/> - <xsl:if test="string($fpaConTypes)"> - <xsl:variable name="fpaConType"> + <xsl:template name="nth_attr"> + <!-- current() = W1/@* --> + <!-- return nth value (slash separated) of attribute --> + <xsl:param name="position"/> + <xsl:attribute name="{name()}"> + <xsl:choose> + <xsl:when test="contains(., '/')"> + <xsl:call-template name="nth_val"> + <xsl:with-param name="position" select="$position"/> + <xsl:with-param name="pre" select="substring-before(., '{')"/> + <xsl:with-param name="post" select="substring-after(., '}')"/> + <xsl:with-param name="body" select="substring-before(substring-after(., '{'), '}')"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="."/> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + </xsl:template> + + <xsl:template name="nth_val"> + <!-- current() = W1/@* --> + <!-- return nth value (slash separated) of attribute --> + <!-- recursive --> + <xsl:param name="position"/> + <xsl:param name="pre"/> + <xsl:param name="post"/> + <xsl:param name="body"/> + <xsl:choose> + <xsl:when test="$position = 1"> <xsl:choose> - <xsl:when test="contains($fpaConTypes, ',')"> - <xsl:value-of select="substring-before($fpaConTypes, ',')"/> + <xsl:when test="contains($body, '/')"> + <xsl:value-of select="concat($pre, substring-before($body, '/'), $post)"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="$fpaConTypes"/> + <xsl:value-of select="concat($pre, $body, $post)"/> </xsl:otherwise> </xsl:choose> - </xsl:variable> - <xsl:value-of select="$FPAForm_table/FPAFormDefs[@FPAType = $fpaType]/FPAFormDef[@FPAConType = $fpaConType]/@FPAForm"/> - </xsl:if> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="nth_val"> + <xsl:with-param name="position" select="$position - 1"/> + <xsl:with-param name="pre" select="$pre"/> + <xsl:with-param name="post" select="$post"/> + <xsl:with-param name="body" select="substring-after($body, '/')"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> </xsl:template> - <xsl:template name="calc-pron"> + <xsl:template name="calc-iForm_position"> <!-- current() = W1 --> - <!-- returns value of pron --> - <xsl:param name="ipaForm"/> - <xsl:param name="fpaForm"/> - <xsl:call-template name="ipaForm-pron-alt"> - <xsl:with-param name="ipaForm" select="$ipaForm"/> - <xsl:with-param name="pron"> - <xsl:call-template name="fpaForm-pron-alt"> - <xsl:with-param name="fpaForm" select="$fpaForm"/> - <xsl:with-param name="pron" select="@pron"/> + <!-- returns position (nth) of iForm or position of î{` --> + <xsl:call-template name="calc-iForm_position_main"> + <xsl:with-param name="iType" select="@iType"/> + <xsl:with-param name="iConType"> + <xsl:call-template name="get_first"> + <xsl:with-param name="list" select="preceding-sibling::W1[1]/@iConType"/> </xsl:call-template> </xsl:with-param> + <xsl:with-param name="pre" select="substring-before(@iForm, '{')"/> + <xsl:with-param name="post" select="substring-after(@iForm, '}')"/> + <xsl:with-param name="iForms" select="substring-before(substring-after(@iForm, '{'), '}')"/> + <xsl:with-param name="position" select="1"/> + <xsl:with-param name="kihonkei" select="0"/> </xsl:call-template> </xsl:template> - <xsl:template name="ipaForm-pron-alt"> - <!-- current() = W1 --> - <!-- returns value of pron --> - <xsl:param name="ipaForm"/> - <xsl:param name="pron"/> - <xsl:variable name="ipaType" select="@ipaType"/> + <xsl:template name="get_first"> + <xsl:param name="list"/> <xsl:choose> - <xsl:when test="string($ipaForm)"> - <xsl:call-template name="alt-head"> - <xsl:with-param name="pron" select="$pron"/> - <xsl:with-param name="len" select="string-length($IPAForm_table/IPAFormDefs[@IPAType = $ipaType]/IPApronDef[@IPAForm = 'î{`']/@pron)"/> - <xsl:with-param name="alt" select="$IPAForm_table/IPAFormDefs[@IPAType = $ipaType]/IPApronDef[@IPAForm = $ipaForm]/@pron"/> + <xsl:when test="contains($list, '{')"> + <xsl:call-template name="get_first_main"> + <xsl:with-param name="pre" select="substring-before($list, '{')"/> + <xsl:with-param name="post" select="substring-after($list, '}')"/> + <xsl:with-param name="list" select="substring-before(substring-after($list, '{'), '}')"/> </xsl:call-template> </xsl:when> <xsl:otherwise> - <xsl:value-of select="$pron"/> + <xsl:value-of select="$list"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template name="get_first_main"> + <xsl:param name="pre"/> + <xsl:param name="post"/> + <xsl:param name="list"/> + <xsl:choose> + <xsl:when test="contains($list, '/')"> + <xsl:variable name="first" select="substring-before($list, '/')"/> + <xsl:choose> + <xsl:when test="string-length($first) = 0"> + <xsl:call-template name="get_first_main"> + <xsl:with-param name="pre" select="$pre"/> + <xsl:with-param name="post" select="$post"/> + <xsl:with-param name="list" select="substring-after($list, '/')"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat($pre, $first, $post)"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat($pre, $list, $post)"/> </xsl:otherwise> </xsl:choose> </xsl:template> - <xsl:template name="fpaForm-pron-alt"> + <xsl:template name="calc-iForm_position_main"> <!-- current() = W1 --> - <!-- returns value of pron --> - <xsl:param name="fpaForm"/> - <xsl:param name="pron"/> - <xsl:variable name="fpaType" select="@fpaType"/> + <!-- returns position (nth) of iForm whose ifn value = 1 --> + <!-- recursive --> + <xsl:param name="iType"/> + <xsl:param name="iConType"/> + <xsl:param name="pre"/> + <xsl:param name="post"/> + <xsl:param name="iForms"/> + <xsl:param name="position"/> + <xsl:param name="kihonkei"/> + <xsl:variable name="iForm"> + <xsl:choose> + <xsl:when test="contains($iForms, '/')"> + <xsl:value-of select="concat($pre, substring-before($iForms, '/'), $post)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat($pre, $iForms, $post)"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="iForm_val"> + <xsl:for-each select="$IPA_table"> + <xsl:value-of select="key('IPAfn', concat($iType, $iForm, $iConType))/@val"/> + </xsl:for-each> + </xsl:variable> <xsl:choose> - <xsl:when test="string($fpaForm)"> - <xsl:call-template name="alt-tail"> - <xsl:with-param name="pron" select="$pron"/> - <xsl:with-param name="len" select="string-length($FPAForm_table/FPAFormDefs[@FPAType = $fpaType]/FPApronDef[@FPAForm = 'î{`']/@pron)"/> - <xsl:with-param name="alt" select="$FPAForm_table/FPAFormDefs[@FPAType = $fpaType]/FPApronDef[@FPAForm = $fpaForm]/@pron"/> + <xsl:when test="$iForm_val = 1"> + <xsl:value-of select="$position"/> + </xsl:when> + <xsl:when test="contains($iForms, '/')"> + <xsl:call-template name="calc-iForm_position_main"> + <xsl:with-param name="iType" select="$iType"/> + <xsl:with-param name="iConType" select="$iConType"/> + <xsl:with-param name="pre" select="$pre"/> + <xsl:with-param name="post" select="$post"/> + <xsl:with-param name="iForms" select="substring-after($iForms, '/')"/> + <xsl:with-param name="position" select="$position + 1"/> + <xsl:with-param name="kihonkei"> + <xsl:choose> + <xsl:when test="($iForm = 'î{`') and ($kihonkei = 0)"> + <xsl:value-of select="$position"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$kihonkei"/> + </xsl:otherwise> + </xsl:choose> + </xsl:with-param> </xsl:call-template> </xsl:when> <xsl:otherwise> - <xsl:value-of select="$pron"/> + <xsl:value-of select="$kihonkei"/> </xsl:otherwise> </xsl:choose> </xsl:template> - <xsl:template name="alt-head"> - <xsl:param name="pron"/> - <xsl:param name="len"/> - <xsl:param name="alt"/> - <xsl:value-of select="$alt"/> - <xsl:value-of select="substring($pron, number($len) + 1)"/> + <xsl:template name="calc-fForm_position"> + <!-- current() = W1 --> + <!-- returns position (nth) of fForm or position of î{` --> + <xsl:variable name="fConTypes" select="following-sibling::W1[1]/@fConType"/> + <xsl:call-template name="calc-fForm_position_main"> + <xsl:with-param name="fType"> + <xsl:call-template name="get_first"> + <xsl:with-param name="list" select="@fType"/> + </xsl:call-template> + </xsl:with-param> + <xsl:with-param name="fConType"> + <xsl:choose> + <xsl:when test="contains($fConTypes, ',')"> + <xsl:value-of select="substring-before($fConTypes, ',')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$fConTypes"/> + </xsl:otherwise> + </xsl:choose> + </xsl:with-param> + <xsl:with-param name="pre" select="substring-before(@fForm, '{')"/> + <xsl:with-param name="post" select="substring-after(@fForm, '}')"/> + <xsl:with-param name="fForms" select="substring-before(substring-after(@fForm, '{'), '}')"/> + <xsl:with-param name="position" select="1"/> + <xsl:with-param name="kihonkei" select="0"/> + </xsl:call-template> </xsl:template> - <xsl:template name="alt-tail"> - <xsl:param name="pron"/> - <xsl:param name="len"/> - <xsl:param name="alt"/> - <xsl:value-of select="substring($pron, 1, string-length($pron) - number($len))"/> - <xsl:value-of select="$alt"/> + <xsl:template name="calc-fForm_position_main"> + <!-- current() = W1 --> + <!-- returns position (nth) of fForm whose ffn value = 1 --> + <!-- recursive --> + <xsl:param name="fType"/> + <xsl:param name="fConType"/> + <xsl:param name="pre"/> + <xsl:param name="post"/> + <xsl:param name="fForms"/> + <xsl:param name="position"/> + <xsl:param name="kihonkei"/> + <xsl:variable name="fForm"> + <xsl:choose> + <xsl:when test="contains($fForms, '/')"> + <xsl:value-of select="concat($pre, substring-before($fForms, '/'), $post)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat($pre, $fForms, $post)"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="fForm_val"> + <xsl:for-each select="$FPA_table"> + <xsl:value-of select="key('FPAfn', concat($fType, $fForm, $fConType))/@val"/> + </xsl:for-each> + </xsl:variable> + <xsl:choose> + <xsl:when test="$fForm_val = 1"> + <xsl:value-of select="$position"/> + </xsl:when> + <xsl:when test="contains($fForms, '/')"> + <xsl:call-template name="calc-fForm_position_main"> + <xsl:with-param name="fType" select="$fType"/> + <xsl:with-param name="fConType" select="$fConType"/> + <xsl:with-param name="pre" select="$pre"/> + <xsl:with-param name="post" select="$post"/> + <xsl:with-param name="fForms" select="substring-after($fForms, '/')"/> + <xsl:with-param name="position" select="$position + 1"/> + <xsl:with-param name="kihonkei"> + <xsl:choose> + <xsl:when test="($fForm = 'î{`') and ($kihonkei = 0)"> + <xsl:value-of select="$position"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$kihonkei"/> + </xsl:otherwise> + </xsl:choose> + </xsl:with-param> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$kihonkei"/> + </xsl:otherwise> + </xsl:choose> </xsl:template> </xsl:stylesheet> Index: chaone/prep.xsl diff -u chaone/prep.xsl:1.1.1.1 chaone/prep.xsl:1.2 --- chaone/prep.xsl:1.1.1.1 Thu Sep 14 14:45:41 2006 +++ chaone/prep.xsl Sun Oct 22 14:42:02 2006 @@ -1,125 +1,132 @@ -<?xml version="1.0" encoding="Shift_JIS"?> - -<!-- XSLT stylesheet for ChaOne --> -<!-- for msxml and exslt --> -<!-- ver. 1.2.0b5 --> -<!-- (0) preprocessing --> -<!-- 2005-07-09 by Studio ARC --> -<!-- Copyright (c) 2004-2005 Studio ARC --> - -<xsl:stylesheet - xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:exsl="http://exslt.org/common" - xmlns:msxml="urn:schemas-microsoft-com:xslt" - xmlns:ext="http://exslt.org/common" - exclude-result-prefixes="exsl msxml ext" - version="1.0" - xml:lang="ja"> - - <xsl:output method="xml" encoding="Shift_JIS" omit-xml-declaration="yes" indent="yes"/> - - <xsl:param name="ipadic" select="'no'"/> - - <xsl:variable name="ea_symbol_table" select="document('ea_symbol_table.xml')/ea_symbol_table"/> - <xsl:variable name="pos_list" select="document('grammar.xml')"/> - <xsl:variable name="pa_word_list" select="document('pa_word.xml')"/> - <xsl:key name="pos" match="pos" use="@ipadic"/> - <xsl:key name="pa_word" match="W1" use="concat(@orth, @pron, @pos)"/> - - <xsl:template match="/"> - <xsl:apply-templates select="S"/> - </xsl:template> - - <xsl:template match="S"> - <xsl:copy> - <xsl:apply-templates mode="prep"/> - </xsl:copy> - </xsl:template> - - <xsl:template match="*" mode="prep"> - <xsl:choose> - <xsl:when test="@pos = '¢mê'"> - <xsl:call-template name="ea-symbol-chk"> - <xsl:with-param name="orth" select="@orth"/> - </xsl:call-template> - </xsl:when> - <xsl:when test="self::W1 and ($ipadic = 'yes')"> - <xsl:apply-templates select="." mode="ipadic"/> - </xsl:when> - <xsl:otherwise> - <xsl:copy> - <xsl:copy-of select="@*"/> - <xsl:apply-templates select="*" mode="prep"/> - </xsl:copy> - </xsl:otherwise> - </xsl:choose> - </xsl:template> - - <xsl:template match="W1" mode="ipadic"> - <xsl:variable name="ipa_pos" select="@pos"/> - <xsl:variable name="uni_pos"> - <xsl:for-each select="$pos_list"> - <xsl:value-of select="key('pos',$ipa_pos)/@unidic"/> - </xsl:for-each> - </xsl:variable> - <xsl:variable name="orthpronpos" select="concat(@orth, @pron, $uni_pos)"/> - <xsl:copy> - <xsl:for-each select="@*[name()!='pos']"> - <xsl:copy-of select="."/> - </xsl:for-each> - <xsl:attribute name="pos"> - <xsl:value-of select="$uni_pos"/> - </xsl:attribute> - <xsl:for-each select="$pa_word_list"> - <xsl:for-each select="key('pa_word',$orthpronpos)"> - <xsl:for-each select="@*[starts-with(name(), 'ipa') or starts-with(name(), 'fpa')]"> - <xsl:copy-of select="."/> - </xsl:for-each> - </xsl:for-each> - </xsl:for-each> - <xsl:apply-templates select="*" mode="prep"/> - </xsl:copy> - </xsl:template> - - <!-- preprocess for unknown pos with English Alphabet --> - <xsl:template name="ea-symbol-chk"> - <xsl:param name="orth"/> - <xsl:variable name="hits"> - <xsl:for-each select="$ea_symbol_table/W1[starts-with($orth, @orth)]"> - <xsl:sort select="string-length(@orth)"/> - <xsl:copy-of select="."/> - </xsl:for-each> - </xsl:variable> - <xsl:choose> - <xsl:when test="ext:node-set($hits)/W1[1]/@orth"> - <xsl:apply-templates select="ext:node-set($hits)/W1[1]" mode="ea-symbol"> - <xsl:with-param name="orgW1" select="."/> - <xsl:with-param name="orth" select="$orth"/> - </xsl:apply-templates> - </xsl:when> - <xsl:otherwise> - <xsl:copy-of select="."/> - </xsl:otherwise> - </xsl:choose> - </xsl:template> - - <xsl:template match="W1" mode="ea-symbol"> - <xsl:param name="orgW1"/> - <xsl:param name="orth"/> - <xsl:choose> - <xsl:when test="@orth"> - <xsl:copy-of select="."/> - <xsl:if test="string-length($orth) > string-length(@orth)"> - <!-- *** recursive call *** --> - <xsl:call-template name="ea-symbol-chk"> - <xsl:with-param name="orth" select="substring($orth, string-length(@orth) + 1)"/> - </xsl:call-template> - </xsl:if> - </xsl:when> - <xsl:otherwise> - <xsl:copy-of select="$orgW1"/> - </xsl:otherwise> - </xsl:choose> - </xsl:template> - -</xsl:stylesheet> +<?xml version="1.0" encoding="Shift_JIS"?> + +<!-- XSLT stylesheet for ChaOne --> +<!-- for msxml and exslt --> +<!-- ver. 1.3.0a1 --> +<!-- (0) preprocessing --> +<!-- 2006-10-12 by Studio ARC --> +<!-- Copyright (c) 2004-2006 Studio ARC --> + +<xsl:stylesheet + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:exsl="http://exslt.org/common" + xmlns:msxml="urn:schemas-microsoft-com:xslt" + xmlns:ext="http://exslt.org/common" + exclude-result-prefixes="exsl msxml ext" + version="1.0" + xml:lang="ja"> + + <xsl:output method="xml" encoding="Shift_JIS" omit-xml-declaration="yes" indent="yes"/> + + <xsl:param name="ipadic" select="'no'"/> + + <xsl:variable name="ea_symbol_table" select="document('ea_symbol_table.xml')/ea_symbol_table"/> + <xsl:variable name="pos_list" select="document('grammar.xml')"/> + <xsl:variable name="pa_word_list" select="document('pa_word.xml')"/> + <xsl:key name="pos" match="pos" use="@ipadic"/> + <xsl:key name="pa_word" match="W1" use="concat(@orth, @pron, @pos)"/> + + <xsl:template match="/"> + <xsl:apply-templates/> + </xsl:template> + + <xsl:template match="*"> + <xsl:copy> + <xsl:copy-of select="@*"/> + <xsl:apply-templates/> + </xsl:copy> + </xsl:template> + + <xsl:template match="S"> + <xsl:copy> + <xsl:apply-templates mode="prep"/> + </xsl:copy> + </xsl:template> + + <xsl:template match="*" mode="prep"> + <xsl:choose> + <xsl:when test="@pos = '¢mê'"> + <xsl:call-template name="ea-symbol-chk"> + <xsl:with-param name="orth" select="@orth"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="self::W1 and ($ipadic = 'yes')"> + <xsl:apply-templates select="." mode="ipadic"/> + </xsl:when> + <xsl:otherwise> + <xsl:copy> + <xsl:copy-of select="@*"/> + <xsl:apply-templates select="*" mode="prep"/> + </xsl:copy> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template match="W1" mode="ipadic"> + <xsl:variable name="ipa_pos" select="@pos"/> + <xsl:variable name="uni_pos"> + <xsl:for-each select="$pos_list"> + <xsl:value-of select="key('pos',$ipa_pos)/@unidic"/> + </xsl:for-each> + </xsl:variable> + <xsl:variable name="orthpronpos" select="concat(@orth, @pron, $uni_pos)"/> + <xsl:copy> + <xsl:for-each select="@*[name()!='pos']"> + <xsl:copy-of select="."/> + </xsl:for-each> + <xsl:attribute name="pos"> + <xsl:value-of select="$uni_pos"/> + </xsl:attribute> + <xsl:for-each select="$pa_word_list"> + <xsl:for-each select="key('pa_word',$orthpronpos)"> + <xsl:for-each select="@*[starts-with(name(), 'ipa') or starts-with(name(), 'fpa')]"> + <xsl:copy-of select="."/> + </xsl:for-each> + </xsl:for-each> + </xsl:for-each> + <xsl:apply-templates select="*" mode="prep"/> + </xsl:copy> + </xsl:template> + + <!-- preprocess for unknown pos with English Alphabet --> + <xsl:template name="ea-symbol-chk"> + <xsl:param name="orth"/> + <xsl:variable name="hits"> + <xsl:for-each select="$ea_symbol_table/W1[starts-with($orth, @orth)]"> + <xsl:sort select="string-length(@orth)"/> + <xsl:copy-of select="."/> + </xsl:for-each> + </xsl:variable> + <xsl:choose> + <xsl:when test="ext:node-set($hits)/W1[1]/@orth"> + <xsl:apply-templates select="ext:node-set($hits)/W1[1]" mode="ea-symbol"> + <xsl:with-param name="orgW1" select="."/> + <xsl:with-param name="orth" select="$orth"/> + </xsl:apply-templates> + </xsl:when> + <xsl:otherwise> + <xsl:copy-of select="."/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template match="W1" mode="ea-symbol"> + <xsl:param name="orgW1"/> + <xsl:param name="orth"/> + <xsl:choose> + <xsl:when test="@orth"> + <xsl:copy-of select="."/> + <xsl:if test="string-length($orth) > string-length(@orth)"> + <!-- *** recursive call *** --> + <xsl:call-template name="ea-symbol-chk"> + <xsl:with-param name="orth" select="substring($orth, string-length(@orth) + 1)"/> + </xsl:call-template> + </xsl:if> + </xsl:when> + <xsl:otherwise> + <xsl:copy-of select="$orgW1"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + +</xsl:stylesheet>