Home > asr > syls2css.m

syls2css

PURPOSE ^

syls2css: Find the confusing syllable set (CSS) from a given Mandarin syllable sequence in HanYu PinYin.

SYNOPSIS ^

function output=syls2css(syls, dict)

DESCRIPTION ^

 syls2css: Find the confusing syllable set (CSS) from a given Mandarin syllable sequence in HanYu PinYin.
    The output CSS is obtained by analyzing Mandarin utterances of native Japanese.

    Usage: output=syls2css(syl)
           output=syls2css(syl, dict)

    The second usage will remove the confusing syllables that are not in the dict.

    For example:

        syls={'ren', 'men'};    % 人們
        css1=syls2css(syls)
        dictFile='hanyu.dic';
        dict=dictRead(dictFile);
        css2=syls2css(syls, dict)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function output=syls2css(syls, dict)
0002 % syls2css: Find the confusing syllable set (CSS) from a given Mandarin syllable sequence in HanYu PinYin.
0003 %    The output CSS is obtained by analyzing Mandarin utterances of native Japanese.
0004 %
0005 %    Usage: output=syls2css(syl)
0006 %           output=syls2css(syl, dict)
0007 %
0008 %    The second usage will remove the confusing syllables that are not in the dict.
0009 %
0010 %    For example:
0011 %
0012 %        syls={'ren', 'men'};    % 人們
0013 %        css1=syls2css(syls)
0014 %        dictFile='hanyu.dic';
0015 %        dict=dictRead(dictFile);
0016 %        css2=syls2css(syls, dict)
0017 
0018 %    Roger Jang, 20070214
0019 
0020 if nargin<1, selfdemo; return; end
0021 if nargin<2, dict=[]; end
0022 
0023 % ====== syls={'bo'}
0024 if length(syls)==1
0025     sylSet=syl2css(syls, dict);
0026     for j=1:length(sylSet)
0027         output(j,1)=sylSet{j};
0028     end
0029     return;
0030 end
0031 
0032 % ====== syls={'tian', 'qi', 're', 'da', 'ha', 'qian'}
0033 sylSet=syl2css(syls{1}, dict);
0034 prevOutput=syls2css(syls(2:end), dict);
0035 entryNum=size(prevOutput, 1);
0036 output={};
0037 for i=1:length(sylSet)
0038     item=sylSet{i};
0039     for j=1:entryNum
0040         firstCol{j,1}=item;
0041     end
0042     if i==1
0043         output=[firstCol, prevOutput];
0044     else
0045         output=[output; firstCol, prevOutput];
0046     end
0047 end
0048 
0049 % ====== Self demo
0050 function selfdemo
0051 syls={'ren', 'men'}    % 人們
0052 css1=syl2css(syls)
0053 dictFile='hanyu.dic';
0054 dict=dictRead(dictFile);
0055 css2=syls2css(syls, dict)

Generated on Tue 01-Jun-2010 09:50:19 by m2html © 2003